[mythtv] Mediacodec problem with fire stick 4K
aman at tmm1.net
Wed Dec 5 23:13:08 UTC 2018
On Wed, Nov 21, 2018 at 9:46 PM Aman Gupta <aman at tmm1.net> wrote:
> On Tue, Nov 20, 2018 at 2:32 PM Aman Gupta <aman at tmm1.net> wrote:
>> On Tue, Nov 20, 2018 at 2:28 PM Peter Bennett <pb.mythtv at gmail.com>
>>> Hi Aman
>>> When running with mediacodec on the fire stick 4K, there is a problem
>>> with MPEG2. Perhaps the 4K does not support MPEG2 or the interlacing is
>>> causing a problem. What appears to happen is that we get the situation
>>> where we have done avcodec_send_packet until it returns AVERROR(EAGAIN).
>>> The avcodec_receive_frame also returns AVERROR(EAGAIN) and this
>>> continues forever, we never get a frame out of it. With h264 it works
>>> fine. If there is no MPEG2 support, maybe we should get an error return
>>> or it should revert to software decoding. Is there anything ffmpeg can
>>> do to avoid this, or do I have something wrong in my code?
>> The hardware mpeg2 decoder on that device is extremely buggy.
>> For some interlaced streams, it will generate flashing green output:
Amazon has verified this bug and says they are waiting on a vendor driver
update to resolve it.
>> For videos where it works, the decoder will randomly lock up after some
>> time and stop accepting new packets and also stop returning new frames (as
>> you noticed).
> The green screen issue is definitely hardware specific, but this freezing
> issue may actually be an ffmpeg bug.
I've gotten reports that this freeze issue also happens with h264
MediaCodec decoding on the 4K Stick, which further suggests this is an
issue with ffmpeg's mediacodec wrapper.
Since this seems like some sort of race condition, one thing to try would
be adjusting the timeouts used when dequeuing input/output buffers:
Another (much bigger) change would be to introduce threads and use one
dedicated thread for output buffers. VLC uses a similar technique and I got
similar advice from a developer on the Android media team- mediacodec is
thread safe and using separate threads for input and output is recommended.
> I recall that I've seen the freeze happen on other FireOS devices, like
> the older FireTV boxes.
> Further, none of these devices (including the new 4K stick) seem to
> reproduce the hang when using Exoplayer or VLC.
> However I'm not sure what ffmpeg could do differently to avoid this issue.
> The code in ffmpeg is already very similar to Exoplayer.
> I've spent dozens of hours trying to debug this at various times this year
> and sadly made no progress. It seems to happen quite regularly on the 4K
> stick, which at least makes it easier to try out potential fixes.
> If anyone wants to spend time on this I'm happy to advise, but I have
> given up on trying to fix this myself.
>> These are issues in the underlying codec/hardware/OS and not something
>> ffmpeg can work-around.
>>> I have set ffmpeg debug logging and captured the log. That is here ->
>>> The code where we process packets is here ->
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mythtv-dev