[Libav-user] MPEGTS and pts/dts

Andrey Utkin andrey.krieger.utkin at gmail.com
Fri Oct 28 21:09:56 CEST 2011


2011/10/28 RichardP <tuxbox.guru at gmail.com>:
> Hi all,
>
> I am trying to stream video from a stream and am having difficulty with
> PTS/DTS ... I just dont know where it is to be set is the simple question.
>
> I decode a video stream (DVB) and stream only the video and it works
> perfectly... when I add the audio I get the errors below and am a bit lost
> where things have got lost.
>
> I encode the same AVFrame that was returned by the _decode() function.. is
> this incorrect? (the video works) .. the Audio samples are encoded (but I
> assume there is no PTS information contained)
>
> Any hints to make this work.. as searching has shown many solutions that I
> really don't understand and what needs to be done.
>
> Best Regards,
> Richard
>
>
> [mpegts @ 0x24e5c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: 475200 >= -9223372036854775808
> [ 16:20:48 ] Pts/Dts -> 5640178740/5640178740
> [mpegts @ 0x24e5c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: 475200 >= -9223372036854775808
> [ 16:20:48 ] Pts/Dts -> 5640180900/5640180900
> [mpegts @ 0x24e5c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: 475200 >= -9223372036854775808

It could be better if you provide us with your sources and media sample.
Regarding audio transcoding and timestamping, recently i have been
enlighted by Justin Ruggles at #libav IRC channel:
http://pastebin.com/Kk7UX7qw
You should put decoded audio data to fifo, read it by (encoder's
frame_size)*num_channels*(av_get_bytes_per_sample(sample_fmt)) from
there, encode it, and calculate PTS by continuously increasing it by
delta.
Delta is to be calculated in this way:
delta = (encoder frame_size) * (out format time_base, for mpegts its
1/90000 ) / (encoder sample_rate)
The example of this is present in my code:
https://github.com/krieger-od/transcoder/blob/379ad41d5da32588d588a9640b9517fcff31647d/transcoder.c#L509

-- 
Andrey Utkin


More information about the Libav-user mailing list