[Ffmpeg-devel] Setting timestamps...

Mat heavensdoor78
Thu Sep 29 16:20:36 CEST 2005


Hi all.
I'm here again about var fps... :) I need help.
In my app I produce many short videoclips (30 secs) with 
avcodec/avformat (mp4/mov)
The framerate could change between the clips... how do I manage 
correctly the variable framerate?

This is what I do:
- I create a movie (let's assume we have 10 fps in this clip) and I set:
    time_base.num = 1;
    time_base.den = 1000;
    g_pts = 0;
- I write a single frame, I try to set the timestamp:
    avcodec_encode_video( ... );
    av_init_packet( &pkt );
    pkt.pts = g_pts;
    g_pts += 100;               // I can put here any values... like 
100000... the result is always the same
    if( c->coded_frame->key_frame )
        pkt.flags |= PKT_FLAG_KEY;
    pkt.stream_index = vo->avVideoStream->index;
    pkt.data = vo->video_outbuf;
    pkt.size = out_size;
    av_write_frame( vo->avContext, &pkt );
- I close the movie.

The clip is too fast... all the frames in 1 second.
What I'm doing wrong ?

In  output_example the framerate was 1 / 25 and:
    pkt.pts = av_rescale_q( c->coded_frame->pts, c->time_base, 
vo->avVideoStream->time_base );

Tnx in advance
-Mat-





More information about the ffmpeg-devel mailing list