bluenviron / gortsplib

RTSP 1.0 client and server library for the Go programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert MJPEG RTP Packets to JPEG Image

Tekunalogy opened this issue · comments

Hello!
I was looking through the examples, and I wanted to develop something that would read incoming rtp packets and save them as JPEG images.

I did some preliminary work here: https://github.com/Tekunalogy/rtpmjpeg2jpeg

However, as you can see in the repository, the resulting jpeg image is nowhere close to the gstreamer "videotestsrc".

I did try using the server and "record-format-mjpeg" examples:

and I got a strange issue:

...
2024/03/07 18:08:30 33 RTP packets lost
2024/03/07 18:08:30 11 RTP packets lost
2024/03/07 18:08:30 20 RTP packets lost
2024/03/07 18:08:30 27 RTP packets lost
2024/03/07 18:08:30 5 RTP packets lost
2024/03/07 18:08:30 24 RTP packets lost
2024/03/07 18:08:30 22 RTP packets lost
2024/03/07 18:08:30 20 RTP packets lost
2024/03/07 18:08:30 8 RTP packets lost
2024/03/07 18:08:31 8 RTP packets lost
2024/03/07 18:08:31 2 RTP packets lost
2024/03/07 18:08:31 15 RTP packets lost
2024/03/07 18:08:31 43 RTP packets lost
...

So I have a feeling that this is part of the issue. Adding queue/queue2 to the gstreamer command did not resolve the issue either.

Could someone point me in the right direction, or maybe some other examples to look at? I know in the Pion webrtc library, they have an h264 writer module, which takes the data and makes it into a writable format if I recall correctly, so am I going to need something similar to that for the mjpeg specification?

gstreamer command:

gst-launch-1.0 videotestsrc ! video/x-raw,width=1920,height=1080,format=I420 ! jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=9000