Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

Disable default subtitle track with ffmpeg

I'm creating an MKV container with 4 different files:

  • video.mp4
  • audio_en.mp4
  • audio_es.mp4
  • subtitles.ass

For that I'm using the following ffmpeg script:

ffmpeg -i video.mp4 -i audio_es.mp4 -i audio_en.mp4 -i subtitles.ass 
-map 0:v -map 1:a -map 2:a -map 3:s 
-metadata:s:a:0 language=spa 
-metadata:s:a:1 language=eng 
-metadata:s:s:0 language=spa -disposition:s:0 -default 
-default -c:v copy -c:a copy -c:a copy -c:s copy result.mkv

The result.mkv looks awesome, everything works as expected except for one thing: subtitles are still set as the default track, so players like VLC shows them automatically. I've already tried plenty of different ways to avoid that to happen with the disposition flag but I cannot make it work.

How should I modify the script so that the MKV does not have the subtitles track marked as default?

Thanks in advance!

question from:https://stackoverflow.com/questions/65672037/disable-default-subtitle-track-with-ffmpeg

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For Matroska (.mkv) output use the -default_mode option:

ffmpeg -i video.mp4 -i audio_es.mp4 -i audio_en.mp4 -i subtitles.ass 
-map 0:v -map 1:a -map 2:a -map 3:s 
-metadata:s:a:0 language=spa 
-metadata:s:a:1 language=eng 
-metadata:s:s:0 language=spa 
-default_mode infer_no_subs 
-c copy result.mkv

This option requires FFmpeg 4.3 or later, or use a build from the current git master branch.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...