fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.64k stars 874 forks source link

Where to put `-map` flag. #1181

Open Kais3rP opened 2 years ago

Kais3rP commented 2 years ago

I'm trying to understand how to use the -map command in fluent-ffmpeg but did not find any reference in docs, I need to add VTT subtitles to a video input, and the all the resources I found suggest to use this approach:

ffmpeg -i foo.webm -i foo.en.vtt -map 0:v -map 0:a -map 1:s  -metadata:s:a language=eng -metadata:s:s:0   language=eng  -c copy -y           
foo.subbed.webm

But I have no idea where to set the -map commands, since they do not belong to a specific input I tried with inputOptions or addOptions without success.

richardbenson commented 2 years ago

FWIW this is how I got it to work:

    var command = new ffmpeg(sourceFilename).addOption([
        '-map 0',
        '-map -0:a:0',
        '-map -0:a:1',
        '-map -0:a:2',
        '-map -0:a:3',
        '-map -0:a:4',
        '-c copy'
    ]);

inputOptions puts the params at the wrong point for it to work. Not sure if the above is recommended but it worked for my simple use case, hope it helps.