avcpp icon indicating copy to clipboard operation
avcpp copied to clipboard

example api2-decode fail

Open ywangwxd opened this issue 2 years ago • 10 comments

I compiled ffmpeg with rockchip mpp. I have tested ffmpeg command to transcode a rtsp stream to a video file, it is working well. But if I use api2-decode or api2-decode-encode-video, neither of them success.

This is the final part of the screen message. It seems that the decoder get many empty frame. The final error is hard to understand.


Read packet: 58410*1/90000 / 0.649 / 1/90000 / st: 0
[hevc_rkmpp_decoder @ 0x55c18e25e0] Received a frame.
  Frame: 3840x2160, size=27372544, ts=9000*1/90000, tm: 0.1, tb: 1/90000, ref=1:1
Read packet: 62910*1/90000 / 0.699 / 1/90000 / st: 0
[hevc_rkmpp_decoder @ 0x55c18e25e0] Wrote 18189 bytes to decoder
[hevc_rkmpp_decoder @ 0x55c18e25e0] Received a frame.
  Frame: 3840x2160, size=27372544, ts=13500*1/90000, tm: 0.15, tb: 1/90000, ref=1:1
Read packet: 67410*1/90000 / 0.749 / 1/90000 / st: 0
[hevc_rkmpp_decoder @ 0x55c18e25e0] Received a frame.
  Frame: 3840x2160, size=27372544, ts=18000*1/90000, tm: 0.2, tb: 1/90000, ref=1:1
Read packet: 71910*1/90000 / 0.799 / 1/90000 / st: 0
**Error: FFmpegError:-11, Resource temporarily unavailable**

ywangwxd avatar Dec 27 '23 12:12 ywangwxd

Are you using the latest release or a git checkout? I fixed a number of small problems related to these examples very recently. Try compiling a vanilla ffmpeg 6.1 and try transcoding file to file, if this doesn't work, then there is a problem.

mmomtchev avatar Dec 28 '23 12:12 mmomtchev

'-11' means EAGAIN. You can try to make access again, something like:

if (ec) {
  if (ec == av::make_ffmpeg_condition(-EGAIN)) {
    continue;
  }
  ...
}

h4tr3d avatar Dec 29 '23 01:12 h4tr3d

I git pull the latest commit from the master branch. The last commit is Dec 21. As I said, if I use ffmpeg command line to transcoe, it is working. Does this mean there is no problem with the rockchip-mpp backend?

Are you using the latest release or a git checkout? I fixed a number of small problems related to these examples very recently. Try compiling a vanilla ffmpeg 6.1 and try transcoding file to file, if this doesn't work, then there is a problem.

ywangwxd avatar Dec 29 '23 01:12 ywangwxd

Are you sure, I found return code <0 is error in the document.

In common way - you are right. But there is cases, when, for example, data is not ready yet but system work properly and you should just a wait a little. EBUSY, EAGAIN just a way say it.

In any case, HW can just stuck and maybe some proper configuration is needed in additional to generic SW setup.

h4tr3d avatar Dec 29 '23 02:12 h4tr3d

Are you sure, I found return code <0 is error in the document.

In common way - you are right. But there is cases, when, for example, data is not ready yet but system work properly and you should just a wait a little. EBUSY, EAGAIN just a way say it.

In any case, HW can just stuck and maybe some proper configuration is needed in additional to generic SW setup.

The original code is something like this


while (Packet pkt = ictx.readPacket(ec)) {
//some other code here
VideoFrame frame = vdec.decode(pkt, ec);
//some other code here
}

You mean I should do a while in the while? eg, do a while loop after each packet or do it on the read packet & decode together?

ywangwxd avatar Dec 29 '23 06:12 ywangwxd

Are you sure, I found return code <0 is error in the document.

In common way - you are right. But there is cases, when, for example, data is not ready yet but system work properly and you should just a wait a little. EBUSY, EAGAIN just a way say it. In any case, HW can just stuck and maybe some proper configuration is needed in additional to generic SW setup.

The original code is something like this


while (Packet pkt = ictx.readPacket(ec)) {
//some other code here
VideoFrame frame = vdec.decode(pkt, ec);
//some other code here
}

You mean I should do a while in the while? eg, do a while loop after each packet or do it on the read packet & decode together?

I have tried doing a for loop on VideoFrame frame = vdec.decode(pkt, ec); but it never stops after get -11 return value.

ywangwxd avatar Dec 29 '23 07:12 ywangwxd

Are you sure, I found return code <0 is error in the document.

In common way - you are right. But there is cases, when, for example, data is not ready yet but system work properly and you should just a wait a little. EBUSY, EAGAIN just a way say it. In any case, HW can just stuck and maybe some proper configuration is needed in additional to generic SW setup.

The original code is something like this


while (Packet pkt = ictx.readPacket(ec)) {
//some other code here
VideoFrame frame = vdec.decode(pkt, ec);
//some other code here
}

You mean I should do a while in the while? eg, do a while loop after each packet or do it on the read packet & decode together?

Neither of the two approaches work. But if I use ffmpeg command line to do anything, decode or transcode. It is working. With the vallina ffmpeg compiled, this is no problem.

ywangwxd avatar Dec 29 '23 07:12 ywangwxd

An update again. I have tried the example code of decode_video.c in the official ffmpeg repo under /doc/examples. This example program is working with ffmpeg-mpp. So it is highly possible that there is some problem with api2-decode here.

ywangwxd avatar Dec 29 '23 08:12 ywangwxd

@ywangwxd , could you please send me a sample of the problematic video? Also, issue are mpp related only? Does video successfully processed by the software decoder?

h4tr3d avatar Mar 09 '24 04:03 h4tr3d