This was really simple, but took me about a day to find out. A google search didn’t help this time so I post it here and maybe it is going to help someone else.
It turns out that the format context has a handy member: duration. This may or may not be valid, so it needs to be checked before using it. The following two lines of code will do the trick:
av_seek_frame(pFormatCtx, -1, pFormatCtx->duration, 0);
When using -1 as a stream index, the time is measured in ffmpeg’s time base, which is the same unit the duration member is in.
- FFmpeg Announces High-Performance VP8 Decoder (news.slashdot.org)
- RockPlayer brings FFmpeg video playback to Android (arstechnica.com)