Arjan wrote:
> Arjan wrote:
>> Hi all, I have a problem with a mpg file. The last frame is not found by 
>> ffmpeg, but it is encoded in the file, since Adobe Premiere can find it.
>>
>> here is a link to the file: 
>> http://arjanhouben.nl/SDL_ffmpeg/ffmpeg/scrtest.mpg (5.3MB)
>> and here is the 'proof' that the frame is actually encoded 
>> http://arjanhouben.nl/SDL_ffmpeg/ffmpeg/scrtest_lastframe.jpg
>>
>> Does anyone have any idea why this frame is not found?
>>
>> tested using
>>
>> FFmpeg version UNKNOWN, Copyright (c) 2000-2008 Fabrice Bellard, et al.
>>   configuration: --disable-debug --enable-shared --disable-static 
>> --enable-memalign-hack
>>   libavutil version: 49.7.0
>>   libavcodec version: 51.57.2
>>   libavformat version: 52.16.0
>>   libavdevice version: 52.0.0
>>   built on Jun 16 2008 11:54:09, gcc: 4.3.0 20080305 (alpha-testing) 
>> mingw-20080502
>>
>> but the behavior is not limited to this version/platform.
>>
>>  - Arjan
>> _______________________________________________
>> libav-user mailing list
>> [email protected]
>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>>   
> I discovered that ffmpeg can actually decode the frame, but only if you 
> ignore the value which av_read_frame returns!
>
> So if you ignore this value, and decode the packet like you would 
> normally, than avcodec_decode_video returns the correct frame..
>
> I can't imagine that this is expected behavior..
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
For completeness, I have figured out what was going wrong.

http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/apiexample_8c-source.html#l00404

and I quote:

    some codecs, such as MPEG, transmit the I and P frame with a
    latency of one frame. You must do the following to have a
    chance to get the last frame of the video

None of the current online examples implements this, including ffplay!
I think this should be implemented in the examples, or at least 
explicitly noted in the doxygen documentation.

For those faced with the same problem, this is the simple solution:
After you have received your last packet, just call avcodec_decode_video 
with NULL for 'buf' and 'buf_size' parameter.
You can use the 'got_picture_ptr' to check whether or not you actually 
got a frame.

- arjan
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to