[Libav-user] AVCodecContext::time_base 1/fps?

Korbe, Will wkorbe at akamai.com
Tue Aug 2 03:55:27 CEST 2011


Hello,


The comment for AVCodecContext::time_base seems to indicate this variable can be interpreted two ways, depending if the content is fixed-fps or not. However, I don't see in the code how this is accounted for, for example, in mpegtssenc.c, where it wants to determine the pcr_packet_period, it appears to rely on this value being set to the 1/fps, but it does not do any explicit checks if the content is fixed-fps or not. Should this value really just be 1/fps always? A previously developer  set time_base to 1/1000 in our application to indicate milliseconds, but this caused the mpeg2-ts output to have a PCR value every 100 packets which didn't meet the once every 100ms MPEG2-TS specification. Changing the time_base to 1/fps, which was 1/25 in this case, allowed a PCR at least once every 100ms. I'm worried about the side-effects this may cause and want to understand the true meaning for AVCodecContext::time_base. It there a way to tell if a codec is fixed-fps?

Thank you,
Will


avcodec.h:

typedef struct AVCodecContext {
...

    /**
     * This is the fundamental unit of time (in seconds) in terms
     * of which frame timestamps are represented. For fixed-fps content,
     * timebase should be 1/framerate and timestamp increments should be
     * identically 1.
     * - encoding: MUST be set by user.
     * - decoding: Set by libavcodec.
     */
    AVRational time_base;
...

mpegtsenc.c:
..
        } else {
            // max delta PCR 0.1s
            service->pcr_packet_period =
                pcr_st->codec->time_base.den/(10*pcr_st->codec->time_base.num);
        }
...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110801/61b01a0f/attachment.html>


More information about the Libav-user mailing list