Artifacts when transcoding H264 RTP stream to MPEG4 on i.MX 6

Hi.

I’m using gstreamer to convert an H264 UDP (RTP) stream to MPEG4 on an i.MX 6 platform. This is my pipeline:

caps_in='application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,packetization-mode=(string)1,sprop-parameter-sets=(string)"J2QAH6wTGqBQBbpGDAIEgAAAAwCAAAAZB4sS3A\=\=\,KM4EcsA\=",profile-level-id=(string)64001f,profile=(string)high,payload=(int)96'
caps_h264='video/x-h264,stream-format=(string)byte-stream,alignment=(string)au,level=(string)3.1,profile=(string)high,width=(int)1280,height=(int)720,framerate=(fraction)50/1,colorimetry=(string)bt601'

gst-launch-1.0 -vv udpsrc port=5001 caps="${caps_in}" buffer-size=$(( 1024 * 1024 * 4 )) \
! rtpjitterbuffer latency=1500 \
! rtph264depay \
! "${caps_h264}" \
! v4l2h264dec \
! v4l2mpeg4enc extra-controls="cid,video_bitrate=0" \
! 'video/mpeg,level=(string)5,profile=(string)simple' \
! mpeg4videoparse config-interval=-1 \
! rtpmp4vpay config-interval=-1 \
! udpsink host="ff02::1%eth0" port="4001" auto-multicast=false buffer-size=$(( 1024 * 1024 * 4 ))

If I start this pipeline, one of two things happens:

  • In most cases (about 80%) the stream looks good. In this case it will continue to look good “forever”.
  • In some cases (about 20%) I can play the stream but it contains artifacts. The artifacts won’t go away until I restart the pipeline.

If I play the stream from the second case with mplayer instead of gstremer, I get warnings like these (in addition to the artifacts):

[mpeg4 @ 0x75ad18f51640]slice end not reached but screenspace end (64 left 7F5934, score= -7443)
[mpeg4 @ 0x75ad18f51640]concealing 3600 DC, 3600 AC, 3600 MV errors in I frame

Regardless of whether the stream works right or not, I also get errors like this one from the transcoding gstreamer (no idea whether these are relevant):

[ 6730.318005] cma: cma_alloc: reserved: alloc failed, req-size: 338 pages, ret: -12
[ 6747.106949] cma: cma_alloc: reserved: alloc failed, req-size: 255 pages, ret: -12
[ 6747.114556] coda 2040000.vpu: dma alloc of size 1044480 failed
[ 6747.746289] cma: cma_alloc: reserved: alloc failed, req-size: 338 pages, ret: -12
[ 6757.341396] cma: cma_alloc: reserved: alloc failed, req-size: 338 pages, ret: -12

This all happens with gstreamer 1.22.9, 1.22.12 and 1.24.5 on Linux 6.6.32, 6.6.41 and 6.10.

Now I’m running low on ideas. To me it looks as if the MPEG4 encoder occasionally got a bad start and never recovered, but I don’t know what to do about it / how to debug this further. Does anyone have any idea on what I could try?