[FFmpeg-user] Understanding the behavior of "-ss/-t" option

Gyan gyandoshi at gmail.com
Fri Sep 8 15:04:53 EEST 2017


On Fri, Sep 8, 2017 at 3:40 PM, Nicolas George <george at nsup.org> wrote:


> No, it does not work that way without copyts: without copyts, the
> timestamps always start at 0.
>

There are two issues: a) how to interpret input frame seek point, and b)
what happens to timestamps of selected frames.

Illustration
---------------

Generate source

    ffmpeg -f lavfi -i testsrc2 -t 2 -output_ts_offset 1 src.mp4

As per ffprobe, this gives a file with

    Duration: 00:00:02.00, start: 1.000000, bitrate: 277 kb/s


Running

        ffmpeg -seek_timestamp 1 -ss 2 -i src.mp4 ss-seekts2.mp4

produces, as per ffprobe,

      Duration: 00:00:01.00, start: 0.000000, bitrate: 276 kb/s

The frames in output were taken from TS 2 to 3 of src.mp4, testsrc2 frame
counter in first frame says '25'. TS in output is reset to 0 start. As
expected.


Running

        ffmpeg -seek_timestamp 1 -copyts -ss 2 -i src.mp4
copyts-seekts-ss2.mp4

produces an empty file. It's the same command as above, but with copyts
added.


Running

        ffmpeg -seek_timestamp 1 -copyts -ss 1 -i src.mp4
copyts-seekts-ss1.mp4

produces a file, reported as,

  Duration: 00:00:01.00, start: 2.000000, bitrate: 276 kb/s

whose video contents correspond to TS 2 to 3 of src.mp4, (frame counter
25).  'ss' acts as relative offset, and is apparently immune to
seek_timestamp. Source timestamps are copied over to output.


More information about the ffmpeg-user mailing list