[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mythtv-dev
Subject:    Re: [mythtv] mediacodec errors
From:       Peter Bennett <pb.mythtv () gmail ! com>
Date:       2018-07-02 20:06:30
Message-ID: 63defade-452e-ea70-ad5c-ab4d518b71ab () gmail ! com
[Download RAW message or body]

Hi Aman

This workaround that I sent you (see below) is not successful. On 
Android 8 I am getting illegal state exceptions with FF with 720p 
recordings, with the workaround in place.

Peter


On 06/29/2018 05:40 PM, Peter Bennett wrote:
> The method dequeueOutputBuffer can throw IllegalStateException. 
> According to the MediaCodec documentation that means it is not in the 
> Executing state, or codec is configured in asynchronous mode. I don't 
> have enough understanding of how it works to know why that would be.
>
> I believe that this may only happen with 1080i interlaced video.
>
> The situation only occurs if you send several packets until there are 
> frames available, then receive only one frame from the codec context 
> and then flush, expecting to lose any remaining frames. Doing this 
> sequence repeatedly causes the error after about 10 or 15 times. 
> Somehow those available frames are not being correctly flushed. By 
> adding my own code to discard those frames I avoid the problem.
>
> Add this code before avcodec_flush_buffers:
>
>                 int ret = 0;
>                 while (ret == 0)
>                 {
>                     AVFrame *frame = av_frame_alloc();
>                     ret = avcodec_receive_frame(enc, frame);
>                     av_frame_free(&frame);
>                 }
>
> No More exceptions!!
>
> It should not be necessary to receive all available frames and discard 
> them like this before flushing. Perhaps something like this code 
> snippet should be added to avcodec_flush_buffers.
>
> Please let me know if you make any change in ffmpeg to solve this 
> issue so that I can remove this piece of code.
>
> Peter
>

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic