<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Media on Bastien Traverse</title>
    <link>https://bastientraverse.com/en/tags/media/</link>
    <description>Recent content in Media on Bastien Traverse</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 29 Oct 2021 00:00:00 +0200</lastBuildDate><atom:link href="https://bastientraverse.com/en/tags/media/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Parallel ffmpeg stream manipulation</title>
      <link>https://bastientraverse.com/en/posts/2021-10/parallel-ffmpeg/</link>
      <pubDate>Fri, 29 Oct 2021 00:00:00 +0200</pubDate>
      
      <guid>https://bastientraverse.com/en/posts/2021-10/parallel-ffmpeg/</guid>
      <description>&lt;p&gt;This post will illustrate how we can apply different operations (audio transcoding, subtitles selection, video, chapters and fonts passthrough) on multistream MKVs with ffmpeg, while optimizing for multicore systems.&lt;/p&gt;
&lt;p&gt;More precisely, here is what we are trying to achieve:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;transcode the Japanese audio track from a entire anime season, from a superfluously lossless Flac to the more efficient Opus format&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;shed the useless (to me) English audio track (also in Flac, and 5.1&amp;hellip;), as well as the unneeded &amp;ldquo;Signs-only&amp;rdquo; subtitle   tracks&lt;/li&gt;
&lt;li&gt;pass-through the video track&lt;/li&gt;
&lt;li&gt;retain all attachments (fonts, chapters&amp;hellip;)&lt;/li&gt;
&lt;li&gt;preserve file modification times&lt;/li&gt;
&lt;li&gt;replace the original files with the new ones&lt;/li&gt;
&lt;li&gt;do all this as fast and efficiently as possible 😎&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;When starting, I knew how to accomplish this in two steps using two different tools:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Identify and remove the unwanted streams with &lt;a href=&#34;https://mkvtoolnix.download/doc/mkvmerge.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;mkvmerge&lt;/a&gt;&lt;sup&gt;(&lt;a href=&#34;https://www.reddit.com/r/mkvtoolnix/comments/8qcgez/can_somebody_help_with_batch_remove_unwanted/e0jq70n/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;source&lt;/a&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mkvmerge -i *.mkv
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;File &lt;span class=&#34;s1&#34;&gt;&amp;#39;01.mkv&amp;#39;&lt;/span&gt;: container: Matroska
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 0: video &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;HEVC/H.265/MPEG-H&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 1: audio &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;Flac&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 2: audio &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;Flac&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 3: subtitles &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;SubStationAlpha&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 4: subtitles &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;SubStationAlpha&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 5: subtitles &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;HDMV PGS&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Track ID 6: subtitles &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;HDMV PGS&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Attachment ID 1: &lt;span class=&#34;nb&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;application/vnd.ms-opentype&amp;#39;&lt;/span&gt;, size &lt;span class=&#34;m&#34;&gt;30712&lt;/span&gt; bytes, file name &lt;span class=&#34;s1&#34;&gt;&amp;#39;font.ttf&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;...&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; f in *.mkv&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; mkvmerge -o &lt;span class=&#34;s2&#34;&gt;&amp;#34;remuxed/&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; --audio-tracks &lt;span class=&#34;s1&#34;&gt;&amp;#39;!eng&amp;#39;&lt;/span&gt; --subtitle-tracks &lt;span class=&#34;s1&#34;&gt;&amp;#39;!4,6&amp;#39;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;admonition tip&#34;&gt;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;
  Here I was able to use &lt;code&gt;!eng&lt;/code&gt; because the audio track was labeled as such, but we could achieve the same with numerical index (just as we are doing for subs).
&lt;/div&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;
&lt;p&gt;Use ffmpeg to transcode the remaining audio track to Opus, using a &lt;a href=&#34;https://kokomins.wordpress.com/2019/10/10/anime-encoding-guide-for-x265-and-why-to-never-use-flac/#recommended-settings&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;generous 192 kbps&lt;/a&gt; (96k per audio channel) bitrate and then do the cleanup:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; f in remuxed/*.mkv&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; ffmpeg -i &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; -map &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; -c copy -c:a libopus -b:a 192k &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; touch -r &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; mv &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;-map 0&lt;/code&gt; ports over all input streams, &lt;code&gt;-c copy&lt;/code&gt; keeps them intact, and &lt;code&gt;-c:a libopus -b:a 192k&lt;/code&gt; modulates this by transcoding all audio streams (in our case, the one we kept) to 192k Opus. Finally, &lt;code&gt;touch -r&lt;/code&gt; updates our file modtime to reflect the original one, and &lt;code&gt;mv&lt;/code&gt; overwrite the source with the modified file (&lt;strong&gt;warning&lt;/strong&gt;: make sure to always test on a copy first, &lt;strong&gt;otherwise data loss will incur!&lt;/strong&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;From there it was rather easy to merge it all in one fell for loop:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; f in *.mkv&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    mkvmerge -o &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; --audio-tracks &lt;span class=&#34;s1&#34;&gt;&amp;#39;!eng&amp;#39;&lt;/span&gt; --subtitle-tracks &lt;span class=&#34;s1&#34;&gt;&amp;#39;!4,6&amp;#39;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    ffmpeg -i &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; -map &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; -c copy -c:a libopus -b:a 192k &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp2_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    touch -r &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp2_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    mv &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp2_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    rm &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, now the next step was to get rid of the superfluous &lt;em&gt;mkvmerge&lt;/em&gt; and do it all with the Ever Almighty Multimedia Swiss-Army Knife®, ffmpeg. For that I had to dig quite a bit, but here is the result:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; f in *.mkv&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; ffmpeg -i &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; -map &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; -map -0:a:1 -map -0:s:1 -map -0:s:3 -c copy -c:a libopus -b:a 192k &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; touch -r &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; mv &lt;span class=&#34;s2&#34;&gt;&amp;#34;tmp_&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As before we first select all streams via &lt;code&gt;-map 0&lt;/code&gt;, then make use of &lt;a href=&#34;https://trac.ffmpeg.org/wiki/Map&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;negative mapping&lt;/a&gt; (notice the minus sign at the front of the subsequent &lt;code&gt;-map&lt;/code&gt; values) to get rid of the unwanted tracks (second audio track, second and fourth sub tracks&amp;hellip; Beware, this time we are using ffmpeg&amp;rsquo;s indexes/IDs which are relative to the category and 0-indexed). Then it is as before, we copy all remaining streams without changing them (&lt;code&gt;-c copy&lt;/code&gt;) except audio ones which are transcoded to Opus.&lt;/p&gt;
&lt;p&gt;Now this is all well and dandy, but this command runs sequentially, iterating over each file while queuing up the others, disregarding our multicore CPU architecture and thus slowing down the process. How can we run all this concurrently, dispatching a job to each CPU thread?&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.gnu.org/software/parallel/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;GNU Parallel&lt;/a&gt;&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; to the rescue!&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;parallel ffmpeg -i &lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; -map &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; -map -0:a:1 -map -0:s:1 -map -0:s:3 -c copy -c:a libopus -b:a 192k tmp_&lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;;&amp;#39;&lt;/span&gt; touch -r &lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; tmp_&lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;;&amp;#39;&lt;/span&gt; mv tmp_&lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; ::: *.mkv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;admonition info&#34;&gt;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;
  Of course, overall time will also depend on your storage read/write speeds&amp;hellip;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Et voilà&lt;/em&gt;, that&amp;rsquo;s how you &lt;em&gt;efficiently&lt;/em&gt; and &lt;em&gt;stylishly&lt;/em&gt; reduce a bloated 10.9GB series to a lean and mean 4.8GB one. Great success! 👍👏🤗&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;See &lt;a href=&#34;https://kokomins.wordpress.com/2019/10/10/anime-encoding-guide-for-x265-and-why-to-never-use-flac/#why-you-should-never-use-flac&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Why you should never use FLAC&lt;/a&gt; (for that use case that is)&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;See &lt;a href=&#34;https://unix.stackexchange.com/a/104798&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this Unix SE answer&lt;/a&gt; for why Parallel is superior to Xargs in this matter.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Anime recommendation: Showa Genroku Rakugo Shinju</title>
      <link>https://bastientraverse.com/en/posts/2021-04/rakugo/</link>
      <pubDate>Thu, 22 Apr 2021 00:00:00 +0200</pubDate>
      
      <guid>https://bastientraverse.com/en/posts/2021-04/rakugo/</guid>
      <description>&lt;figure class=&#34;center&#34;&gt;&lt;img src=&#34;https://m.media-amazon.com/images/M/MV5BY2NjMmMzNWYtMTc3My00YmJhLThhMTYtNTliNjBiZDMwZTZkXkEyXkFqcGc@._V1_FMjpg_UX1000_.jpg&#34;
    alt=&#34;Cover poster for Shouwa Genroku Rakugo Shinjuu&#34; width=&#34;400&#34; height=&#34;500&#34;&gt;&lt;figcaption&gt;
      &lt;p&gt;&lt;a href=&#34;https://myanimelist.net/anime/28735/Shouwa_Genroku_Rakugo_Shinjuu&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;MyAnimeList.net&lt;/a&gt; - &lt;a href=&#34;https://www.animenewsnetwork.com/encyclopedia/anime.php?id=16614&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;AnimeNewsNetwork&lt;/a&gt; - &lt;a href=&#34;https://www.imdb.com/title/tt5419278/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;IMDB&lt;/a&gt; - &lt;a href=&#34;https://en.wikipedia.org/wiki/Descending_Stories:_Showa_Genroku_Rakugo_Shinju#Anime&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
    &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This anime is an absolute masterpiece. The quality of the drawings, the ambiance, the story&amp;hellip; They are all so delicate, so &lt;em&gt;refined&lt;/em&gt;. It is one of those works which upgrades your perception of a whole genre.&lt;/p&gt;
&lt;p&gt;Promotional video (in Japanese):&lt;/p&gt;


    
    &lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; allowfullscreen=&#34;allowfullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube-nocookie.com/embed/WK5XlNWNfq4?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;
      &gt;&lt;/iframe&gt;
    &lt;/div&gt;

&lt;p&gt;The trailer certainly does not capture the depth of the ambiance this anime will suck you into. It has quite litterally &lt;em&gt;entranced&lt;/em&gt; me. Watching it made me feel more human. It made me laugh, it made me cry. It softened my heart.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 2022-10-08:&lt;/strong&gt; I&amp;rsquo;ve just finished re-watching the anime, this time mustering the courage to go all the way through the last two final episodes; and if, like me &amp;ndash; and apparently &lt;a href=&#34;https://dustspeckintheuniverse.home.blog/2017/03/26/rakugo-shinjuu-dissecting-the-final-reveal/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;quite a few others&lt;/a&gt; &amp;ndash; you are incredibly disturbed by the insinuation made about Konatsu&amp;rsquo;s first child&amp;rsquo;s father, I warmly suggest reading &lt;a href=&#34;http://www.anime-evo.net/2017/03/26/showa-genroku-rakugo-shinju-season-2-12/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this excellent review&lt;/a&gt; which offers a credible rebuttal.&lt;/p&gt;
&lt;p&gt;In any case and despite this one unexpected late speck, my opinion and all the reviews seem to concord: this anime really is a masterpiece 😊🙏&lt;/p&gt;
</description>
    </item>
    
    <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>
