[FFmpeg-user] Mpegts timing issues?

Mike Scheutzow mike.scheutzow at alcatel-lucent.com
Fri Apr 13 16:03:57 CEST 2012

Daniel Price wrote:
> Hi Everyone;
>  Thanks in advance to anyone that can help with this.
> I have a set top box based on embedded code that I have to treat as a black
> box. It's capable of playing an h.264/aac stream in an mpeg transport
> stream. Normally we use a specific type of encoder to make streams for it.
> I am trying to transcode files using ffmpeg, that are then multicast onto
> the network, which this STB ingests, decodes, and plays to a TV. I've
> gotten it *extremely* close to working, but I'm left with one standing
> issue. The audio plays at the wrong frequency, and it stutters. 

The stutter is likely the result of the audio PES packet being too 
large. Latest git has a (new?) option named pes_packet_size. If you set 
this to 0, the muxer looks like it will output each individual audio 
frame rather than accumulating a bunch of them and sending them all 
together. I've never tried this option, so I don't know if it actually 

If the option doesn't work, you'll have to modify the mpegtsenc.c file. 
Try changing DEFAULT_PES_HEADER_FREQ to 1.

The "plays at the wrong frequency" sounds like a different problem. 
Maybe your decoder is trying to compensate for audio buffer underrun in 
some weird way. If you're lucky, it will go away when you fix the pes 
packet size problem.

> ... I've been comparing
> against a reference TS stream that I know works, which has valid PTS values
> on the audio PID, on the PES packets. I'm checking the working against the
> non-working streams in Elecard's Stream Analyzer, and this is the major
> discrepancy that I've come up with. In my reference (working) stream, a PES
> packet is delivered every ~20ms. In the other, ~300ms.
> ...
>  ffmpeg -y -i sintel_trailer-1080p.mp4 -f mpegts -vcodec libx264
> -bufsize 4M -maxrate 3000k -bf 0 -g 60 -keyint_min 20 -coder 0 -acodec aac
> -ab 128k -ar 48k -strict experimental linux_ffmpeg/sintel_trailer2.ts

You're aware the built-in aac encoder has terrible audio quality, right? 
It sounds terrible.

Mike Scheutzow

More information about the ffmpeg-user mailing list