1.2.8 • Published 23 days ago
hls2mp4 v1.2.8
A tool for download hls/m3u8 to mp4
- This package depends on @ffmpeg/ffmpeg, you need install it first
# install ffmpeg
npm install @ffmpeg/ffmpeg
- for more information, see https://github.com/ffmpegwasm/ffmpeg.wasm
online demo
install
# npm
npm install hls2mp4
# yarn
yarn add hls2mp4
usage
import Hls2Mp4 from "hls2mp4";
const hls2mp4 = new Hls2Mp4({
/**
* @type {number}
* max retry times while request data failed
*/
maxRetry = 3,
/**
* @type {number}
* the concurrency for download ts
*/
tsDownloadConcurrency = 10,
/**
* the base url of ffmpeg
*/
ffmpegBaseUrl = 'https://unpkg.com/@ffmpeg/core@0.12.2/dist/umd',
/**
* progress callback
*/
onProgress?: (type, progress) => {
// type = 0 => load FFmpeg
// type = 1 => parse m3u8
// type = 2 => downloading ts
// type = 3 => merge ts
};
/**
* error callback
*/
onError?: (error) => {};
});
const buffer = await hls2mp4.download('your m3u8 url')
if (buffer) {
hls2mp4.saveToFile(buffer, 'test.mp4')
}
else {
// download failed
}
as script
<script src="static/js/ffmpeg.min.js"></script>
<script src="dist/hls2mp4.js"></script>
<script>
const hls2mp4 = new Hls2Mp4({...})
</script>
1.2.8
23 days ago
1.2.7
3 months ago
1.2.6
4 months ago
1.2.5
5 months ago
1.2.4
7 months ago
1.2.3
8 months ago
1.2.2
8 months ago
1.2.1
8 months ago
1.2.0
8 months ago
1.1.1
12 months ago
1.1.0
12 months ago
1.1.9
11 months ago
1.1.8
12 months ago
1.1.7
12 months ago
1.1.6
12 months ago
1.1.5
12 months ago
1.1.4
12 months ago
1.1.3
12 months ago
1.1.2
12 months ago
2.0.3
11 months ago
2.0.2
11 months ago
2.0.5
11 months ago
2.0.4
11 months ago
2.0.1
11 months ago
2.0.0
11 months ago
1.0.9
12 months ago
1.0.8
12 months ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago