<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 16 nov. 2022, 14 h 15, Dave Blanchard via gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Fixed this problem by adding 'jpegparse' before jpegdec/avdec_mjpeg. Working great now at 30 fps with no errors. Also, very little stream latency compared to my previous ffmpeg setup; it's now essentially realtime video. Now if gstreamer will work continuously over weeks or months without the occasional random crash like ffmpeg, I'll be very happy!<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Great idea. The parser will protect the decoder from possibly corrupted frames coming from the camera too, so that may help with stability.</div><div dir="auto"><br></div><div dir="auto">Congrat,</div><div dir="auto">Nicolas</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thank you!<br>
<br>
Begin forwarded message:<br>
<br>
Date: Wed, 16 Nov 2022 11:40:39 -0600<br>
From: Dave Blanchard via gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">gstreamer-devel@lists.freedesktop.org</a>><br>
To: <a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">gstreamer-devel@lists.freedesktop.org</a><br>
Cc: Dave Blanchard <<a href="mailto:dave@killthe.net" target="_blank" rel="noreferrer">dave@killthe.net</a>><br>
Subject: Invalid PTS from v4l2 mjpeg source<br>
<br>
<br>
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.<br>
<br>
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:<br>
<br>
ffmpeg -r 30 -video_size 704x480 -i /dev/video1 -c:v mpeg2video -b:v 8M -f mpegts <a href="http://localhost:5000/publish/camera1" rel="noreferrer noreferrer" target="_blank">http://localhost:5000/publish/camera1</a><br>
<br>
With gstreamer I'm using this command:<br>
<br>
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<br>
<br>
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:<br>
<br>
[...]<br>
<br>
[mpeg2video @ 0x259b740] Invalid pts (108003372) <= last (108003372)<br>
[mpeg2video @ 0x259b740] Invalid pts (108003374) <= last (108003374)<br>
[mpeg2video @ 0x259b740] Invalid pts (108003376) <= last (108003376)<br>
[mpeg2video @ 0x259b740] Invalid pts (108003378) <= last (108003378)<br>
<br>
[...]<br>
<br>
Seems DTS=PTS, which is wrong.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Thank you!<br>
<br>
-- <br>
Dave Blanchard <<a href="mailto:dave@killthe.net" target="_blank" rel="noreferrer">dave@killthe.net</a>><br>
-- <br>
Dave Blanchard <<a href="mailto:dave@killthe.net" target="_blank" rel="noreferrer">dave@killthe.net</a>><br>
</blockquote></div></div></div>