Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoWriter with gstreamer pipeline which writes frames in I420 format

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?

VideoWriter with gstreamer pipeline which writes frames in I420 format

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?