AM62A7: Wave5 Encoder not closing properly in SDK 11.01

Part Number: AM62A7

Hi,

I am using an AM62A7 with TI Processor SDK 11.01 and have encountered an issue with the Wave5 hardware encoder for both H.264 and H.265 encoding.

Issue

Whenever v4l2h264enc or v4l2h265enc is used, the GStreamer EOS event does not propagate beyond the hardware encoder.

As a result, when stopping a recording pipeline, qtmux / mp4mux does not receive EOS and cannot finalize the MP4 file. The resulting MP4 file is therefore unplayable.

H.265 reproduction

The following pipeline reproduces the issue:

GST_DEBUG=3 gst-launch-1.0 -e \
videotestsrc ! \
video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! \
v4l2h265enc ! \
h265parse ! \
qtmux ! \
filesink location=test-hw.mp4

The pipeline starts and encodes normally.When I press Ctrl+C, I get:

Handling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...

The pipeline remains indefinitely at:

Waiting for EOS...

A second Ctrl+C is required to terminate gst-launch-1.0.

The generated MP4 is not playable because the EOS/finalization sequence does not complete.

H.265 test without qtmux

I also removed qtmux completely to determine whether the problem was related to MP4 muxing. The same behavior occurs. 
Therefore, the issue occurs even without qtmux. This suggests that the EOS/drain operation is getting stuck at or below v4l2h265enc.

 
 

H.264

I observe the same behavior with the H.264 hardware encoder.

  • Hi Sathiya,

    How is the behavior when you don't specify the -e option?

    Also instead of specifying the -e option in the pipeline, providing num-buffers in videotestsrc is recommended. This will ensure a clean shutdown by sending an EOS when num-buffers is reached.

    Example pipeline:

    gst-launch-1.0 videotestsrc num-buffers=90 ! \
    video/x-raw,width=1920,height=1080,framerate=30/1,format=NV12 ! \
    v4l2h264enc ! \
    h264parse ! \
    qtmux ! \
    filesink location=test.mp4
    Hope this helps
    Best Regards
    Suren
  • Hi Suren,

    Without -e option, the stream is ending but the mp4 file is not playable.

    Here is the pipeline:

    root@am62axx-evm:~# GST_DEBUG=3 gst-launch-1.0 videotestsrc ! video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! v4l2h264enc ! h264parse ! qtmux ! filesink location=test-qtmux-h264.mp4
    Setting pipeline to PAUSED ...
    0:00:00.110647495   754      0x2347d90 WARN                    v4l2 gstv4l2object.c:4867:gst_v4l2_object_probe_caps:<v4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
    0:00:00.112102525   754 0xffff94000b70 WARN              aggregator gstaggregator.c:2159:gst_aggregator_query_latency_unlocked:<qtmux0> Latency query failed
    Pipeline is PREROLLING ...
    0:00:00.113236800   754 0xffff94000d00 FIXME                default gstutils.c:4036:gst_pad_create_stream_id_internal:<videotestsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
    0:00:00.116853610   754 0xffff94000d00 WARN                    v4l2 gstv4l2object.c:3408:gst_v4l2_object_reset_compose_region:<v4l2h264enc0:src> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
    Redistribute latency...
    0:00:00.117669570   754 0xffff94000d00 WARN                    v4l2 gstv4l2object.c:3408:gst_v4l2_object_reset_compose_region:<v4l2h264enc0:sink> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
    0:00:00.152777365   754 0xffff94000d00 WARN          v4l2bufferpool gstv4l2bufferpool.c:850:gst_v4l2_buffer_pool_start:<v4l2h264enc0:pool0:src> Uncertain or not enough buffers, enabling copy threshold
    0:00:00.174852670   754 0xffff94000e90 WARN               h264parse gsth264parse.c:2219:gst_h264_parse_update_src_caps:<h264parse0> VUI framerate 30.0 exceeds allowed maximum 0.2
    Redistribute latency...
    0:00:00.176165090   754 0xffff94000b70 FIXME               basesink gstbasesink.c:3399:gst_base_sink_default_event:<filesink0> stream-start event without group-id. Consider implementing group-id handling in the upstream elements
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    0:00:00.177271125   754 0xffff94000b70 FIXME             aggregator gstaggregator.c:1448:gst_aggrRedistribute latency...
    egator_aggregate_func:<qtmux0> Subclass should call gst_aggregator_selected_samples() from its aggregate implementation.
    New clock: GstSystemClock
    ^Chandling interrupt.
    Interrupt: Stopping pipeline ...
    Execution ended after 0:00:20.717739645
    Setting pipeline to NULL ...
    0:00:20.894882970   754 0xffff94000b70 WARN                   qtmux gstqtmux.c:1921:gst_qt_mux_send_buffer:<qtmux0> Failed to send buffer (0xffff880136e0) size 68554
    0:00:20.897362905   754      0x2347d90 WARN              bufferpool gstbufferpool.c:1423:gst_buffer_pool_set_flushing:<v4l2h264enc0:pool0:sink> can't change flushing state of inactive pool
    0:00:20.907078610   754      0x2347d90 WARN              bufferpool gstbufferpool.c:1423:gst_buffer_pool_set_flushing:<v4l2h264enc0:pool0:sink> can't change flushing state of inactive pool
    Freeing pipeline ...
    root@am62axx-evm:~#

    I tried playing the video in ubuntu. Here is the ffplay log.

    snarayanan@SLS:~$ ffplay test-qtmux-h264.mp4 
    ffplay version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2003-2021 the FFmpeg developers
      built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
      configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
      libavutil      56. 70.100 / 56. 70.100
      libavcodec     58.134.100 / 58.134.100
      libavformat    58. 76.100 / 58. 76.100
      libavdevice    58. 13.100 / 58. 13.100
      libavfilter     7.110.100 /  7.110.100
      libswscale      5.  9.100 /  5.  9.100
      libswresample   3.  9.100 /  3.  9.100
      libpostproc    55.  9.100 / 55.  9.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7a8654000cc0] moov atom not found
    test-qtmux-h264.mp4: Invalid data found when processing input
        nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0   
    snarayanan@SLS:~$


    MP4 Muxers need EOS signal to finalize the file. Otherwise, stream will not be playable.


    I also wanted to add that I getting this error / warning in dmesg:
    [   79.411396] vdec 30210000.video-codec: error -ENXIO: IRQ index 0 not found
    [   79.411422] vdec 30210000.video-codec: failed to get irq resource, falling back to polling
    [   79.411585] vdec 30210000.video-codec: OPP table not found in device tree
    [   79.414228] vdec 30210000.video-codec: Added wave5 driver with caps: 'ENCODE' 'DECODE'
    [   79.414247] vdec 30210000.video-codec: Product Code:      0x521c
    [   79.414254] vdec 30210000.video-codec: Firmware Revision: 291549