Reputation: 98
My aim to get video stream from capture card (Blackmagic decklink) to OpenCV and live stream to red5 or any other rtmp server.
So, I tried done with two branch at gstreamer with command is at below is working properly. But, when using with OpenCV just stream black frames to rtmp server, by the way opencv works well.
Gstreamer Command :
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
OpenCV code :
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);
My environment :
How can I deal with it?
Thanks in advance.
Upvotes: 0
Views: 2575
Reputation: 3932
The problem is that you left gst-launch-1.0 there which of course wouldnt work.
This is a proper way:
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);
Inspired by this question..
And be aware that there are problems using x264enc along with tee.. because sometimes the x264enc want to preroll lot of frames which may flood the other branch of tee..
Upvotes: 2