Created
September 19, 2024 22:04
-
-
Save ivorpad/a198c19ab4a96f4c070e9e8addd66727 to your computer and use it in GitHub Desktop.
Download m3u8 files
This file contains hidden or 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
const ffmpeg = require('fluent-ffmpeg'); | |
const path = require('path'); | |
const m3u8Url = 'https://stream.mux.com/playback_id.m3u8'; | |
const outputPath = path.join(__dirname, 'output.mp4'); | |
ffmpeg(m3u8Url) | |
.outputOptions([ | |
'-c copy', | |
'-bsf:a aac_adtstoasc' // Bitstream filter for AAC audio | |
]) | |
.on('start', (commandLine) => { | |
console.log('FFmpeg process started with command:', commandLine); | |
}) | |
.on('progress', (progress) => { | |
console.log(`Downloaded ${progress.percent.toFixed(2)}%`); | |
}) | |
.on('error', (err, stdout, stderr) => { | |
console.error('An error occurred:', err.message); | |
console.error('FFmpeg stderr:', stderr); | |
}) | |
.on('end', () => { | |
console.log('Download completed successfully!'); | |
}) | |
.save(outputPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment