openCV VideoCapture doesn't work with gstreame

2019-07-04 05:56发布

问题:

I'd like to display a rtp / vp8 video stream that comes from gstreamer, in openCV.

I have already a working solution which is implemented like this :

gst-launch-0.10 udpsrc port=6666 ! "application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)VP8-DRAFT-IETF-01,payload=(int)120" ! rtpvp8depay ! vp8dec ! ffmpegcolorspace ! ffenc_mpeg4 ! filesink location=videoStream

Basically it grabs incoming data from a UDP socket, depacketize rtp, decode vp8, pass to ffmpegcolorspace (I still don't understand what this is for, I see it everywhere in gstreamer).

The videoStream is a pipe I created with mkfifo. On the side, I have my openCV code that does :

VideoCapture cap("videoStream");

and uses cap.read() to push into a Mat.

My main concern is that I use ffenc_mpeg4 here and I believe this alters my video quality. I tried using x264enc in place of ffenc_mpeg4 but I have no output : openCV doesn't react, neither does gstreamer, and after a couple of seconds, gst-launch just stops.

Any idea what I could use instead of ffenc_mpeg4 ? I looked for "lossless codec" on the net, but it seems I am confusing things such as codec, contains, format, compression and encoding ; so any help would be (greatly) appreciated !

Thanks in advance !