Re: avcodec_decode_video not decoding frames when expected

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_video not decoding frames when expected

Arjan-6
Michel Bardiaux wrote:

> Arjan wrote:
>> Hi all,
>> I am trying to implement a seek function for my video playback system.
>> I'll try to explain the problem by this example: (times in milliseconds)
>>
>>
>> SEEK DONE                       (seek to 5000, using AVSEEK_FLAG_BACKWARD)
>> VIDEO PTS FOUND: 4960           (key frame)
>> VIDEO PTS FOUND: 5000
>> VIDEO PTS FOUND: 5040
>> VIDEO PTS FOUND: 5040
>> VIDEO PTS FOUND: 5080
>> VIDEO PTS FOUND: 5120
>> VIDEO PTS FOUND: 5160           (key frame)
>> VIDEO PTS FOUND: 5200
>> VIDEO PTS FOUND: 5240
>> VIDEO PTS FOUND: 5280
>> WRITTEN PTS [5280] INTO BUFFER  (avcodec_decode_video returned frame)
>>
>>
>> Here's what's happening; I tried seeking to 5000ms, I used the
>> AVSEEK_FLAG_BACKWARD so I would get the first keyframe before the time I
>> need. This seems to work fine, as the first PTS which is found, is a
>> keyframe. The next frame is the valid frame, but avcodec_decode_video
>> does not return a frame.
>> It's only at pts 5280, when there has been another key frame and several
>> B frames, that avcodec_decode_video finally returns a frame.
>>
>> I would like to know if this is expected behaviour,
>
> Impossible to tell without knowing the GOP structure. Besides, is PTS
> 5040 really duplicated? That is suspect.
>
>> and if it is, how
>> can I make sure I get the frame I need as fast as possible?
>
> There are the fields hurry_up, skip_frame and skip_idct in the codec
> context, that might be a solution. Just a guess though, I dont know what
> they do exactly.
>
>> thanks in advance,
>>

I'm investigating this again, and I still don't get it.
I only get the duplicate frames when I do an av_seek_frame call.
After the call I always flush the buffers (avcodec_flush_buffers) but it
doesn't matter.

it comes down to the following calls:

- av_seek_frame
- avcodec_flush_buffers
- av_read_frame

They are executed in that order, but after I call avcodec_decode_video
on the aquired videopacket, I sometimes get repeated pts values and I
don't always get the keyframe I expect.

I already tried setting skip_loop_filter, skip_idct and skip_frame to
AVDISCARD_NONE, but it did not change anything.

I hope someone can point me in the right direction, this is really
annoying :)
_______________________________________________
libav-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user