title: Is there an elegant way to split a file by chapter using ffmpeg?
body: <p>In <a href="http://blog.albertarmea.com/post/91024308173/losslessly-splitting-videos-by-chapter-using-bash" rel="noreferrer">this page</a>, Albert Armea share a code to split videos by chapter using <code>ffmpeg</code>. The code is straight forward, but not quite good-looking.</p>
  <pre><code>ffmpeg -i &quot;$SOURCE.$EXT&quot; 2&gt;&amp;1 |
  grep Chapter |
  sed -E &quot;s/ *Chapter #([0-9]+\.[0-9]+): start ([0-9]+\.[0-9]+), end ([0-9]+\.[0-9]+)/-i \&quot;$SOURCE.$EXT\&quot; -vcodec copy -acodec copy -ss \2 -to \3 \&quot;$SOURCE-\1.$EXT\&quot;/&quot; |
  xargs -n 11 ffmpeg
  </code></pre>
  <p>Is there an elegant way to do this job?</p>