-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ying_123
committed
Jun 11, 2023
1 parent
65bea11
commit 55c15c4
Showing
3 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,6 @@ | |
# node modules | ||
node_modules/ | ||
|
||
# dist | ||
dist/package.json | ||
dist/README.md | ||
|
||
# roolup cache | ||
.rollup.cache/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
### A tool for download hls/m3u8 to mp4 | ||
|
||
#### no longer depend on @ffmpeg/ffmpeg since version 2.0 | ||
|
||
### online demo | ||
|
||
[online demo](https://code-app.netlify.app/hls2mp4/) | ||
|
||
### install | ||
|
||
```shell | ||
# npm | ||
npm install hls2mp4 | ||
|
||
# yarn | ||
yarn add hls2mp4 | ||
``` | ||
|
||
### usage | ||
|
||
```js | ||
import Hls2Mp4 from "hls2mp4"; | ||
|
||
const hls2mp4 = new Hls2Mp4({ | ||
/** | ||
* max retry times while request data failed, default: 3 | ||
*/ | ||
maxRetry?: number; | ||
/** | ||
* the concurrency for download ts segment, default: 10 | ||
*/ | ||
tsDownloadConcurrency?: number; | ||
/** | ||
* the type of output file, can be mp4 or ts, default: mp4 | ||
*/ | ||
outputType?: 'mp4' | 'ts'; | ||
|
||
}, (type, progress) => { | ||
// type = 0 => load FFmpeg | ||
// type = 1 => parse m3u8 | ||
// type = 2 => downloading ts | ||
// type = 3 => merge ts | ||
}); | ||
|
||
const buffer = await hls2mp4.download('your m3u8 url') | ||
hls2mp4.saveToFile(buffer, 'test.mp4') | ||
``` | ||
|
||
#### as script | ||
```html | ||
<script src="static/js/ffmpeg.min.js"></script> | ||
<script src="dist/hls2mp4.js"></script> | ||
<script> | ||
const hls2mp4 = new Hls2Mp4({...}) | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "hls2mp4", | ||
"version": "2.0.5", | ||
"description": "a tool for download hls/m3u8 to mp4", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"repository": "https://github.com/icefee/hls2mp4", | ||
"keywords": [ | ||
"ffmpeg", | ||
"hls", | ||
"m3u8" | ||
], | ||
"author": "[email protected]", | ||
"license": "MIT", | ||
"dependencies": { | ||
"aes-js": "^3.1.2" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^25.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.2", | ||
"@rollup/plugin-typescript": "^11.1.0", | ||
"@types/aes-js": "^3.1.1", | ||
"@types/node": "^20.2.5", | ||
"rollup": "^3.21.4", | ||
"tslib": "^2.0.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
"type": "module", | ||
"homepage": "https://github.com/icefee/hls2mp4", | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |