On Sat, Mar 8, 2008 at 1:51 AM, Michael Niedermayer <[EMAIL PROTECTED]>
wrote:

> On Tue, Mar 04, 2008 at 01:53:10AM +0100, Xawotihs wrote:
> > Hello ffmpeg gurus,
> >
> > I've written a directshow splitter somehow working based on
> > libavformat, now I've decided to write a muxer.
> >
> > So, Directshow gives me some compressed "mediasamples" with a
> > timestart and timestop in what they call REFERENCE_TIME (1/10000000
> > second since the beginning of the stream).
> > Now, I've got that and I need to fill libavformat AVStream structures
> > and also the AVPacket structure for each mediasample. So, because I'm
> > lazy I thought I would just hardcode the AVStream.time_base for all my
> > streams to 1/10000000 and just use the real duration of my packets
> > (timestop-timestart) for each packet as the AVPacket.duration ... big
> > mistake :)
> >
> > Actually it works for audio on the small wav file I produced, but for
> > video, my windows explorer freezes completly each time I open the
> > directory containing my produced .avi file ... When I open the
> > produced file in virtualdub, it tells me my files uses a framerate of
> > 10000000 fps and contains 99.1% overhead =)
> >
> > So, I looked at the code a bit and I noticed AVStream.duration is not
> > used at all in the AVI muxer, it's barelly used in the MOV muxer, and
> > kinda used in the MKV muxer...
> > Am I doomed to guess a constant framerate from my video stream and set
> > that as AVStream.time_base ?
>
> AVStream.time_base is not supposed to be written to by the user. You can
> set AVCodecContext.time_base.
> AVI has some overhead problems with large timebases, but the fact that
> MS can generate avis shows the API must provide a frame rate.
>
I just checked my code and I was indeed setting AVCodecContext.time_base and
not AVStream.time_base. Sorry for the confusion.

So, to pick a concrete example, if I set

AVCodecContext.time_base.num = 1
AVCodecContext.time_base.den = 100000000
AVPacket1.PTS = 0
AVPacket1.duration = 400000,
AVPacket2.PTS = 400000
AVPacket2.duration = 400000.

It's completly normal that I'm creating a 10000000 fps AVI movies full of
NULL frame and once every 400000 frames, a real codec frame lasting
1/1000000 second and not a 25 fps movie ?

For me the input needed to get such movie would have been:
AVCodecContext.time_base.num = 1
AVCodecContext.time_base.den = 100000000
AVPacket1.PTS = 0
AVPacket1.duration = 1,
AVPacket2.PTS = 400000
AVPacket2.duration = 1.

When I looked at the AVI muxer code, I noticed that AVPacket.duration was
not used by the AVI muxer ... When I looked at the MOV muxer, I noticed the
AVPacket.duration seems strangely used and it seemed ok in the MKV muxer.

My real problem is that DirectShow gives me at filter connection time an
average frame duration, I can easily use that to compute an average frame
rate, but that's just average, what will happen if suddendly a frame last
1.5 times as much than the others ?

Yann.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to