Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default streams with ffmpeg

I have some m4v files that I am wanting to add subtitles to with ffmpeg. I know I need to map the streams to get them into the output file but how do I ensure that this subtitle stream will be a default stream? The subtitles are .srt and people seem to be saying that they are not compatible with mp4 containers, what do I need to convert the subtitles to first?

Also, does it matter what order the various streams are in? Does the video stream always have to come first, followed by the audio, then the subtitles? Or can you mix them up however you want? Does it make any difference?

Lastly, what is the difference between a default stream and a forced stream?

like image 310
Sam Avatar asked Oct 21 '22 04:10

Sam


1 Answers

1. I have some m4v files that I am wanting to add subtitles to with ffmpeg.

m4v is the Apple knock off version of the non-platform specific MP4 standard. I don't know that much about this Apple format, but like most older container formats, I suspect it probably only supports audio/video or has poor or limited support for subtitles.

2. The subtitles are .srt and people seem to be saying that they are not compatible with mp4 containers, what do I need to convert the subtitles to first?

You can convert subtitles using a tool like AegisSub or Gaupol. However, my recommendation is to use MKVMerge tool that will produce an MKV file container, a container format that was designed to support a vast array of different streams, including subtitles (almost every type), fonts, and attachments. MKVmerge will also allow you to specify default streams.

3. Also, does it matter what order the various streams are in? Does the video stream always have to come first, followed by the audio, then the subtitles? Or can you mix them up however you want? Does it make any difference?

No. The type of each stream (video/audio/subtitle/other) is specified in the header. Players figure out which is which.

4. Lastly, what is the difference between a default stream and a forced stream?

Default stream is the one your player will default to if you haven't set your language preference code (ENG, JAP, SPA, ITA, etc.) in your player. Forced stream will force that stream regardless of the setting you specified in your player.

like image 110
BlushNine Avatar answered Oct 24 '22 10:10

BlushNine