Gstreamer : Sometime image is created with 0KB size

We are converting From Video stream(H264) to image using below gstreamer pipeline , but sometime image is generated with 0kb size.

gst_parse_launch (“v4l2src device=/dev/video9 num-buffers=1 ! video/x-h264, width=512, height=512, framerate=30/1, stream-format=byte-stream ! h264parse ! omxh264dec ! queue max-size-time=400000000 ! videoconvert ! avenc_png ! filesink location=/tmp/AlbumArt_Img1.png”, &error)

Why sometime it is generated with 0kb size ?

Any suggestion or solution will be really helpful

gst-omx (omxh264enc) has been retired and should no longer be used.

What happens if you use a different decoder?

Just one V4L2 buffer is not always enough to start decoding H.264. You may want to remove the queues, and perhaps use identity eos-after=1 instead, placing the identity right before avenc_png.

(if decoding all the time is not a problem, you can also use fakevideosink, and then use the last-sample mechanism with gst_video_convert_sample() to encode that sample to PNG)

We have tried as per the suggestion , But with this below pipeline stream is always running and image is generated with 0kb file size only.

gst-launch-1.0 -v --gst-debug=*:2 v4l2src device=/dev/video9 ! video/x-h264, width=512, height=512, framerate=30/1, stream-format=byte-stream ! h264parse ! omxh264dec ! videoconvert ! identity eos-after=1 avenc_png ! filesink location=/tmp/AlbumArt.png

logs :
root@dtdj-dj12:/# gst-launch-1.0 -v --gst-debug=*:2 v4l2src device=/dev/video9 ! video/x-h264, width=512, height=512, framerate=30/1, stream-format=byte-stream ! h264parse ! omxh264dec ! videoconvert ! identity eos-after=1 avenc_png ! filesink location=/tmp/AlbumArt.png
0:00:00.785370022 970 0xaaaafed292d0 WARN GST_REGISTRY gstregistry.c:1841:gst_update_registry: registry update failed: Error writing registry cache to /home/root/.cache/gstreamer-1.0/registry.aarch64.bin: No such file or directory
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive, parsed=(boolean)true
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:sink: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive, parsed=(boolean)true
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, profile=(string)constrained-baseline, level=(string)4.1
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:sink: caps = video/x-h264, width=(int)512, height=(int)512, framerate=(fraction)30/1, stream-format=(string)byte-stream, alignment=(string)au, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, profile=(string)constrained-baseline, level=(string)4.1
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:src: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)30/1
0:00:01.101528326 970 0xffffa0003590 WARN videodecoder gstvideodecoder.c:3802:gst_video_decoder_negotiate_pool: Subclass failed to decide allocation
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:src: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:src: caps = video/x-raw, format=(string)NV12, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, format=(string)NV12, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:src: caps = video/x-raw, format=(string)NV12, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:sink: caps = video/x-raw, format=(string)NV12, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)NV12, width=(int)512, height=(int)512, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1

Should the elements identity and avenc_png be linked with a !?

We have tried with this changes as well, But still it is generating empty image only.

Try with ... ! pngenc snapshot=true ! filesink location=out.png

If that doesn’t work, what does gst-launch-1.0 -v ... ! videoconvert ! fakesink silent=false num-buffers=2 output? (note the -v)

I have tried with below pipeline , now its generating proper image after every request to start the pipeline :

gst-launch-1.0 -v --gst-debug=*:2 v4l2src device=/dev/video9 ! h264parse ! omxh264dec ! videoconvert ! videorate ! video/x-raw,framerate=30/1 ! identity eos-after=1 ! avenc_png ! filesink location=/tmp/AlbumArt.png sync=true