26 lines
768 B
JavaScript
26 lines
768 B
JavaScript
import { createWriteStream } from 'node:fs'
|
|
import ffmpeg from 'fluent-ffmpeg'
|
|
|
|
// test stream from https://ottverse.com/free-hls-m3u8-test-urls/
|
|
const playlistUrl = 'https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8'
|
|
const fileOutputStream = createWriteStream('/tmp/test-stream.ts')
|
|
|
|
ffmpeg()
|
|
.input(playlistUrl)
|
|
.audioCodec('copy')
|
|
.videoCodec('copy')
|
|
.addOutputOptions('-movflags faststart')
|
|
.output(fileOutputStream)
|
|
.format('mpegts')
|
|
.on('end', () => {
|
|
console.log('Finished');
|
|
})
|
|
.on('error', (err, stdout, stderr) => {
|
|
console.error(`there was an error`);
|
|
console.error(err);
|
|
console.error(stdout);
|
|
console.error(stderr);
|
|
throw new Error(err.message);
|
|
})
|
|
.run();
|