<span class="Apple-style-span" style="color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">Dear zhivago,</span><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><br>
</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">In my study, I use H264+AAC to output mp4 file.</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">The video timestamp is added by 1. </font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">For example: 0, 1, 2, 3, ......(ffmpeg will handle it by fps.)</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">The audio timestamp is added by 1024.</font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">Audio sample number (512) x sample byte (2) = 1024</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">For example: 0, 1024, 2048 .....</font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">The file can be play by vlc, but QT can not.</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">If your problem is timestamp, try use my value.</font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">But my data is coming from driver(raw data).</font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><br></font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">Regards, Eric Hsieh, 09/19<br></font><br><div class="gmail_quote">2011/9/19 zhivago <span dir="ltr"><<a href="mailto:zhivagoserg@yandex.ua">zhivagoserg@yandex.ua</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
psychesnet wrote:<br>
><br>
> Dear zhivago,<br>
><br>
> you can try to set pkt1.pts = 0, and the ffmpeg will calculate for this<br>
> packet.<br>
><br>
><br>
> Regards, Eric Hsieh, 09/17<br>
><br>
</div>> 2011/9/17 zhivago &<a href="mailto:lt%3Bzhivagoserg@yandex.ua">lt;zhivagoserg@yandex.ua</a>&gt;<br>
<div><div></div><div class="h5">><br>
>> Help me please properly set the timestamps. I have created an output<br>
>> filter,<br>
>> which takes video (MEDIASUBTAYPE_H264) and audio (MEDIASUBTAYPE_AAC). I<br>
>> have<br>
>> to put it all into a container FLV. To mix the streams, I use libav. How<br>
>> to<br>
>> calculate for AVPacket presentation timestamp (pts).<br>
>><br>
>>    static const REFERENCE_TIME UNITS_PER_SECOND = 10000000i64;<br>
>>         ....<br>
>>    REFERENCE_TIME startTime = m_lastSampleTime.startTime;<br>
>><br>
>>    AVPacket pkt;<br>
>>    av_init_packet( &pkt );<br>
>>    pkt.data = pbData;<br>
>>    pkt.size = lDataLength;<br>
>>    pkt.flags |= AV_PKT_FLAG_KEY;<br>
>><br>
>>    if ( video )<br>
>>    {<br>
>>        ASSERT( m_codecContextVideo );<br>
>><br>
>>        num = m_codecContextVideo->time_base.num;<br>
>>        den = m_codecContextVideo->time_base.den;<br>
>><br>
>>        pkt1.pts          ??? // = ::MulDiv( startTime * den, 1, num *<br>
>> UNITS_PER_SECOND );<br>
>>        pkt1.stream_index = m_streamVideoOutput->index;<br>
>>    }<br>
>>    else<br>
>>    {<br>
>>       ASSERT( m_codecContextAudio );<br>
>><br>
>>       num = m_codecContextAudio->time_base.num;<br>
>>       den = m_codecContextAudio->time_base.den;<br>
>><br>
>>       pkt1.pts          ??? // = ::MulDiv( startTime * den, 1, num *<br>
>> UNITS_PER_SECOND );<br>
>>       pkt1.stream_index = m_streamAudioOutput->index;<br>
>>    }<br>
>><br>
>>    ASSERT( m_formatContextOutput );<br>
>><br>
>>    if ( AllConnected() )<br>
>>    {<br>
>><br>
>>        av_interleaved_write_frame( m_formatContextOutput, &pkt1 );<br>
>>    }<br>
>>    else<br>
>>    {<br>
>>        av_write_frame( m_formatContextOutput, &pkt1 );<br>
>>    }<br>
><br>
</div></div>Thanks for the feedback, Eric Hsieh. I set pkt1.pts = 0, but the<br>
synchronized video and sound only about 1 second. Then file does not play.<br>
Maybe have other ideas.<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://libav-users.943685.n4.nabble.com/Timestamps-for-AVPaket-tp3818534p3823325.html" target="_blank">http://libav-users.943685.n4.nabble.com/Timestamps-for-AVPaket-tp3818534p3823325.html</a><br>

</font><div><div></div><div class="h5">Sent from the libav-users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</div></div></blockquote></div><br></div>