<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Archive on Bastien Traverse</title>
    <link>https://bastientraverse.com/en/tags/archive/</link>
    <description>Recent content in Archive on Bastien Traverse</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 01 May 2015 00:00:00 +0200</lastBuildDate><atom:link href="https://bastientraverse.com/en/tags/archive/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>ffmpeg set sub as default</title>
      <link>https://bastientraverse.com/en/posts/2015-05/ffmpeg-default-sub/</link>
      <pubDate>Fri, 01 May 2015 00:00:00 +0200</pubDate>
      
      <guid>https://bastientraverse.com/en/posts/2015-05/ffmpeg-default-sub/</guid>
      <description>&lt;p&gt;Copy of my &lt;a href=&#34;https://superuser.com/q/700082/393261&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;answer&lt;/a&gt; to the question &amp;ldquo;&lt;a href=&#34;https://superuser.com/questions/700082/is-there-an-option-in-ffmpeg-to-specify-a-subtitle-track-that-should-be-shown-by&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Is there an option in ffmpeg to specify a subtitle track that should be shown by default?&lt;/a&gt;&amp;rdquo; on superuser:&lt;/p&gt;
&lt;blockquote&gt;
&lt;h2 id=&#34;no-there-isnt-an-option-in-ffmpeg-to-specify-a-subtitle-track-that-should-be-shown-by-default&#34;&gt;&lt;a href=&#34;#no-there-isnt-an-option-in-ffmpeg-to-specify-a-subtitle-track-that-should-be-shown-by-default&#34; class=&#34;headerlink anchor&#34;&gt;&lt;i class=&#34;iconfont icon-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;No, there isn&amp;rsquo;t an option in ffmpeg to specify a subtitle track that should be shown by default.&lt;/h2&gt;&lt;p&gt;(ffmpeg version 2.6.1 built with gcc 4.9.2 (GCC) 20150304 (prerelease) as default on Arch, see end of answer for compile flags)&lt;/p&gt;
&lt;p&gt;Resources highlighting the lack of command line options for setting default/forced subtitles stream in ffmpeg include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://ffmpeg.org/pipermail/ffmpeg-user/2012-October/010769.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this Oct. 2012 mailing list thread&lt;/a&gt; (which delves in the matroska format and explains that ffmpeg doesn&amp;rsquo;t write in the required fields)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ffmpeg.org/pipermail/ffmpeg-user/2013-January/012997.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this Jan. 2013 thread&lt;/a&gt; (shows the lack of interest of ffmpeg devs for this)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ffmpeg.org/pipermail/ffmpeg-user/2014-January/019641.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this Jan. 2014 thread&lt;/a&gt; (asks about flipping the default flag in Matroska container, to no avail)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2254&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this very recent forum post&lt;/a&gt; (MP4, zeranoe ffmeg forums)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, &lt;a href=&#34;https://stackoverflow.com/questions/26956762/ffmpeg-set-subtitles-track-as-default&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this question&lt;/a&gt; on StackOverflow asks the same as you but for mkv, and highlights the fact that ffmpeg is the culprit since &lt;a href=&#34;https://www.bunkus.org/videotools/mkvtoolnix/doc/mkvpropedit.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;mkvpropedit&lt;/a&gt; (part of &lt;em&gt;mkvtoolnix&lt;/em&gt;) can do it.&lt;/p&gt;
&lt;h3 id=&#34;however-there-is-a-potential-workaround&#34;&gt;&lt;a href=&#34;#however-there-is-a-potential-workaround&#34; class=&#34;headerlink anchor&#34;&gt;&lt;i class=&#34;iconfont icon-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;However, there is a potential workaround&lt;/h3&gt;&lt;p&gt;&lt;a href=&#34;https://trac.ffmpeg.org/ticket/2402&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;This March 2013 ffmpeg bug report&lt;/a&gt;  (still open) deals with mkv and default flag for subtitles and explains something that we can use to circumvent this limitation in some scenarios:&lt;/p&gt;
&lt;p&gt;The Matroska specification - ​http://matroska.org/technical/specs/index.html (search for FlagDefault) - specifies that the value for the default flag is &amp;ldquo;default&amp;rdquo; if nothing is specified, the demuxer therefore marks all subtitle tracks as &amp;ldquo;default&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;So ffmpeg &lt;em&gt;may&lt;/em&gt; write the default flag on our subtitles stream in some cases; I tried it with different input video files and got mixed results:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;with the &lt;a href=&#34;https://peach.blender.org/download/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Big Buck Bunny&lt;/a&gt; AVI Mpeg4  and a random .srt file, the remuxed mkv subtitles stream &lt;strong&gt;did&lt;/strong&gt; have the default flag:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  $ ffmpeg -i big_buck_bunny_480p_surround-fix.avi -i subtitle.srt -c copy test.mkv
  $ ffmpeg -i test.mkv
  Input #0, matroska,webm, from &#39;test.mkv&#39;:
    Metadata:
      ENCODER         : Lavf56.25.101
    Duration: 00:28:31.40, start: 0.000000, bitrate: 1028 kb/s
      Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 24 fps, 24 tbr, 1k tbn, 24 tbc (default)
      Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
      Stream #0:2: Subtitle: subrip (default)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;however I couldn&amp;rsquo;t reproduce this with a &lt;a href=&#34;http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;sample mp4-contained H264 sample&lt;/a&gt; neither with a personal mp4, so I guess &lt;code&gt;mp4 --&amp;gt; mkv&lt;/code&gt; doesn&amp;rsquo;t work. But what if&amp;hellip;?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  $ ffmpeg -i sample.mp4 -c copy sample.avi
  $ ffmpeg -i sample.avi -i subtitle.srt -c copy sample.mkv
  $ ffmpeg -i sample.mkv
  ...
Input #0, matroska,webm, from &#39;sample.mkv&#39;:
  Metadata:
	ENCODER         : Lavf56.25.101
  Duration: 00:28:31.40, start: 0.000000, bitrate: 2 kb/s
	Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(tv, bt709), 560x320, SAR 1:1 DAR 7:4, 60 fps, 60 tbr, 1k tbn, 60 tbc (default)
	Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp (default)
	Stream #0:2: Subtitle: subrip (default)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;VICTORY!&lt;/strong&gt; Doing &lt;code&gt;mp4 --&amp;gt; avi&lt;/code&gt; and then &lt;code&gt;avi + srt --&amp;gt; mkv&lt;/code&gt; gets the subtitles stream on by default and VLC displays them correctly.&lt;/p&gt;
&lt;p&gt;Sure that&amp;rsquo;s very roundabout and I&amp;rsquo;d rather not think of the information loss in the process, but at least it works.&lt;/p&gt;
&lt;h3 id=&#34;summary&#34;&gt;&lt;a href=&#34;#summary&#34; class=&#34;headerlink anchor&#34;&gt;&lt;i class=&#34;iconfont icon-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;Summary&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;ffmpeg is definitely not adapted right now for setting streams as default or forced,&lt;/li&gt;
&lt;li&gt;mkv is probably better than mp4 as an origin container, since it has a known tool doing the job fine (&lt;a href=&#34;https://www.bunkus.org/videotools/mkvtoolnix/doc/mkvpropedit.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;mkvpropedit&lt;/a&gt; from &lt;em&gt;mkvtoolnix&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;ffmpeg-version-details&#34;&gt;&lt;a href=&#34;#ffmpeg-version-details&#34; class=&#34;headerlink anchor&#34;&gt;&lt;i class=&#34;iconfont icon-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;ffmpeg version details:&lt;/h4&gt;&lt;p&gt;&lt;code&gt;ffmpeg version 2.6.1 built with gcc 4.9.2 (GCC) 20150304 (prerelease) configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</description>
    </item>
    
  </channel>
</rss>
