[FFmpeg-devel] H264 encoding and RTP muxing - calculating pts and dts

Dominik Tomczak dominiktomczak
Wed Jul 21 10:29:40 CEST 2010


Does H264 encoder generate timestams (pts and dts)? How to set those two
values? Taking the sample output-example.c I can see the code:

if (c->coded_frame->pts != AV_NOPTS_VALUE)
                pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base,
st->time_base);

but c->coded_frame->pts, c->time_base, st->time_base are always constant, I
checked. So it means, thet the pts is always the same so the VLC decoder
show only 1st frame.


Regards


On Tue, Jul 20, 2010 at 1:35 PM, Luca Abeni <lucabe72 at email.it> wrote:

> Hi,
>
> I think this is a libav-user question, anyway...
>
> On 07/20/2010 12:56 PM, Dominik Tomczak wrote:
>
>> Hello
>>
>> My application uses libav libaries to encode frames with H264 and mux them
>> using RTP. The sequence is
>>
>> int encodedBytes = avcodec_encode_video
>> if (encodedBytes>  0)
>> {
>> AVPacket packet;
>> ...
>>
>> av_interleaved_write_frame(&packet)
>> }
>>
>> I get the video frames in RGB from my web camera, convert it to YUV but I
>> don't know how to set DTS and PTS values for packet.
>>
> You can use the video4linux2 input, and it will generate proper timestamps
> for the input frames; then, the H264 encoder will generate proper PTSs and
> DTSs based on the input timestamps, and you can use them for the RTP muxer.
>
> This basically is what ffmpeg.c does, and it works fairly well (just
> tested).
>
>
>                                Luca
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>



-- 
Dominik Tomczak
Software Engineer
www.dominiktomczak.com



More information about the ffmpeg-devel mailing list