Invalid PTS from v4l2 mjpeg source

Dave Blanchard dave at killthe.net
Wed Nov 16 17:40:39 UTC 2022


Hi all, I'm trying to use gstreamer to capture video from a MJPEG surveillance card. There's one last snag to get through to get this working right.

With ffmpeg I use the following command to stream the video to an HLS endpoint, which then plays perfectly at 30 fps with no trouble:

ffmpeg -r 30 -video_size 704x480 -i /dev/video1 -c:v mpeg2video -b:v 8M -f mpegts http://localhost:5000/publish/camera1

With gstreamer I'm using this command:

gst-launch-1.0 v4l2src device=/dev/video1 ! "image/jpeg,width=704,height=480,framerate=30/1" ! jpegdec [or avdec_mjpeg] ! videoconvert ! avenc_mpeg2video bitrate=8192 threads=0 ! mpegtsmux ! srtsink uri=srt://:5000 latency=0

I'm able to play the resulting video, but it seems about half of the frames are being dropped, and I'm getting a steady stream of PTS errors on the console for every other frame:

[...]

[mpeg2video @ 0x259b740] Invalid pts (108003372) <= last (108003372)
[mpeg2video @ 0x259b740] Invalid pts (108003374) <= last (108003374)
[mpeg2video @ 0x259b740] Invalid pts (108003376) <= last (108003376)
[mpeg2video @ 0x259b740] Invalid pts (108003378) <= last (108003378)

[...]

Seems DTS=PTS, which is wrong.

Weirdly, every once in a while these errors will stop, and the video will play perfectly for a moment at 30 fps, until the errors begin again and it's back to 15 real fps.

Can anyone give me a clue how to fix this? Ideally on the command line without any coding, although I can do that as a last resort. I've searched and searched and can't figure this out.

Thank you!

-- 
Dave Blanchard <dave at killthe.net>


More information about the gstreamer-devel mailing list