[mythtv] mediacodec illegalstateexception

Peter Bennett pb.mythtv at gmail.com
Sat Jul 21 21:37:08 UTC 2018



On 07/20/2018 06:43 PM, Aman Gupta wrote:
> Can you try this patch and see if it has any affect on the 
> illegalstateexceptions?
>
> https://gist.github.com/tmm1/b209155c2414f4a30c6e20ddc6dea236
>
> Also would be interesting to know if either of those WARNING logs I 
> added get triggered.
>
> Aman
Hi Aman

I applied the patch. The error still happens and I did not see the 
packet warning messages. here are some of the log messages. The message 
"Video decode buffering retry" indicates that we have the situation 
where avcodec_send_packet and avcodec_receive_frame are both returning 
AVERROR(EAGAIN) so it is trying again.

FF in a recording 1080i mpeg2:

2018-07-21 16:58:46.811249 I  Dec: FindPosition(18016, search not 
adjusted) -->
             [408:18010(740732596),409:18071(743318912)]
2018-07-21 16:58:46.811300 I  AFD: SeekReset(18010, 0, do flush, don't 
discard)
2018-07-21 16:58:46.811392 I  AFD: SeekReset() flushing
2018-07-21 16:58:46.841151 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.851539 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.862007 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.872595 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.882966 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.893267 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.903554 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.913918 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.924261 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.934694 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.945214 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.955866 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.966270 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.976657 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.987042 I  AFD: Video decode buffering retry
2018-07-21 16:58:46.997478 I  AFD: Video decode buffering retry
2018-07-21 16:58:47.008211 I  AFD: Video decode buffering retry
2018-07-21 16:58:47.018716 I  AFD: Video decode buffering retry
2018-07-21 16:58:47.029131 I  AFD: Video decode buffering retry
2018-07-21 16:58:47.039607 I  AFD: Video decode buffering retry
2018-07-21 16:58:47.050284 E  [amediacodec @ 0x2884ca9118] 
java.lang.IllegalStateException occurred
2018-07-21 16:58:47.050324 E  [mpeg2_mediacodec @ 0x2884c90378] Failed 
to dequeue output buffer (status=-542398533)
2018-07-21 16:58:47.050362 E  AFD: video avcodec_receive_frame error: 
Generic error in an external library (-542398533) gotpicture:0
2018-07-21 16:58:47.050399 I  AFD: SeekReset(0, 0, do flush, do discard)
2018-07-21 16:58:47.050487 I  AFD: SeekReset() flushing
2018-07-21 16:58:47.050887 E  [amediacodec @ 0x2884ca9118] 
java.lang.IllegalStateException occurred
2018-07-21 16:58:47.050911 E  [mpeg2_mediacodec @ 0x2884c90378] Failed 
to flush codec

When it happens I free up the codec context and create a new one. The 
exceptions are not always preceded by so many "Video decode buffering 
retry" messages. this is the next failure in the same FF operation:

2018-07-21 16:58:49.499814 I  AFD: SeekReset(18283, 0, do flush, don't 
discard)
2018-07-21 16:58:49.499835 I  AFD: SeekReset() flushing
2018-07-21 16:58:49.527726 I  AFD: Video decode buffering retry
2018-07-21 16:58:49.538118 E  [amediacodec @ 0x2884ca9118] 
java.lang.IllegalStateException occurred
2018-07-21 16:58:49.538143 E  [mpeg2_mediacodec @ 0x2884c90378] Failed 
to dequeue output buffer (status=-542398533)
2018-07-21 16:58:49.538166 E  AFD: video avcodec_receive_frame error: 
Generic error in an external library (-542398533) gotpicture:0
2018-07-21 16:58:49.538190 I  AFD: SeekReset(0, 0, do flush, do discard)
2018-07-21 16:58:49.538214 I  AFD: SeekReset() flushing
2018-07-21 16:58:49.538472 E  [amediacodec @ 0x2884ca9118] 
java.lang.IllegalStateException occurred
2018-07-21 16:58:49.538488 E  [mpeg2_mediacodec @ 0x2884c90378] Failed 
to flush codec

The sequence is that when I start FF it works fine until it has fast 
forwarded for about two minutes (10 minutes into the recording). Then it 
gets the exception, and recreates the codec context.  Then it continues 
and after that it gets the error much more frequently, every few seconds.

It is doing many flush actions followed by decoding sequences. When it 
is in the stage of errors happening frequently, it successfully handles 
5 or 10 flush and decode operations before the error happens again.

Peter


More information about the mythtv-dev mailing list