[Libav-user] Timestamps for AVPaket

Eric Hsieh(Psychesnet) psychesnet at gmail.com
Mon Sep 19 15:38:40 CEST 2011


Dear zhivago,

In my study, I use H264+AAC to output mp4 file.
The video timestamp is added by 1.
For example: 0, 1, 2, 3, ......(ffmpeg will handle it by fps.)
The audio timestamp is added by 1024.
Audio sample number (512) x sample byte (2) = 1024
For example: 0, 1024, 2048 .....
The file can be play by vlc, but QT can not.
If your problem is timestamp, try use my value.
But my data is coming from driver(raw data).

Regards, Eric Hsieh, 09/19

2011/9/19 zhivago <zhivagoserg at yandex.ua>

>
> psychesnet wrote:
> >
> > Dear zhivago,
> >
> > you can try to set pkt1.pts = 0, and the ffmpeg will calculate for this
> > packet.
> >
> >
> > Regards, Eric Hsieh, 09/17
> >
> > 2011/9/17 zhivago <zhivagoserg at yandex.ua>
> >
> >> Help me please properly set the timestamps. I have created an output
> >> filter,
> >> which takes video (MEDIASUBTAYPE_H264) and audio (MEDIASUBTAYPE_AAC). I
> >> have
> >> to put it all into a container FLV. To mix the streams, I use libav. How
> >> to
> >> calculate for AVPacket presentation timestamp (pts).
> >>
> >>    static const REFERENCE_TIME UNITS_PER_SECOND = 10000000i64;
> >>         ....
> >>    REFERENCE_TIME startTime = m_lastSampleTime.startTime;
> >>
> >>    AVPacket pkt;
> >>    av_init_packet( &pkt );
> >>    pkt.data = pbData;
> >>    pkt.size = lDataLength;
> >>    pkt.flags |= AV_PKT_FLAG_KEY;
> >>
> >>    if ( video )
> >>    {
> >>        ASSERT( m_codecContextVideo );
> >>
> >>        num = m_codecContextVideo->time_base.num;
> >>        den = m_codecContextVideo->time_base.den;
> >>
> >>        pkt1.pts          ??? // = ::MulDiv( startTime * den, 1, num *
> >> UNITS_PER_SECOND );
> >>        pkt1.stream_index = m_streamVideoOutput->index;
> >>    }
> >>    else
> >>    {
> >>       ASSERT( m_codecContextAudio );
> >>
> >>       num = m_codecContextAudio->time_base.num;
> >>       den = m_codecContextAudio->time_base.den;
> >>
> >>       pkt1.pts          ??? // = ::MulDiv( startTime * den, 1, num *
> >> UNITS_PER_SECOND );
> >>       pkt1.stream_index = m_streamAudioOutput->index;
> >>    }
> >>
> >>    ASSERT( m_formatContextOutput );
> >>
> >>    if ( AllConnected() )
> >>    {
> >>
> >>        av_interleaved_write_frame( m_formatContextOutput, &pkt1 );
> >>    }
> >>    else
> >>    {
> >>        av_write_frame( m_formatContextOutput, &pkt1 );
> >>    }
> >
> Thanks for the feedback, Eric Hsieh. I set pkt1.pts = 0, but the
> synchronized video and sound only about 1 second. Then file does not play.
> Maybe have other ideas.
>
>
> --
> View this message in context:
> http://libav-users.943685.n4.nabble.com/Timestamps-for-AVPaket-tp3818534p3823325.html
> Sent from the libav-users mailing list archive at Nabble.com.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110919/77a76cff/attachment.html>


More information about the Libav-user mailing list