You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Jetson Orin Nano上GStreamer硬件解码FFmpeg推送的RTSP流失败问题及适配方案咨询

Jetson Orin Nano上GStreamer硬件解码FFmpeg推送的RTSP流失败问题及适配方案咨询

嗨,我来帮你捋一捋这个问题的来龙去脉,以及对应的解决思路!

首先咱们明确问题核心:你用FFmpeg推送的RTSP流,在Jetson Orin Nano上用GStreamer的nvv4l2decoder硬件解码时,出现了「Stream format not found, dropping the frame」的错误;但换成test-launch推送的high profile H.264流,就能正常解码。后来你尝试强制指定GStreamer pipeline的caps为high profile,虽然没报错,但解码器压根没工作——这其实是caps不匹配导致的。

问题根源分析

从你提供的调试信息能看到:

  • FFmpeg推的流是constrained-baseline profile、level 3.1
  • 正常工作的流是high profile、level 3

Jetson的nvv4l2decoder硬件解码器对H.264的profile兼容性有一定限制:constrained-baseline是baseline的子集,但部分硬件解码器对这种约束型profile的支持不够完善,而标准的baseline或high profile兼容性会好很多。另外,你用FFmpeg指定-profile:v baseline后,libx264默认会开启constrained baseline特性,这就导致输出的流是约束型的。

解决方案

我给你两个方向的方案,你可以根据需求选择:

方案一:修改FFmpeg推流参数,输出兼容的profile

这是最直接的解决方式,让FFmpeg输出标准的baseline或high profile,适配硬件解码器:

  1. 输出标准baseline profile(关闭constrained特性):
ffmpeg -loglevel warning -re -stream_loop -1 -i path/to/file.mp4 -c:v libx264 -preset superfast -tune zerolatency -pix_fmt yuv420p -b:v 600k -max_muxing_queue_size 1024 -profile:v baseline -x264-params constrained_intra=0 -an -filter:v scale=1280:-1 -f rtsp rtsp://<IP>:8554/test

这里加了-x264-params constrained_intra=0,用来关闭约束型帧内预测,让输出变成标准baseline。

  1. 直接输出high profile(和你正常工作的流一致):
ffmpeg -loglevel warning -re -stream_loop -1 -i path/to/file.mp4 -c:v libx264 -preset superfast -tune zerolatency -pix_fmt yuv420p -b:v 600k -max_muxing_queue_size 1024 -profile:v high -level:v 3 -an -filter:v scale=1280:-1 -f rtsp rtsp://<IP>:8554/test

方案二:调整GStreamer pipeline,适配constrained-baseline流

如果你没法修改FFmpeg的推流参数,可以调整GStreamer的pipeline,让解码器正确识别constrained-baseline的流:

  1. 匹配实际流的caps:
gst-launch-1.0 rtspsrc location=rtsp://<IP>:8554/test drop-on-latency=true ! rtph264depay ! h264parse ! video/x-h264,profile=constrained-baseline,level=3.1 ! queue ! nvv4l2decoder enable-max-performance=1 ! queue ! nvvidconv ! 'video/x-raw, format=(string)RGBA' ! fakesink

这里把caps指定为实际流的constrained-baselinelevel 3.1,确保解码器能匹配上。

  1. 给解码器添加宽松错误检查:
    如果上面的方法还是不行,可以尝试关闭解码器的严格错误检查,让它兼容更多格式:
gst-launch-1.0 rtspsrc location=rtsp://<IP>:8554/test drop-on-latency=true ! rtph264depay ! h264parse ! queue ! nvv4l2decoder enable-max-performance=1 disable-error-check=true ! queue ! nvvidconv ! 'video/x-raw, format=(string)RGBA' ! fakesink

为什么之前强制high profile没用?

你之前把caps改成high后,虽然没报错,但实际流是constrained-baseline,caps不匹配导致GStreamer无法正确将流传给nvv4l2decoder,解码器自然不会工作——相当于pipeline里的解码器环节被跳过了,所以你看不到错误,但也没用到硬件解码。

备注:内容来源于stack exchange,提问作者luis castro

火山引擎 最新活动