title: Gstreamer. Multiple pcap to avi
body: <p>I have multiple .pcap files 01.pcap, 02.pcap,...N.pcap,  they includes two streams, Audio-G.711 Video-H.264. Every pcap has ~1 min of streaming And I need to make one .avi.
  I use mergecap.exe to concatenate pcaps to one big pcap.</p>
  
  <pre><code>mergecap.exe -F pcap 01.pcap 02.pcap ....N.pcap -w out.pcap
  </code></pre>
  
  <p>After that I use gstreamer to make .avi file</p>
  
  <pre><code>gst-launch-1.0 filesrc location=out.pcap ! tee name=t ! pcapparse dst-ip=192.168.2.55 dst-port=5010 ^
          ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96 ^
          ! rtpjitterbuffer ^
          ! rtph264depay ^
          ! h264parse ^
          ! queue^
          ! mux. t. ! pcapparse dst-ip=192.168.2.55 dst-port=4010 ^
          ! application/x-rtp, media=(string)audio, clock-rate=(int)8000, encoding-name=(string)PCMA, channels=(int)1, payload=(int)8 ^
          ! rtpjitterbuffer ^
          ! rtppcmadepay ^
          ! queue ^
          ! mux. avimux name=mux ! filesink location=test.avi
  </code></pre>
  
  <p>This pipeline works for one pcap well.. When I conatenate two .pcaps, it's works too. But if it is more than 2 pacaps-> rtpjitterbuffer drops almost every video packet</p>
  
  <p>...</p>
  
  <pre><code>    0:00:03.856698538 12812   08E3FD28 WARN         rtpjitterbuffer gstrtpjitterbuffer.c:2163:gst_rtp_jitter_buffer_chain:&lt;rtpjitterbuffer0&gt; Packet #41238 too late as #57525 was already popped, dropping
      0:00:03.861442222 12812   08E3FD28 WARN         rtpjitterbuffer gstrtpjitterbuffer.c:2163:gst_rtp_jitter_buffer_chain:&lt;rtpjitterbuffer0&gt; Packet #41239 too late as #57525 was already popped, dropping
      0:00:03.870865810 12812   08E3FD28 WARN         rtpjitterbuffer gstrtpjitterbuffer.c:2163:gst_rtp_jitter_buffer_chain:&lt;rtpjitterbuffer0&gt; Packet #41240 too late as #57525 was already popped, dropping
      0:00:03.876392403 12812   08E3FD28 WARN         rtpjitterbuffer gstrtpjitterbuffer.c:2163:gst_rtp_jitter_buffer_chain:&lt;rtpjitterbuffer0&gt; Packet #41241 too late as #57525 was already popped, dropping
  
  and continues...
  and continues...
  and continues...
  </code></pre>
  
  <p>...</p>
  
  <p>I was trying : </p>
  
  <ul>
  <li>Change latency in rtpjitterbuffer</li>
  <li>Remove rtpjitterbuffer</li>
  <li>Don't use tee</li>
  </ul>
  
  <p>Your suggestions why this is happening?
  I remind you that everything works up to two pcap's. No matter what pcaps 1 with 2 or 5 with 6 or ...</p>
  
  <p>UPD. Tried to play with queues as <strong>otopolsky</strong> described but still did not works. I put queue after tee element. But the same error. I think that's because rtpjitterbuffer in two different threads uses in the same variable (from main thread?)</p>
  
  <p>Maybe there is another way to make audio and video synchronized from pcap's by the rtp TIMESTAMP's?</p>