I am currently trying to convert a live feed from a Raspberry Pi camera to H264 and store it as a mp4 video using gstreamer. Since I am using a Raspberry Pi 1, I need to use the hardware accelerated video encoding as otherwise the encoder cannot keep up.
I tried the following pipeline, which I feed manually with RGB image data:
appsrc name=src format=time is-live=true caps=video/x-raw,format=(string)RGB,width=640,height=480,bpp=24,depth=24,framerate=20/1 ! autovideoconvert ! queue ! omxh264enc ! mp4mux ! filesink location=output.mp4
However, it fails with the following output:
0:00:01.193743067 2469 0x1f5b320 WARN autoconvert gstautoconvert.c:1048:gst_auto_convert_sink_query:<autoconvertchild> Got query allocation while no element was selected, letting through
0:00:01.205271623 2469 0x1f5b2c0 WARN omxvideoenc gstomxvideoenc.c:2944:gst_omx_video_enc_propose_allocation:<omxh264enc-omxh264enc0> allocation query does not contain caps
0:00:02.109098855 2469 0x1f5b320 WARN v4l2bufferpool gstv4l2bufferpool.c:1189:gst_v4l2_buffer_pool_dqbuf:<v4l2convert0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:02.172643411 2469 0xa2703200 WARN GST_PADS gstpad.c:4226:gst_pad_peer_query:<omxh264enc-omxh264enc0:src> could not send sticky events
0:00:02.193615605 2469 0xa2703200 WARN omxvideoenc gstomxvideoenc.c:1602:gst_omx_video_enc_loop:<omxh264enc-omxh264enc0> error: Internal data stream error.
0:00:02.197108471 2469 0xa2703200 WARN omxvideoenc gstomxvideoenc.c:1602:gst_omx_video_enc_loop:<omxh264enc-omxh264enc0> error: stream stopped, reason not-negotiated
0:00:02.329828367 2469 0x1f7eaa0 WARN bufferpool gstbufferpool.c:1394:gst_buffer_pool_set_flushing:<v4l2convert0:pool:sink> can't change flushing state of inactive pool
0:00:02.333992206 2469 0x1f7eaa0 WARN bufferpool gstbufferpool.c:1394:gst_buffer_pool_set_flushing:<v4l2convert0:pool:sink> can't change flushing state of inactive pool
Curiously, if I replace omxh264enc
with the
non-accelerated version x264enc
, it works
(although it falls behind after a couple of frames).
I assume that the warnings right before Internal data
stream error
might give some indication to what is
actually going wrong, but I cannot make much sense out of them.
The full code can be found here: https://pastebin.com/pgr940yu, as well as the full debug output of that code here: https://pastebin.com/CLwAfxMG.
Thanks a lot in advance!
Best, Homan