[Ffmpeg-devel] Calculating PTS Times
Colin Ward
lists
Sun Oct 23 09:21:01 CEST 2005
Rich Felker wrote:
>
[Snip]
>> Well lots of decoders output 0 for all of their frames with my build
>>of the libraries.
>
> The pts from the decoder is generally meaningless/invalid, except for
> a few codecs that can be used 'raw' without a container, and even for
> these pts is likely invalid if there is a container. You really need
> to obtain pts from the demuxer.
Ok. Take a look at this example code then:
VideoFrame = avcodec_alloc_frame();
BytesDecoded = avcodec_decode_video(VideoContext, VideoFrame,
&VideoFrameReady, RawData, BytesRemaining);
if (BytesDecoded >= 0)
{
if (VideoFrameReady > 0)
if ((VideoFrame->pts == 0) || (VideoFrame->pts == (int64_t)
AV_NOPTS_VALUE))
{
PTS += (int64_t) ((AV_TIME_BASE * av_q2d(VideoContext->time_base) /
1000));
}
else
{
PTS = (long) ((VideoFrame->pts * av_q2d(VideoContext->time_base)) *
1000);
}
}
av_free(VideoFrame);
The VideoFrame->pts value is the one that is usually incorrect. Is
this being placed here by the decoder? Where do I get the pts that has
been calculated by the demuxer?
/-------------------------------------------------------------------\
[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