1
votes

I use ffmpeg to convert video using H264 for video encoding, and FAAC for audio encoding. The output should be .mp4 or m4v in order to play on both Android and iPhone. I want to add a subtitle STREAM to video file using ffmpeg, but the ffmpeg's documentation doesnt help much.

Can anyone help me with this?

2
use <subtitle file> -newsubtitle option in ffmpeg.. supported file formats: ffmpeg.org/general.html#SEC8Nalin Kanwar
Thanks Nalin, i have tried as your suggestion, It works only if my output file is ".mkv" file. FFmpeg seem not support text stream in mp4 and m4v containers.jAckOdE

2 Answers

4
votes

Is it possible for you to use mencoder instead of ffmpeg? If yes, I would suggest the following:

mencoder input.avi -sub subtitles.sub -ovc lavc -oac copy -o output.mp4

For ffmpeg you can also try out the following command, although I have no way to guarantee it is actually working:

ffmpeg -i inputfile.avi -i subtitlefile.srt outputfile.avi -newsubtitle
1
votes

I have this command works under windows7:

ffmpeg -i input.mkv -filter_complex [0:v][0:s]overlay[v] -map [v] -map 0:a -acodec libvo_aacenc -ac 2 -ar 48000 -ab 320k output.mp4

You can refer to http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20burn%20subtitles%20into%20the%20video#picturebasedsubtitles for official descriptions.