[Ffmpeg-devel] PTS calculation revisited

Colin Ward lists
Sun Feb 19 12:49:50 CET 2006

  Hi all.

  I have a PTS calculation system in place whereby it seems to work well
for *most* file formats.  It is based on scanning through various example
code such as ffplay.c.  However, for some files the results are incorrect. 
Take a look at:


  The output from my media player when playing this is as follows:

AMC Info: CFFMPEG::Open() => File recognised as asf
AMC Info: CFFMPEG::Open() => Audio: wmav2, 32000 Hz, stereo, 32 kb/s
AMC Info: CFFMPEG::Open() => Video: wmv2, yuv420p, 320x240
Input #0, asf, from 'Lah':
  Duration: 00:00:16.4, start: 3.100000, bitrate: 355 kb/s
  Stream #0.0: Audio: wmav2, 32000 Hz, stereo, 32 kb/s
  Stream #0.1, 30.00 fps(r): Video: wmv2, yuv420p, 320x240

  As you can see it is wmv2 video and is 30 FPS.  When I allocate a video
frame and decode it with avcodec_decode_video() the AVFrame->pts value that
is returned is always zero.  So I manually calculate the delta between
frames by using the following code:

  double frame_delay =
  frame_delay *= 1000; // Convert to milliseconds

  However, this always results in frame_delay being 1 (millisecond!) rather
than 33.3333 which it should be in order to be played at 30 FPS.

  What am I doing wrong?

[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