[FFmpeg-user] Encode to timestamp on ts with "holes"

Gabriele Greco gabrielegreco at gmail.com
Wed Mar 6 15:31:49 EET 2019

2019-03-05 12:31 GMT+01:00, Gabriele Greco <gabrielegreco at gmail.com>:

> so after reading ffmpeg documentation and various stackoverflow questions
> decided that copyts was my friend to achieve my result and I tried:
> ffmpeg -ss start_ts -copyts -i input.ts -to end_ts out.mp4
> ffmpeg -ss start_ts -i input.ts -copyts -to end_ts out.mp4

> Use "-async 1" instead of copyts imo.
> Or do you mean timestamp resets? There is a (big) difference...

No -async 1 does not do the trick.

What I want to achieve is that if:

start_ts = 00:01:00
end_ts =  00:05:00

and input.ts has one or more "holes" for a total of 2 minutes

my output video should last 2 minutes and not 4.

Using -async = 1 my video still lasts 4 minutes (or 5 if i do not subtract
start_ts from end_ts in the -to option), since the -to option is applied to
the output video timestamp.

-ss has a different behaviour is specified before or after the input file,
but -to has not, both if I specify it before -i and after I get a video
that is exactly long as end_ts - start_ts, that, if holes are present in
the source file is far beyond the "final" timestamp in the input.

It seems to work like if -to is a wrapper around "-t duration", rather than
a radically different implementation.


More information about the ffmpeg-user mailing list