[Ffmpeg-devel] Timestamps Again
Colin Ward
lists
Sat Nov 5 05:31:49 CET 2005
*sigh*
This pts business is really getting me down. I have been fiddling
with this code on and off for weeks now and can make no progress.
Different file formats seems to act differently and all of the example
sources (ffmpeg.c, ffplay.c) do different things and are all very
complex. So far I have found that the following piece of pseudocode
works the best:
static double pts;
avcodec_decode_video(context, &frame, ...)
if ((frame->pts == 0) || (frame->pts == AV_NOPTS_VALUE))
{
pts += (av_q2d(context->time_base) * 1000);
}
else
{
pts = ((frame->pts * av_q2d(context->time_base)) * 1000);
}
This results in pts being set to the presentation time in milliseconds.
This works fine for avi, mp4, wmv and mpeg files that I tested but
fails for mov files (frame->pts is always zero and the calculated pts
always ends up being incremented by only one millisecond).
Can someone *please* help me with this. Obtaining the presentation time
seems to be terribly difficult with ffmpeg and lots of people suffer
from this problem. Once I have sorted out these problems once and for
all I would like to make some example code to be posted in an FAQ and,
even better, an avformat_get_pts() function that will do all of the hard
work that everybody has to currently re-implement every time they write
a video player that uses ffmpeg.
/-------------------------------------------------------------------\
[Hitman/Code HQ - 6502/z80/68000/604e/80x86/ARM coder - Amiga rulez!]
[VZ-200/VIC-20/MZ-700/c16/c64*10/c128*8/Plus-4/CPC464/CD32/500*2 ]
[600/1000/1200*2/A4000/SNES/N64/Dreamcast/Athlon 1100/AmigaOne ]
[Assembly Language: The most fun you can have with your clothes on! ]
\-------------------------------------------------------------------/
More information about the ffmpeg-devel
mailing list