This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM67A:具有 CVBS-USB 适配器的 TI J722S 上的 GStreamer 流水线冻结/Segfault

Guru**** 2826855 points

Other Parts Discussed in Thread: AM67

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1627659/am67a-gstreamer-pipeline-freeze-segfault-on-ti-j722s-with-cvbs-usb-adapter

器件型号: AM67A
主题: AM67 中讨论的其他器件

TI 硬件: J722S (TDA4-class) EVM/定制电路板
SDK 版本: Processor SDK Linux (Edge AI)—[11_00_00]
输入设备: 模拟摄像机-> Fushicai USBTV007 CVBS 转 USB Grabber
视频规格: 720x480、YuYV 4:2:2、隔行 (interlace-mode=interleaved)


问题说明:

我遇到了 J722S 平台上的 GStreamer 流水线严重稳定性问题。 当使用 USBTV007 CVBS 转 USB 适配器时、流水线要么在到达PLAYING状态时立即冻结、要么在停止前运行几秒钟/分钟。

此设置之前适用于不同的摄像头源、但当前的模拟至 USB 链(提供隔行 YUYV)会导致系统挂起。 同一适配器在标准 x86 PC 上运行良好。

观察到的主要症状:

  1. 管道挂起: v4l2src ! kmssinkPLAYING但不会渲染帧。
  2. SIGSEGV: 添加基于 CPU 的deinterlace元素会导致即时分段故障。
  3. 丢弃缓冲区: 有时、日志会在冻结前显示“已丢弃的缓冲区“或“缓冲池不足“。
  4. 间距模式: gst-launch-1.0 -v报告。 interlace-mode=(string)interleaved
  5. 热性能: SoC 温度稳定 < 60°C

执行的调试信息和测试:

  • v4l2-ctl 测试: v4l2-ctl --device=/dev/video4 --stream-mmap --stream-count=100工作正常、显示稳定的~25 FPS。
  • CMA 存储器: CmaFree大约为 159 MB(总共 917 MB)、因此似乎不是总内存耗尽问题。
  • 管道失败:
    • v4l2src ! videoconvert ! kmssink-> 冻结
    • v4l2src ! identity drop-allocation=true ! videoconvert ! kmssink-> 冻结
    • v4l2src ! deinterlace ! videoconvert ! kmssink-> SIGSEGV
  • I/O 模式: io-mode已测试 0(读取)、1 (mmap) 和 2 (userptr)、但未成功。

GStreamer 大写日志:

/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, format=(string)YUY2, width=(int)720, height=(int)480, framerate=(fraction)30000/1001, interlace-mode=(string)interleaved

问题:

  1. J722S USB 控制器是否存在已知问题、以处理来自提供隔行 YUYV 的 UVC 器件的等时传输?
  2. deinterlacev4l2src在该平台上与缓冲器一起使用时、为什么该元素会导致 SIGSEGV? 这是 DMA-BUF/对齐冲突吗?
  3. 在不停止缓冲池的情况下、将 USB-UVC 源的“隔行 YV“桥接到 TIOVX 框架(NV12 渐进)的建议方法是什么?
python3 app_edgeai.py
/usr/lib/python3.12/site-packages/onnxruntime/capi/_pybind_state.py:28:语法警告:无效的转义序列'\S'
“(%SystemRoot%\System32 除外)、“
libtidl_onnxrt_ep 已加载的 0x26cab7a0
最终创建的子图数为:1、-已卸载节点 — 283,总节点 — 283
应用程序:init ...!!
117.084040 s:内存:初始化...!!
117.084304 s:MEM:初始化的 DMA 堆 (FD=5)!!!
117.084613 s:内存:初始化...完成!!!
117.084657 s:ipc: init ...!!
117.140712 s:ipc:初始化...完成!!!
remote_service:初始化...!!</s>!
remote_service:初始化...完成!!!
117.154480 s:GTC 频率= 200MHz
应用程序:初始化...完成!!
117.165844 s:vx_zone_info
:全局启用 vx_zone_error 117.165901 s:vx_zone_info
:全局启用 vx_zone_warning 117.165919
s



:vx_zone_info:全局启用 vx_zone_info 117.167515 s:vx_zone_zone_info
117.168205 s:vx_zone_info:全局禁用 vx_zone_info
========= 【输入流水线】==========

[pipe-0]

v4l2src device=/dev/video-usb-cam0 brightd=448 对比度=464 饱和度=512 标准=45056 像素纵横比=None! capsfilter caps=“video/x-raw, width=(int)720, height=(int)480;“! tiovxdlcolorconvert! capsfilter caps=“video/x-raw、format=(string)NV12;“! tiovxmultiscaler name=split_01 split_01
。 ! 排队! capsfilter caps=“video/x-raw、width=(int) 640、height=(int) 360;“! tiovxdlcolorconvert out-pool-size=4! capsfilter caps=“video/x-raw、format=(字符串)rgb;“! appsink max-buffers=2 DROP=True name=sen_0
split_01。 ! 排队! capsfilter caps=“video/x-raw、width=(int)416、height=(int)416;“! tiovxdlpreproc out-pool-size=4 data-type=3 tensor-format=1! capsfilter caps=“application/x-tensor-tiovx;"!“!</s>! appsink max-buffers=2 DROP=True name=pre_0 ==========


【输出流水线】==========

appsrc do-timestamp=True format=3 block=True name=post_0! tiovxdlcolorconvert! capsfilter caps=“video/x-raw、format=(字符串)NV12、width=(int) 640、height=(int) 360;“! 排队! mosica_0.sink_0

tiovxmosaic target=1 background=/tmp/background_0 name=mosica_0 src
::pool-size=4 sink_0::startx=“<320>" sink_0“ sink_0::starty=“<150>" sink_0“ sink_0::width=“<640>" sink_0“ sink_0:::::Highs=“<360>"
!“! capsfilter caps=“video/x-raw、format=(字符串)NV12、width=(int) 1920、height=(int) 1080;“! 排队! tiperfoverlay title=对象检测! kmssink sync=False max-lathity=5000000 QoS=True Processing-depende=15000000 driver-name=tidss connector-id=41 plane-id=32 force-modesetting=True FD=38

应用程序:Deinit ...!!
REMOTE_SERVICE:取消初始化...!!!
REMOTE_SERVICE:取消初始化...完成!!!
320.708436 s:IPC: Deinit ...!!
320.709650 s:IPC:DeInit ... Done!!
320.709717 s:内存:Deinit ...!!
320.709739 s:DDR_SHARED_MEM:Alloc's
:68 alloc's of 73183952 Bytes 320.709753 s:DDR_SHARED_MEM:FREE's
:68 FREE's of 73183952 Bytes 320.709763 s:DDR_SHARED_MEM:open's:0 bytes 320.709783 s:
Mem! Deinit!
应用程序:Deinit ...完成!!
 
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Alex、

    当您从 CAP 滤波器禁用隔行扫描模式=交错时、流水线是否起作用?  

    另外、 如果 interlaced-mode=interleaved 是必需的、则添加 ! identity single-segment=true !  deinterlace “之前“以帮助处理时间戳。  

    请提供以下命令的输出以更好地支持您。

    v4l2-ctl -d /dev/video4

    medial-ctl -p -d /dev/media0

    您提供的馈送还支持隔行交错?

    此致

    Suren

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Suren、

    感谢您的指导。 以下是基于您最后一个问题的更新详细信息:

    1.关于 media-ctl

    我尝试运行media-ctl -p -d /dev/media0、但系统报告缺少命令或找不到设备节点。 因为我使用的是 USB-UVC 设备 (USBTV007) 而不是 CSI-2 摄像头、/dev/media0可能无法在我的当前 DTB 中为该接口进行初始化或映射。

    2、跨平台稳定性问题

    如前所述、完全相同的命令在 PC 上运行良好、但在上运行良好 J722S 、它在流式传输几秒钟后冻结:

    # This freezes after ~45-80 seconds on J722S
    gst-launch-1.0 v4l2src device=/dev/video2 ! \
        "video/x-raw, format=(string)YUY2, width=720, height=480, framerate=30000/1001" ! \
        videoconvert ! autovideosink sync=false
    

    发生冻结时、终端中没有错误消息;该帧仅停止更新。 SoC 温度保持在 60°C 以下。

    3.设备详细信息 () v4l2-ctl -d /dev/video2 --all

    检测到适配器为/dev/video2。 以下是配置:

    Driver Info:
        Driver name      : usbtv
        Card type        : usbtv
        Bus info         : usb-xhci-hcd.8.auto-1.1
        Driver version   : 6.12.33
        Capabilities     : 0x85200001
            Video Capture
            Read/Write
            Streaming
            Extended Pix Format
            Device Capabilities
        Device Caps      : 0x05200001
            Video Capture
            Read/Write
            Streaming
            Extended Pix Format
    

    4.失败尝试的总结:

    • interlace-mode从盖子上取下: 仍然冻结。
    • 使用identity single-segment=true仍然冻结或 SIGSEGV(如果存在)deinterlace
    • 更改io-mode (0、1、2): 没有改进。

    它显示了 USBTV007 驱动程序(使用等时传输)可能会丢弃数据包或无法将缓冲区与 J722S 存储器控制器/显示子系统同步...

    此致、Alex

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    为了将 USB 驱动程序与 Gstreamer/TIOVX 内存管理隔离,我使用ffmpeg作为捕获前端实施了混合流水线,将原始数据gst-launch-1.0通过管道传输到 viafdsrc

    工作命令: 以下命令成功运行了 13 分钟以上、但没有系统崩溃、这是以前无法使用的v4l2src

    ffmpeg -f v4l2 -video_size 720x480 -i /dev/video2 -f rawvideo -pix_fmt yuyv422 - | \
    gst-launch-1.0 fdsrc fd=0 ! \
    videoparse width=720 height=480 format=yuy2 ! \
    videoconvert ! \
    kmssink driver-name=tidss sync=false
    

    重要观察结果:

    1. 稳定性: 使用 Linux 管道将 V4L2 捕获与 GStreamer 流水线解耦解决了内核级挂起问题。
    2. 数据完整性: 当日志显示Dequeued v4l2 buffer contains corrupted data时、ffmpeg会平稳地处理这些数据、从而防止整个流水线停止。
    3. 吞吐量: 在 720x480 @ 30fps(大约 165Mbps)时、管道的 CPU 开销videoparse在 J722S A67 内核上是可管理的。

    结语: 对于在 AM67 上使用高带宽原始 USB 摄像头时遇到“冻结“的用户、使用ffmpeg作为强大的缓冲器/源似乎是保持系统稳定性的可行权变措施。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢 Alex 分享这些观察结果。

    让我与我的团队一起回顾您的观察结果。

    此致

    Suren