[FFmpeg-devel] mpegtsenc: add option to define a timestamp offset

Nicolas George nicolas.george at normalesup.org
Mon Apr 1 17:51:45 CEST 2013

Le quartidi 4 germinal, an CCXXI, Harald Axmann a écrit :
> I did a little debugging on this issue. As far as I understand it,
> the mpegts encoder will always create its own time base from the
> picture number. So the original timestamp and every offset added to
> it in some filter get lost anyway. Furthermore setpts is a video

A few tests I ran seem to confirm that, except you use the wrong vocabulary:
time base, in the world of audio-video formats, means the basic unit used to
express timestamps. For example, MPEG-TS always uses a 1/90000 s time base,
which means that all timestamps are expressed an integral number of
1/90000 s period; Matroska usually uses 1/1000: all timestamps are integral
number of milliseconds, etc.

>				     Furthermore setpts is a video
> only filter (intended for changing the speed), so it cannot be used
> to shift streams containing video and audio.

That is true. The basic reason for that is that it is not possible to just
change the timestamps of an audio stream: the samples have to match without
gap. In fact, a lot of tools just ignore the timestamps for audio and count
the samples instead.

> Hence AFAIK current ffmpeg doesn't provide a solution for mpegts
> timestamp shifting. From that point of view the option seems like a
> good idea to me again. Of course it is specific to mpegts. But is
> timestamp shifting necessary for all encoders? If we want to
> implement it for all formats, a change in every single encoder might
> be necessary, because they all can have some specialties (like PCR
> in TS). On the other hand the provided solution is small, local and
> free of side effects. It just adds a feature to mpegts, where it is
> obviously currently needed.

IMHO, there are two completely different issues here, and mixing them seems
like a bad idea.

The first issue is the lack of a tool to adjust the timestamps of all
streams by a simple offset: as you said, setpts can do that but only for
video. But, as someone pointed out, it seems that -itsoffset can do exactly

The second issue is the MPEG-TS muxer ignoring the timestamps of the packets
it gets: unless there is a reason for it that I do not know, it is a bug, no
more no less.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130401/a1725f33/attachment.asc>

More information about the ffmpeg-devel mailing list