JeffyCN / FFmpeg

FFmpeg with rkmpp hwdec - (deprecated due to license issue, check gstreamer instead or https://github.com/nyanmisaka/ffmpeg-rockchip)
https://ffmpeg.org
Other
60 stars 18 forks source link

"Buffer full" and stuck on RK3588 #7

Closed chuqingq closed 2 years ago

chuqingq commented 2 years ago

env:

  1. RK3588.
  2. rockchip/mpp master 5132a49 and mpi_dec_test run successfully.
  3. ffmpeg https://github.com/JeffyCN/FFmpeg/tree/ubuntu/4.2.2-1ubuntu1 5467ab6

sudo ./ffmpeg -v debug -y -vcodec h264_rkmpp -i ../1.mp4 -an -vframes 250 ../ffmpeg2.yuv

output:

[h264_rkmpp @ 0x5578761b80] Initializing RKMPP decoder.
[h264_rkmpp @ 0x5578761b80] RKMPP decoder initialized successfully.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> rawvideo (native))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[NULL @ 0x557875dd50] nal_unit_type: 7(SPS), nal_ref_idc: 3
[NULL @ 0x557875dd50] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264_rkmpp @ 0x5578761b80] Wrote 8529 bytes to decoder
[h264_rkmpp @ 0x5578761b80] Timeout getting decoded frame.
    Last message repeated 1 times
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264_rkmpp @ 0x5578761b80] Wrote 6842 bytes to decoder
[h264_rkmpp @ 0x5578761b80] Timeout getting decoded frame.
    Last message repeated 1 times
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264_rkmpp @ 0x5578761b80] Wrote 6972 bytes to decoder
[h264_rkmpp @ 0x5578761b80] Timeout getting decoded frame.
    Last message repeated 1 times
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264_rkmpp @ 0x5578761b80] Wrote 7158 bytes to decoder
[h264_rkmpp @ 0x5578761b80] Timeout getting decoded frame.
    Last message repeated 1 times
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264_rkmpp @ 0x5578761b80] Buffer full

and stuck here.

JeffyCN commented 2 years ago

ffmpeg rkmppdec is just a wrapper of mpp, so for this kind of issues, likely to be a mpp issue.

so please report to mpp issue tracker.

then for example enable mpp debug log to check where it stuck.

chuqingq commented 2 years ago

ffmpeg rkmppdec is just a wrapper of mpp, so for this kind of issues, likely to be a mpp issue.

so please report to mpp issue tracker.

then for example enable mpp debug log to check where it stuck.

OK, I will report to mpp issue tracker, which is https://github.com/rockchip-linux/mpp right? And I will enable mpp debug log, and provide more information to mpp issue tracker.

I trace the ffmpeg code, and find it stuck on decode_put_packet https://github.com/JeffyCN/FFmpeg/blob/ubuntu/4.2.2-1ubuntu1/libavcodec/rkmppdec.c#L443 and timeout is MPP_TIMEOUT_BLOCK.

Thank you!

JeffyCN commented 2 years ago

looks like mpp issue

JeffyCN commented 1 year ago

FYI, we found an issue that the mpp might not be able to return frames with the starting 4 packets for some streams.

I've pushed a workaround for it:

+++ b/libavcodec/rkmppdec.c
@@ -721,8 +721,10 @@ static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
             // send pending data to decoder
             ret = rkmpp_send_packet(avctx, packet);
             if (ret == AVERROR(EAGAIN)) {
-                // blocked polling since we got enough data
-                return rkmpp_get_frame(avctx, frame, MPP_TIMEOUT_BLOCK);
+                // some streams might need more packets to start returning frame
+                ret = rkmpp_get_frame(avctx, frame, 1);
+                if (ret != AVERROR(EAGAIN))
+                    return ret;
             } else if (ret < 0) {