4

I created a mp4 file from video, audio and .srt file.

ffmpeg -i video.mp4 -i audio.m4a -i sub.srt -map 0:0 -metadata:s:v:0:0 language=eng -map 1:0 -metadata:s:a:0:0 language=eng -map 2:0 -metadata:s:s:0:0 language=eng -c copy -scodec mov_text out.mp4

It works fine, but subtitle is not shown by default. Is there way to show the subtitle by default?

ironsand
  • 5,205

2 Answers2

3

You can use MP4Box 0.6.2-DEV-rev453 (May 2016) or higher to do this:

mp4box -add xr.mp4 -add xr.en.srt:txtflags=0xC0000000 -new ya.mp4

This will mark the subtitle stream in the output file as forced. However, this mark will only be recognized starting with VLC 3.0.0-20161101 (Nov 2016).


I have seen mentions to this post on the FFmpeg mailing list about a patch that implements disposition for FFmpeg:

ffmpeg -i xr.mp4 -i xr.en.srt -c copy -c:s mov_text -disposition:s forced ya.mp4

However after having tried it with both "forced" and "default", the subtitles marked by FFmpeg are not recognized as forced by VLC.


To respond to the comment, here is a test with MP4Box 0.7.0 (Apr 2017) and VLC 3.0.0-20170926 (Sep 2017). Note more recent VLC versions are having a crashing problem, even on videos without subtitles. Using this file:

youtube-dl --write-auto-sub --format 18 --output xr.mp4 kcs82HnguGc
ffmpeg -i xr.en.vtt xr.en.srt
mp4box -add xr.mp4 -add xr.en.srt:txtflags=0xC0000000 -new ya.mp4

Result:

sub

Zombo
  • 1
  • 5
  • 44
  • 63
  • @Pygmalion no it is germane - if you are reading carefully you notice I said you cannot use past VLC 3.0.0-20170926 otherwise it will crash - you ignored this and did it anyway - to your own chagrin - I have now reported you for repeatedly ignoring my full answer – Zombo Oct 11 '17 at 18:45
  • There is nothing wrong with your asnwer, I never claimed that, so I don't know what is there to report about? The problem is that existing solutions for forced subtitles are not robust and not useful for general public. – Pygmalion Oct 11 '17 at 19:21
  • To explain "robust": Imagine you want to see some video. The instruction is: You cannot see it online. And you cannot see it downloaded either, unless you use one special program, and, wait, you may not use the official version of this program, but only special version, but wait you can use only versions newer than this date and older than this date... average response would be - to hell with this video. I am prepared to do anything that my video will have user-friendly forced subscripts, which is in this moment obviously not possible. In a few years I will try again... – Pygmalion Oct 11 '17 at 19:34
  • @Pygmalion good comment - the current situation is not good - best to wait for nightly versions to graduate to release – Zombo Oct 11 '17 at 21:03
  • The ffmpeg disposition flag works perfectly on version 3.4.2! :) – varun Jan 01 '20 at 10:33
0

im not sure if this is considered a workaround, it needs vlc + ffmpeg adjustment. in vlc, it is possible to set "eng" as a default parameter for subs, and here https://stackoverflow.com/questions/17928192/set-a-subtitle-language-using-ffmpeg "-metadata:s:s:0 language=eng" in ffmpeg - it is possible to set metadata for a sub stream as "eng" tried this on vlc 3.0.9.2, the vlc chose to play the eng sub

hope this helps

(this above was part solution, of my looking for solution to "Unsupported codec with id 94213" problem. I re-copied the video/audio/sub streams into a new video/audio only stream using "-sn", then re-add the relevant sub streams)