Ask Your Question
0

VideoWriter with gstreamer pipeline which writes frames in I420 format

asked 2019-08-08 09:22:06 -0600

rarfua gravatar image

updated 2019-08-08 09:28:13 -0600

I have frames in YUV_I420 format, and want to write correct pipeline for VideoWriter which process it, and writes to file.

Frame shape in BGR format: width=1280, height=720.

YUV_I420 frame shape: width=1280, height=1080. - And this is the frame I want to write.

I have next versions of pipeline which does not work:

gstreamer_pipeline = (
"appsrc caps=video/x-raw,format=I420,width=1280,height=720,framerate=25/1 ! "
"videoconvert ! video/x-raw,format=I420 ! x264enc ! mp4mux ! filesink location=res.mp4")
writer = cv2.VideoWriter(gstreamer_pipeline, cv2.CAP_GSTREAMER, 25, (1280, 1080), True)
writer.write(frame_I420)

I experemented with different input shapes (width, height) in gstreamer_pipeline and in VideoWriter, and still no success.

Writing frames in BGR format works just well:

gstreamer_pipeline = (
"appsrc caps=video/x-raw,format=BGR,width=1280,height=720,framerate=25/1 ! "
"videoconvert ! video/x-raw,format=I420 ! x264enc ! mp4mux ! filesink location=res.mp4")
writer = cv2.VideoWriter(gstreamer_pipeline, cv2.CAP_GSTREAMER, 25, (1280, 720), True)
writer.write(frame_BGR)

But I really want to write frames in I420 format, and without previous conversion from from I420 to BGR.

What I miss? What modifications to pipeline would you suggest? Is format I420 supported as an input for appsrc in OpenCV? What are the alternatives?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-08-08 14:43:03 -0600

mshabunin gravatar image

Looks like currently only BGR, Gray and JPEG formats are supported: https://github.com/opencv/opencv/blob... But you can try to add another one.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-08-08 09:22:06 -0600

Seen: 3,906 times

Last updated: Aug 08 '19