简体   繁体   English

通过RTSP传输H264时视频帧损坏

[英]Corrupted video frames when streaming H264 over RTSP

When I stream H264 video over RTSP and use VLC to view the video feed, the video feed is corrupted (partly green but moving objects are still detected). 当我通过RTSP流式传输H264视频并使用VLC查看视频源时,视频源已损坏(部分为绿色,但仍检测到移动的对象)。 However, if I stop the VLC and restart it again, the video feed is no longer corrupted. 但是,如果我停止VLC并再次重新启动它,则视频供稿将不再损坏。 Why is it so, and how can I remedy this issue? 为什么会这样,我该如何解决? Thanks! 谢谢!

The H264 is coming natively from a USB camera into a Raspberry Pi. H264是从USB摄像头本地移植到Raspberry Pi中的。 Below is the code within the crontab of the Pi for launching the g-streamer and RTSP server. 以下是Pi的crontab中的代码,用于启动g-streamer和RTSP服务器。

@reboot bash /home/pi/gst-rtsp-server/examples/test-launch '( v4l2src device=/dev/video1 ! video/x-h264, width=320, height=240, framerate=20/1 ! h264parse ! rtph264pay name=pay0 pt=98 config-interval=10 )'

The Raspberry Pi is connected over a network. Raspberry Pi通过网络连接。 I am using VLC on another computer to view the video feed. 我在另一台计算机上使用VLC来查看视频提要。

vlc rtsp://10.146.0.57:8554/test

If I reboot the Pi, the video feed on the VLC will be corrupted. 如果我重新启动Pi,则VLC上的视频供稿将损坏。 I can still see moving objects in the video feed but there will be green and purple pixels all over. 我仍然可以在视频Feed中看到移动的对象,但是到处都是绿色和紫色像素。

However, if I close the VLC and start VLC again, the issue is gone. 但是,如果我关闭VLC并再次启动VLC,问题就消失了。 The video feed is clean. 视频供稿是干净的。

The output of VLC: [0000557c34211570] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. Created new TCP socket 35 for connection libEGL warning: DRI2: failed to authenticate libEGL warning: DRI2: failed to authenticate [00007fd9b800df20] main decoder error: buffer deadlock prevented VLC的输出: [0000557c34211570] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. Created new TCP socket 35 for connection libEGL warning: DRI2: failed to authenticate libEGL warning: DRI2: failed to authenticate [00007fd9b800df20] main decoder error: buffer deadlock prevented [0000557c34211570] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. Created new TCP socket 35 for connection libEGL warning: DRI2: failed to authenticate libEGL warning: DRI2: failed to authenticate [00007fd9b800df20] main decoder error: buffer deadlock prevented

Please elaborate - you restart the Pi but keep the VLC connection running? 请详细说明-您重新启动Pi,但保持VLC连接运行吗? Doesn't it disconnect because the RTSP server goes away? 它不是因为RTSP服务器消失了而断开连接吗? VLC should reconnect after the Pi restarts. Pi重新启动后,VLC 应该重新连接。 If it does not do this this may be a problem. 如果不这样做,则可能是一个问题。

If a new H.264 bitstream is initiated by the Pi it is logically different from what it previously has send. 如果Pi启动了新的H.264比特流,则从逻辑上讲它与以前发送的比特流有所不同。 If the VLC does not restart but just continues decoding this stream it may get "confused" resulting in decoding error (relying on wrong reference pictures). 如果VLC没有重启,而只是继续解码该流,则可能会“混淆”,从而导致解码错误(依赖于错误的参考图片)。

H.264 has a temporal dependency for frames. H.264对帧具有时间依赖性。 MJPEG does not have this - each frame can be decoded by it self. MJPEG没有此功能-每个帧都可以自行解码。 Therefore you will not see the issue to be present here. 因此,您不会在此处看到该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM