【问题标题】:OpenCV and Gstreamer streaming live videoOpenCV 和 Gstreamer 流式传输实时视频
【发布时间】:2016-11-01 12:47:32
【问题描述】:

我的目标是将视频流从采集卡 (Blackmagic decklink) 获取到 OpenCV,并将实时流传输到 red5 或任何其他 rtmp 服务器。

所以,我尝试在 gstreamer 的两个分支上完成,命令如下,工作正常。但是,当与 OpenCV 一起使用时,只需将黑帧流式传输到 rtmp 服务器,顺便说一下,opencv 运行良好。

Gstreamer 命令:

gst-launch-1.0 -v autovideosrc !三通名称=t t。 !视频转换! 视频缩放!队列 ! x264enc pass=pass1 线程=4 比特率=5000 调=零延迟!队列 ! flvmux 可流=真! rtmpsink location="rtmp://127.0.0.1/live/stb live=1" max-lateness=100 t。 ! 视频/x-raw,宽度=1280,高度=720!应用程序

OpenCV 代码:

String gstSentence = "gst-launch-1.0 -v autovideosrc ! tee name=t " +
                "t. ! videoconvert ! videoscale ! queue ! x264enc pass=pass1 threads=4 bitrate=5000 tune=zerolatency  " +
                "! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://127.0.0.1/live/stb live=1\" max-lateness=100 " +
                "t. ! video/x-raw,width=1280,height=720 ! appsink";

        System.out.println(gstSentence);
        videoCapture = new VideoCapture(gstSentence);

我的环境:

  • Ubuntu 16.04
  • OpenCV 3.1 - Java 包装器
  • Gstreamer 1.8.1

我该如何处理?

提前致谢。

【问题讨论】:

    标签: java opencv gstreamer live-streaming java-gstreamer


    【解决方案1】:

    问题是您将 gst-launch-1.0 留在了那里,这当然行不通。

    这是正确的方法:

    String gst = "autovideosrc ! tee name=t " + 
                 "t. ! videoconvert ! videoscale ! queue ! x264enc pass=pass1 threads=4 bitrate=5000 tune=zerolatency  " +
                 "! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://127.0.0.1/live/stb live=1\" max-lateness=100 " +
                 "t. ! video/x-raw,width=1280,height=720 ! appsink";
    
    videoCapture = new VideoCapture(gstSentence);
    

    灵感来自this question..

    请注意,将 x264enc 与 tee 一起使用会出现问题。因为有时 x264enc 想要预滚动很多帧,这可能会淹没 tee 的其他分支。..

    【讨论】:

    • OpenCV 运行良好,但 RTMP 流仍然是黑色的。我该如何处理?我应该更改 RTMP 和 x264enc 吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 2011-04-07
    相关资源
    最近更新 更多