title: How to extract h264 and aac elementary stream from an mp4 / mkv using gstreamer
body: <p>I could not find a stable and balanced approach to demux the A/V stream and then save it as a playable h264 annex B format video.</p>
  
  <p>Well, I tried the following steps for <a href="http://www.auby.no/files/video_tests/" rel="nofollow">shrinkage</a> file. </p>
  
  <blockquote>
    <p>gst-launch-0.10  filesrc
    location=h264_720p_mp_3.1_3mbps_aac_shrinkage.mkv  !   matroskademux !
    filesink location=abc.h264</p>
  </blockquote>
  
  <p>-rw-rw-r-- 1 XXX XXX 28697147 Nov  1 10:04 h264_720p_mp_3.1_3mbps_aac_shrinkage.mkv<br>
  -rw-rw-r-- 1 XXX XXX 27581733 Nov  1 10:19 abc.h264</p>
  
  <p>a file got saved with "not so smaller" size but is not playable, however the parent container format is playable with the following pipeline</p>
  
  <blockquote>
    <p>gst-launch-0.10  filesrc
    location=h264_720p_mp_3.1_3mbps_aac_shrinkage.mkv  !   matroskademux !
    h264parse ! ffdec_h264 ! ffmpegcolorspace ! ximagesink</p>
  </blockquote>
  
  <p><strong>Questions</strong><br>
  Q1. What are the methods to extract the video ES and Audio ES from different containers using gstreamer ?  </p>
  
  <p>Q2.  Q1 using some other methods which always works and/or are easy ?</p>