Dear Mart,<div><br></div><div>Thanks your reply, but your suggestion is not work.</div><div>I try to use the following function to get pts,</div><div><br>pkt.pts = av_rescale_q(packet-><u></u>timestamp().microseconds(), (AVRational){1,1000000}, stream_context->time_base);</div>
<div><br></div><div>the vlc will buffering the data and always show "Buffering 0%" on debug message window.</div><div>On the other hand, I always fill pts = 0 to ffmpeg when it write video and audio packet.</div>
<div>The video is smooth, but the audio can not be decoded, no voice and the debug message window will show "PTS is out of range (......), dropping buffer".</div><div>Does anyone have ideal to resolve this issue, please help me. Thanks a lot.</div>
<div><br></div><div>Regards, Eric Hsieh, 09/13</div><div><br></div><div><br><div class="gmail_quote">2011/9/9 Mart <span dir="ltr"><<a href="mailto:mart.vandesanden@yb.nl">mart.vandesanden@yb.nl</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
As I understand and use it, to calculate the pts you need to take the time base of the stream into account. For example, my application uses a native time base that is in microseconds (thus if you have a frame rate of 15, the timestamp of each frame is increased by 1000000/15 = (about) 66667). This can be calculated to the stream's time_base with the av_rescale_q function, in the following manner:<br>

<br>
    pkt.pts = av_rescale_q(packet-><u></u>timestamp().microseconds(), (AVRational){1,1000000}, stream_context->time_base);<br>
<br>
The first argument is the timestamp of the frame in microseconds, the second is the microsecond time_base and the third argument is the streams time_base. So this functions transfers a value from one time base to another.<br>

<br>
I hope this helps (and that it is correct, it seems to work for me :))!<br>
<br>
Cheers,<br>
<br>
Mart<br>
<br>
On 09/08/2011 03:09 AM, psychesnet wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Amir,<br>
<br>
My source H264 and AAC are raw data, I try to packet it into mpegts by<br>
ffmpeg, but my issue is how to sync video and audio. In my research, I can<br>
use pts to sync video and audio, but I do not calculate the pts value on raw<br>
data resource. On the Internet, there are a lot of sample code about how to<br>
packet H264+AAC to mpegts, but the pts value is copied from original input<br>
file, no calculate function to do.<br>
So, my issue is how to calculate the pts under mpegts container.<br>
<br>
Thanks a lot.<br>
<br>
--<br>
View this message in context: <a href="http://libav-users.943685.n4.nabble.com/Re-Raw-H264-frames-in-mpegts-container-tp3602662p3797635.html" target="_blank">http://libav-users.943685.n4.<u></u>nabble.com/Re-Raw-H264-frames-<u></u>in-mpegts-container-<u></u>tp3602662p3797635.html</a><br>

Sent from the libav-users mailing list archive at Nabble.com.<br>
______________________________<u></u>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/<u></u>listinfo/libav-user</a><br>
</blockquote>
<br>
<br>
-- <br>
Mart van de Sanden | yellowBird<br>
<br>
yellowBird - See the world like never before<br>
Brugstraat 32 / 9711 HZ Groningen / The Netherlands<br>
<br>
M. (Mart) van de Sanden / Software Specialist<br>
<br>
T <a href="tel:%2B31%2050%208222%20822" value="+31508222822" target="_blank">+31 50 8222 822</a><br>
F <a href="tel:%2B31%2050%208501%20351" value="+31508501351" target="_blank">+31 50 8501 351</a><br>
E  <a href="mailto:mart.vandesanden@yb.nl" target="_blank">mart.vandesanden@yb.nl</a><br>
W <a href="http://www.yb.nl" target="_blank">http://www.yb.nl</a><br>
<br>
<br>
______________________________<u></u>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/<u></u>listinfo/libav-user</a><br>
</blockquote></div><br></div>