简体   繁体   English

WebRTC Stream 当图片复杂度增加时卡住

[英]WebRTC Stream Freezes When Picture Complexity Increases

I am developing an application that uses WebRTC to display a live video stream being captured from a V4L2 source.我正在开发一个应用程序,它使用 WebRTC 来显示从 V4L2 源捕获的实时视频 stream。 The stream originates from a Linux box that has a DVI-USB capture card, is encoded to H264 by ffmpeg and sent to RTP, received by a Janus WebRTC server which is accessed by the web interface. stream 源自带有 DVI-USB 采集卡的 Linux 盒子,由 ffmpeg 编码为 H264 并发送到 RTP,由 Janus WebRTC 服务器接收,通过 web 接口访问。

Here is my current ffmpeg command - pretty simple: ffmpeg -f v4l2 -i /dev/video0 -vf "transpose=1,scale=768:1024" -vcodec libx264 -profile:v baseline -pix_fmt yuv420p -f rtp rtp://10.116.80.86:8004这是我当前的 ffmpeg 命令 - 非常简单:ffmpeg -f v4l2 -i /dev/video0 -vf "transpose=1,scale=768:1024" -vcodec libx264 -profile:v baseline -pix_fmt yuv420p -f rtp rtp:/ /10.116.80.86:8004

I can't go into details, but the DVI source generates a portrait 768x1024 image that initially is a simple image where the only movement is a small clock near the center that increments every second.我不能 go 了解细节,但 DVI 源生成一个纵向 768x1024 图像,最初是一个简单的图像,其中唯一的运动是靠近中心的一个小时钟,每秒递增一次。 At this stage, everything appears to work great.在这个阶段,一切似乎都很好。 The image is high-quality and continuous/smooth in the browser.图像在浏览器中质量高且连续/流畅。

Once I interact with the DVI source, a more complex image is generated, with some text/lines in the upper half.一旦我与 DVI 源交互,就会生成一个更复杂的图像,上半部分有一些文本/线条。 Still not very complex - only 2 colors involved and some basic 1px line shapes, and only the little clock is moving.仍然不是很复杂——只涉及 2 个 colors 和一些基本的 1px 线条形状,只有小时钟在移动。 At this point, the video starts to freeze frequently, and only updates once in a while for a few seconds.此时视频开始频繁卡顿,偶尔更新一次,持续几秒。 Bandwidth should not be an issue here, and the bitrate appears to stay high.带宽在这里应该不是问题,比特率似乎保持高位。 However, many fewer frames are decoded.但是,解码的帧要少得多。

I have also tried scaling the video down to 480x640 from 768x1024 and with that change the issue does not occur.我还尝试将视频从 768x1024 缩小到 480x640,并且通过这种更改不会出现问题。 However, I really need the full resolution and, again, there should not be a bandwidth issue here.然而,我真的需要完整的分辨率,而且这里不应该有带宽问题。

I have also tried capturing the output of ffmpeg to a file rather than streaming to RTP and in the file everything is good.我还尝试将 ffmpeg 的 output 捕获到一个文件,而不是流式传输到 RTP,文件中的一切都很好。

Here is a screenshot of the WebRTC internals (in Edge) for this stream. You can clearly see when the video image changes from the simple clock to including more shapes & text (nothing is changed here other than the image from the DVI source):这是这个 stream 的 WebRTC 内部结构(在 Edge 中)的屏幕截图。您可以清楚地看到视频图像从简单时钟变为包含更多形状和文本的时间(除了来自 DVI 源的图像,这里没有任何变化):

WebRTC 内部图

In Firefox, the video just freezes whenever frames are not decoded.在 Firefox 中,只要帧未解码,视频就会冻结。 In Edge, the video goes black after a moment with no frames decoded.在 Edge 中,视频在没有帧解码的情况下会在片刻后变黑。

Any ideas as to what might be causing this?关于可能导致此问题的任何想法?

Answering my own question for future Googlers:为未来的 Google 员工回答我自己的问题:

I ended up figuring out that this was due to the WebRTC server (Janus) running on a Raspberry Pi.我最终发现这是由于运行在 Raspberry Pi 上的 WebRTC 服务器 (Janus) 造成的。 Apparently the Pi 3B+ was powerful enough to handle the packet flow when the bitrate was low (just the clock), but when the rate got higher it would choke.显然,Pi 3B+ 的功能足以在比特率较低(仅时钟)时处理数据包流,但当比特率变高时,它就会阻塞。

I re-hosted Janus on a more powerful server and all is working well.我在功能更强大的服务器上重新托管了 Janus,一切正常。

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

相关问题 从WebRTC输入流到HLS - Stream from WebRTC input to HLS ffmpeg stream 在尝试使用云 stream ubuntu linux 实例时经常冻结(它保持活动状态并工作不超过 30 分钟) - ffmpeg stream freezes so often (it stays alive and working for no more than 30mins) when trying to stream with a cloud ubuntu linux instance 使用 WebRTC/GetUserMedia 流作为 FFMPEG 的输入 - Use WebRTC/GetUserMedia stream as input for FFMPEG FFMPEG:RTSP stream 冻结,但 FFMPEG 继续记录 - FFMPEG: RTSP stream freezes but FFMPEG keeps recording 使用ffmpeg解码h264 mpegts udp stream时的模糊图片 - Blurry picture when decoding h264 mpegts udp stream with ffmpeg 使用 ffmpeg 在节点 js 服务器中处理 WebRTC RTC stream - Processing WebRTC RTC stream in node js server with ffmpeg 我可以用 WebRTC 从 URL 读取编码的 stream - Can I read an encoded stream from a URL with WebRTC 如何使用服务器上的ffmpeg从WebRTC流中获取音频和视频 - How to get the audio and video from a WebRTC stream using ffmpeg on server 将视频标签中的 Webrtc 轨道 stream 转换为 URL (RTSP/UDP/RTP/Http) - Convert Webrtc track stream to URL (RTSP/UDP/RTP/Http) in Video tag 可以将实时m3u8流与WebRTC源中的PIP覆盖相结合吗? - Possible to Combine Live m3u8 stream with PIP overlay from WebRTC source?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM