I'm trying to use GStreamer on Mac (10.12.6) to stream a video encoded from OpenCV frames via UDP. For some reason this does not work and I'm not getting any error output from GStreamer or OpenCV. This is how I open the writer in OpenCV:
cv::VideoWriter writer(
"appsrc ! videoconvert ! x264enc byte-stream=true threads=4 ! mpegtsmux ! udpsink host=localhost port=9999",
cv::CAP_GSTREAMER,
0,
(double) 5,
cv::Size(320, 240),
true);
This writer opens and I can feed frames into it but I don't get any output when listening to the port. The same pipeline works when compiled from (c++) source using the GStreamer API or when being launched via
/gst-launch-1.0 videotestsrc ! x264enc byte-stream=true threads=4 ! mpegtsmux ! udpsink host=localhost port=9999
I don't think OpenCV or GStreamer itself is at fault because I am able to stream video to the autovideosink in OpenCV when opening the writer via
cv::VideoWriter writer(
"appsrc ! autovideosink",
cv::CAP_GSTREAMER,
0,
(double) 5,
cv::Size(320, 240),
true);
For reference - I installed GStreamer via Brew and built OpenCV myself using the following CMake Flags:
-DOPENCV_ENABLE_NONFREE=ON
-DWITH_OPENGL=ON
-DWITH_OPENVX=ON
-DWITH_OPENCL=ON
-DBUILD_PNG=ON
-DBUILD_TIFF=ON
-DOPENCV_EXTRA_MODULES_PATH=~/src/opencv_contrib/modules
-DWITH_1394=OFF
-DWITH_CUDA=OFF
-DWITH_GSTREAMER=ON.
I'm relatively new to GStreamer so I could be missing something obvious. Any idea what I could be doing wrong here or what would help to track down the issue?
Finally got it. Turning on GStreamer Debug Output via setting GST_DEBUG=2 yielded that x264enc was not found by OpenCV. I didn't notice that as it was found when compiling the pipeline via the GStreamer C++ API.
The reason for that was that while the GStreamer install packages on OSX installed the x264enc element, brew on mac didn't. Having compiled OpenCV myself - it used the brew install of GStreamer and not the framework.
Solved the problem by reinstalling the x264enc element for GStreamer via brew (brew install gst-plugins-ugly --with-x264).
Related
I'm trying to play audio (WAV) file using Gstreamer udpsrc element with no success. Playing audio from a file works just fine:
gst-launch-1.0 -v filesrc location=sp5.wav ! wavparse ! audioconvert ! volume volume=1 ! autoaudiosink
But when running this in one terminal:
gst-launch-1.0 -v udpsrc port=5200 ! wavparse ! audioconvert ! volume volume=1 ! autoaudiosink
and this in another:
$ gst-launch-1.0 -v filesrc location=sp5.wav ! udpsink host=localhost port=5200
can't get any audio out (and Wireshark shows packets are going across). Trying the last command from a different PC didn't make any difference.
Running Gstreamer version 1.14.4.
Am i missing something obvious?
Currently, i'm using OpenCV 4.2 C++ in order to encode and stream outputs from a Allied Vision Manta camera.
I already can grabe a frame, compress with MJPEG and the stream to other pipeline using OpenCV and GStreamer.
However, i need to try with H.264 (and later with H.265) but it's not working. The pipelines created are these in VideoWriter function are the follow:
1 - "appsrc ! queue ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5015";
2 - "appsrc ! autovideoconvert ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5015";
With the 1st pipe, i get:
[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1759) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module x264enc0 reported: Can not initialize x264 encoder.
[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1665) writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline
With the 2nd pipe, I get:
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/vmwgfx_drv_video.so
libva info: va_openDriver() returns -1
The others arguments of VideoWritter are:
cv::CAP_GSTREAMER, 0, 5, Size(1080, 720), true
The input pixel format is BGR, because i need to grab the frames with BayerRG8, and then convert to BGR to minimize the traffic.
The receiver is done with
udpsrc port=5015 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264,framerate=15/1 ! rtph264depay ! decodebin ! videoconvert ! appsink
One detail that i don't know if it's important or not, i'm doing this in the VirtualBox.
Hello I am trying to encode and decode a "live" video using the webcam of and windows pc. The gstreamer version that I am currently using is 1.15.1
For the encoding line I use:
gst-launch-1.0 ksvideosrc ! \
'video/x-raw, width=640, height=480, framerate=30/1' ! \
videoconvert ! \
x264enc pass=qual quantizer=20 tune=zerolatency ! \
rtph264pay ! \
filesink location=D:\\cam.ts
This make a file on the D drive, but when is try to decode it I get an error.
line used:
gst-launch-1.0 filesrc location=D:\\cam.ts ! \
rtph264depay ! \
avdec_h264 ! \
videoconvert ! \
autovideosink sync=false
This is the answer Gstreamer gives me
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3064): gst_base_src_loop ():
/GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming stopped, reason error (-5)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
I'm trying to use gscam (http://wiki.ros.org/gscam) compiled with the gstreamer 1.0 flag with a camera connected via ethernet to my laptop running Ubuntu16.04, ROS kinetic and gstreamer 1.0.
I'm able to properly start gstreamer and see the stram window using the command:
gst-launch-1.0 udpsrc caps="application/x-rtp,media=video,clock-rate=90000,encoding-name=H264, payload=96" port=5002 ! rtph264depay ! video/x-h264,framerate=24/1,width=640,height=480 ! queue ! avdec_h264 ! videoconvert ! autovideosink sync=FALSE
but following the gscam instuction, running the command:
export GSCAM_CONFIG="udpsrc caps="application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96" port=5002 ! rtph264depay ! video/x-h264,framerate=24/1,width=640,height=480 ! decodebin ! videoconvert"
and then:
rosrun gscam gscam
I get the error:
[FATAL] [1533651268.132080791]: no element "udpsrc"
[FATAL] [1533651268.132104353]: Failed to initialize gscam stream!
This happens both when installing gscam using:
sudo apt-get install ros-kinetic-gscam
and compiling it from source using catkin
Can anyone please help me?
Update:
A crucial missing information is that gscam was build from source with gstreamer-1.0 flags.
Thus, it is not the common application from the ROS ppa which uses gstreamer-0.10.
First the direct solution: It seems that you are missing some plugin packages.
udpsrc is part of gst-plugins-good-plugins-0.10, which you can install under Ubuntu 16.04 as follows (with necessary base plugins):
sudo apt-get install gstreamer0.10-plugins-base gstreamer0.10-plugins-base-apps gstreamer0.10-plugins-good
Second, some info about gstreamer: gscam does depend on gstreamer-0.10 and not gstreamer-1.0, which are completely disjunct versions.
You can check this out by typing
$ apt-cache depends ros-kinetic-gscam
...
libgstreamer0.10-0
...
You have to watch out when elaborating config strings with gstreamer-1.0 and then try to use these in gstreamer-0.10.
It might not always work, so try directly working with gstreamer-0.10.
I am currently getting the following error
WARNING: erroneous pipeline: no element "Qtdemux" when I run the following command
gst-launch-1.0 -v filesrc location=~/Desktop/Dog.mp4 ! Qtdemux ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000
I have tried making sure I have gstreamer-plugin-good and get the following response
gstreamer1.0-plugins-good is already the newest version (1.8.3-1ubuntu0.4).
However when I look at gst-inspect-1.0 Qtdemux I get the following response No such element or plugin 'Qtdemux'.
Any thoughts on what may be the problem I am facing?
It is qtdemux, with a samll q.