[mythtv] FFmpeg mediacodec problem
Peter Bennett
pb.mythtv at gmail.com
Thu Jun 14 19:42:14 UTC 2018
On 06/14/2018 03:04 PM, Aman Gupta wrote:
>
>
> On Thu, Jun 14, 2018 at 11:59 AM Peter Bennett <pb.mythtv at gmail.com
> <mailto:pb.mythtv at gmail.com>> wrote:
>
> Hi Aman
>
> mediacodec playback is working quite well now in mythfrontend, but I
> have a problem with ffmpeg as follows:
>
> When decoding 3840x2160 content, there is pixellation caused by
> dropped
> frames. The frames are being dropped because of apparent inconsistent
> behavior in ffmpeg.
>
> MythTV calls avcodec_send_packet to send the next packet. It receives
> -11 return code (EAGAIN) indicating it must call
> avcodec_receive_frame
> and then try to send again. We call avcodec_receive_frame and it
> is also
> getting a -11 return code indicating it must send a packet before
> it can
> receive. According to the documentation this will never happen.
> MythTV
> then reports an error, drops the packet and moves on to the next one.
> This is happening many times. eventually the avcodec_receive_frame
> works
> and we receive a frame, but later the pattern repeats.
>
>
> This is a known issue, cause by an incompatibility between how
> MediaCodec's APIs work vs how FFmpeg's abstraction works.
>
> Ideally MediaCodec would provide a way for us to know whether it needs
> to wait on input or output. But no reliable way to do this exists, so
> the FFmpeg wrapper has to make a guess. And sometimes that guess is
> wrong. I'm aware that we're breaking the API contract as defined by
> libavcodec, but I haven't been able to find a solution.
>
> The only workaround for now is to retry sending the original packet
> instead of dropping it. The second time you call avcodec_send_packet
> it should block instead of returning EAGAIN.
>
> Aman
>
>
> I tried turning on ffmpeg debug logging but I did not see any message
> from that.
>
> Please advise what should be done. Let me know if you need more
> information.
>
> Peter
>
Hi Aman
Thanks for the info. I tried it and the second call to
avcodec_send_packet does not block, it also returns -11.
So what I have done is, sleep 10 milliseconds, then try the receive and
the send again. Continue like this until it works. Now the video is
perfect :).
FYI - what I see is - at the start of playback:
10 packets sent
9 fails and retries to send next packet (above condition)
4 packets sent
1 frame received
After this it sends and receives ok, with one fail and retry every 10
frames or so.
So I think I have a working solution.
Thank you.
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180614/491524aa/attachment.html>
More information about the mythtv-dev
mailing list