Use avconv to add subtitles
avconv is a very handy program so far i have posted a few recipes for converting audio and video with it, this post is for subtitles.
there are 2 types of subtitle really hard and soft. With hard subtitles they are hard encoded into the video stream which means they are present all the time, this may be needed by mobile players which do not support soft subtitles. with soft subtitles the presentation and size is decided by the player but it does give the user the option of multiple languages. With a player such as vlc having an srt file with the same name as the movie is enough to have subtitles. For itunes it is necessary to encode the subtitles within the mp4 file.
so here are a few recipes.
avconv -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4
-codec copy -c:s mov_text
using the libass library if it is compiled into your avconv
avconv -i subtitles.srt subtitles.ass
to convert and
avconv -i mymovie.mp4 -vf ass=subtitles.ass mysubtitledmovie.mp4
Mp4 and Mkv files use slightly different recipes
avconv -i input.mp4 -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s mov_text output.mp4
avconv -i input.mp4 -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt output.mkv
Adding a second subtitle stream
First add another input: -i input2.srt. Second, map that as 2nd stream: -map 2:0. Finally, select encoder for 2nd subtitle stream (the same as the first one): -c:s srt.
avconv -i input.mp4 -f srt -i input.srt -i input2.srt -map 0:0 -map 0:1 -map 1:0 -map 2:0 -c:v copy -c:a copy -c:s srt -c:s srt output.mkv
avconv supports the mov_text subtitle encoder which is about the only one supported in an MP4 container and playable by iTunes, Quicktime, iOS etc.
Your line would read:
avconv -i input.mp4 -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:s mov_text output.mp4