Bogdan Wood
Bogdan Wood

Reputation: 61

Gstreamer. Multiple pcap to avi

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.

mergecap.exe -F pcap 01.pcap 02.pcap ....N.pcap -w out.pcap

After that I use gstreamer to make .avi file

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

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

...

    0:00:03.856698538 12812   08E3FD28 WARN         rtpjitterbuffer gstrtpjitterbuffer.c:2163:gst_rtp_jitter_buffer_chain:<rtpjitterbuffer0> 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:<rtpjitterbuffer0> 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:<rtpjitterbuffer0> 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:<rtpjitterbuffer0> Packet #41241 too late as #57525 was already popped, dropping

and continues...
and continues...
and continues...

...

I was trying :

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 ...

UPD. Tried to play with queues as otopolsky 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?)

Maybe there is another way to make audio and video synchronized from pcap's by the rtp TIMESTAMP's?

Upvotes: 1

Views: 1057

Answers (1)

nayana
nayana

Reputation: 3932

I think on 80% that the problem is that you do not put queue before processing of each tee branch.. when all the rtpjitterbuffers are in one thread they may lock each other. So my best guess is put queue right after pcapparse or maybe before it to be completly sure:

gst-launch-1.0 filesrc ! tee name=t 
  avimux name=mux ! filesink location=test.avi
  t. ! pcapparse ! x-rtp caps ! queue ! rtpjitterbuffer ! rtph264depay ! h264parse ! mux.
  t. ! pcapparse ! x-rtp caps ! queue ! rtpjitterbuffer ! rtppcmadepay ! mux.
  t. ! pcapparse ! x-rtp caps ! queue ! rtpjitterbuffer ! rtpwhateverelse .. ! mux.

You may play with the position of queue or put more queue. Just remember that queue is used not only for buffering purpose but mainly to separate the processing to different threads - its nicely written here - check the nice picture at the beginning depicting the threads.

HTH - I hope its the answer.. if not then update question or ask in comment.

Upvotes: 1

Related Questions