h4tr3d / avcpp

C++ wrapper for FFmpeg
Other
425 stars 78 forks source link

example api2-decode fail #127

Open ywangwxd opened 6 months ago

ywangwxd commented 6 months ago

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**
mmomtchev commented 6 months ago

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.

h4tr3d commented 6 months ago

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

if (ec) {
  if (ec == av::make_ffmpeg_condition(-EGAIN)) {
    continue;
  }
  ...
}
ywangwxd commented 6 months ago

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.

h4tr3d commented 6 months ago

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.

ywangwxd commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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.

h4tr3d commented 4 months ago

@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?