[Libav-user] Raw H264 frames in mpegts container

Eric Hsieh(Psychesnet) psychesnet at gmail.com
Tue Sep 13 08:12:59 CEST 2011

Dear Mart,

Thanks your reply, but your suggestion is not work.
I try to use the following function to get pts,

pkt.pts = av_rescale_q(packet->**timestamp().microseconds(),
(AVRational){1,1000000}, stream_context->time_base);

the vlc will buffering the data and always show "Buffering 0%" on debug
message window.
On the other hand, I always fill pts = 0 to ffmpeg when it write video and
audio packet.
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
Does anyone have ideal to resolve this issue, please help me. Thanks a lot.

Regards, Eric Hsieh, 09/13

2011/9/9 Mart <mart.vandesanden at yb.nl>

> 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:
>    pkt.pts = av_rescale_q(packet->**timestamp().microseconds(),
> (AVRational){1,1000000}, stream_context->time_base);
> 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.
> I hope this helps (and that it is correct, it seems to work for me :))!
> Cheers,
> Mart
> On 09/08/2011 03:09 AM, psychesnet wrote:
>> Hello Amir,
>> My source H264 and AAC are raw data, I try to packet it into mpegts by
>> ffmpeg, but my issue is how to sync video and audio. In my research, I can
>> use pts to sync video and audio, but I do not calculate the pts value on
>> raw
>> data resource. On the Internet, there are a lot of sample code about how
>> to
>> packet H264+AAC to mpegts, but the pts value is copied from original input
>> file, no calculate function to do.
>> So, my issue is how to calculate the pts under mpegts container.
>> Thanks a lot.
>> --
>> View this message in context: http://libav-users.943685.n4.**
>> nabble.com/Re-Raw-H264-frames-**in-mpegts-container-**
>> tp3602662p3797635.html<http://libav-users.943685.n4.nabble.com/Re-Raw-H264-frames-in-mpegts-container-tp3602662p3797635.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<http://ffmpeg.org/mailman/listinfo/libav-user>
> --
> Mart van de Sanden | yellowBird
> yellowBird - See the world like never before
> Brugstraat 32 / 9711 HZ Groningen / The Netherlands
> M. (Mart) van de Sanden / Software Specialist
> T +31 50 8222 822
> F +31 50 8501 351
> E  mart.vandesanden at yb.nl
> W http://www.yb.nl
> ______________________________**_________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/**listinfo/libav-user<http://ffmpeg.org/mailman/listinfo/libav-user>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110913/05121a62/attachment.html>

More information about the Libav-user mailing list