I am trying to add text subtitles to an .mp4 container using ffmpeg:
ffmpeg -i input.mp4 -i input.srt -map 0.0 -map 0.1 -map 1.0 output.mp4
When I am trying to run this line, it gives me an error :
Nmber of stream maps must match number of output streams.
If I try to change the mp4 to mkv (although mp4 supports text subtitles), like this:
ffmpeg -i input.mp4 -i input.srt -map 0.0 -map 0.1 -map 1.0 output.mkv
It correctly maps the streams, but gives an error :
Encoder (codec id 94210) not found for output stream #0.2
When I launch
ffmpeg -codecs
I can see that srt codec is supported as decoder and encoder, however I am not sure what is used for mp4 and mkv subs encoding, and whether I need to switch it on or compile separately.
ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4
-vf subtitles=infile.srt
will not work with -c copy
The order of -c copy -c:s mov_text
is important. You are telling FFmpeg:
If you reverse them, you are telling FFmpeg:
Alternatively you could just use -c:v copy -c:a copy -c:s mov_text
in any
order.