Hi there,
I’m trying to convert H264 encoding from command line to H264 encoding using opencv.
My command line encoding is:
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! 'video/x-raw, width=(int)720, height=(int)576, framerate=(fraction)25/1, format=(string)UYVY' ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420' ! queue ! omxh264enc control-rate=4 bitrate=1000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! mpegtsmux ! rtpmp2tpay mtu=1400 ! udpsink port=5000 async=false sync=false host=172.23.32.45
Now, this pipeline works well but I want to work with opencv since i’m working with the frame before I send it.
In opencv I receive the frame using:
cap.open("v4l2src device=/dev/video0 ! video/x-raw, width=720, height=576, framerate=25/1, format=(string)UYVY ! videoconvert ! video/x-raw, format=(string)BGR ! appsink");
cap >> img;
I have to use “format=(string)UYVY” or “format=(string)YV12” because it’s the only way I can receive an image from my frame grabber (AverMedia C351)
Then, I send the picture using:
Writer.open("appsrc ! videoconvert ! video/x-raw, format=UYVY ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! queue ! omxh264enc control-rate=4 bitrate=1000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! mpegtsmux ! rtpmp2tpay mtu=1400 ! udpsink host=172.23.32.45 port=5000 async=false sync=false -vvv", 0, FPSDemand, cv::Size(720,576), true);
.
.
.
Writer.write(img);
With this pipeline every once in a while in the decoder side the picture got stuck for a few seconds and after that it returns, with the command line pipeline it’s works well, what is the difference?
The decoder side is the same for both methods and I get the same issues with VLC encoding and with gstreamer using:
gst-launch-1.0 udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T-ES" ! rtpbin ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink sync=false async=false -e
Can really use your help for understanding the difference.
Thanks ,Gal.