I'm programming a tool for convert MP4 to HLS with nodejs , I'm trying to use fluent-ffmpeg to convert it , but I have some error at giving "outputOptions" .
My code :
var fs = require('fs');
var ffmpeg = require('fluent-ffmpeg');
// open input stream
var infs = new ffmpeg
infs.addInput('./data/test3.mp4').outputOptions([
'-map 0:0',
'-map 0:1',
'-map 0:0',
'-map 0:1',
'-s:v:0 2160x3840',
'-c:v:0 libx264',
'-b:v:0 2000k',
'-s:v:1 960x540',
'-c:v:1 libx264',
'-b:v:1 365k',
'-var_stream_map', '"v:0,a:0', 'v:1,a:1"',
'-master_pl_name master.m3u8',
'-f hls',
'-hls_time 1',
'-hls_list_size 0',
'-hls_segment_filename', '"v%v/fileSequence%d.ts"'
]).output('./data/v%v/prog_index.m3u8')
.on('start', function (commandLine) {
console.log('Spawned Ffmpeg with command: ' + commandLine);
})
.on('error', function (err, stdout, stderr) {
console.log('An error occurred: ' + err.message, err, stderr);
})
.on('progress', function (progress) {
console.log('Processing: ' + progress.percent + '% done')
})
.on('end', function (err, stdout, stderr) {
console.log('Finished processing!' /*, err, stdout, stderr*/)
})
.run()
the error i get is
Error: ffmpeg exited with code 1: v:1,a:1": Invalid argument
Unable to find a suitable output format for 'v:1,a:1"'
i have try to print out the command that fluent-ffmpeg spawned and i get
fmpeg -i ./data/test3.mp4 -y -map 0:0 -map 0:1 -map 0:0 -map 0:1 -s:v:0 2160x3840 -c:v:0 libx264 -b:v:0 2000k -s:v:1 960x540 -c:v:1 libx264 -b:v:1 365k -var_stream_map "v:0,a:0 v:1,a:1" -master_pl_name master.m3u8 -f hls -hls_time 1 -hls_list_size 0 -hls_segment_filename "v%v/fileSequence%d.ts" ./data/v%v/prog_index.m3u8
I paste this command in terminal and I can success convert the mp4 to hls.
what should I do at my code to let it success convert?
fluent-ffmpeg version : 2.1.2
ffmpeg version : 4.2.1
Edit: As per this fluent-ffmpeg issue comment, quote the vsm arg in single quotes, and use double quotes for the outer quotes.
The var_stream_map arg should be one string i.e.
'"v:0,a:0 v:1,a:1"',