title: gstreamer: Demux & Remux MKV, preserving video
body: <p>I am trying to reencode the audio part of a  MKV file that contains some <code>video/x-h264</code> and some <code>audio/x-raw</code>.  I can't manage to just demux the MKV and remux it.  Even simply:</p>
  
  <pre><code>gst-launch-1.0 filesrc location=test.mkv ! matroskademux name=demux \
      matroskamux name=mux ! filesink location=test2.mkv \
      demux.video_00 ! mux.video_00 \
      demux.audio_00 ! mux.audio_00
  </code></pre>
  
  <p>fails miserably with:</p>
  
  <pre><code>Setting pipeline to PAUSED ...
  Pipeline is PREROLLING ...
  WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Delayed linking failed.
  Additional debug info:
  ../gstreamer/gst/parse/grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
  failed delayed linking pad  video_00 of GstMatroskaDemux named demux to pad  video_00 of GstMatroskaMux named mux
  WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Delayed linking failed.
  Additional debug info:
  ../gstreamer/gst/parse/grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
  failed delayed linking pad  audio_00 of GstMatroskaDemux named demux to pad  audio_00 of GstMatroskaMux named mux
  ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Internal data stream error.
  Additional debug info:
  ../gst-plugins-good/gst/matroska/matroska-demux.c(5715): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
  streaming stopped, reason not-linked (-1)
  ERROR: pipeline doesn't want to preroll.
  Setting pipeline to NULL ...
  Freeing pipeline ...
  </code></pre>
  
  <p>My best attempt at the transcoding mentioned above goes:</p>
  
  <pre><code>gst-launch-1.0 -v filesrc location=test.mkv ! matroskademux name=demux \
     matroskamux name=mux ! filesink location=test2.mkv \
     demux.video_00 ! queue ! 'video/x-h264' ! h264parse ! mux. \
     demux.audio_00 ! queue ! rawaudioparse ! audioconvert ! audioresample ! avenc_aac ! mux.   
  </code></pre>
  
  <p>with the same result.  Removing the pad name <code>audio_00</code> leads to <code>gst</code> being stuck at <code>PREROLLING</code>.</p>
  
  <p>I have seen a few people facing similar problems:</p>
  
  <ul>
  <li><a href="http://gstreamer-devel.966125.n4.nabble.com/Putting-h264-file-inside-a-container-td4668158.html" rel="nofollow noreferrer">http://gstreamer-devel.966125.n4.nabble.com/Putting-h264-file-inside-a-container-td4668158.html</a></li>
  <li><a href="http://gstreamer-devel.966125.n4.nabble.com/Changing-the-container-format-td3576914.html" rel="nofollow noreferrer">http://gstreamer-devel.966125.n4.nabble.com/Changing-the-container-format-td3576914.html</a></li>
  </ul>
  
  <p>As therein, keeping only video or only audio works.</p>