[FFmpeg-user] hstack a video with a delayed version of itself

Moritz Barsnick barsnick at gmx.net
Wed Aug 14 16:01:16 EEST 2019


Hi Michael,

On Wed, Aug 14, 2019 at 14:36:08 +0200, Michael Koch wrote:
> I want to hstack a video with a delayed version of itself.
[...]
> ffmpeg -f lavfi -i testsrc2=size=600x400:duration=10 -filter_complex
> split[1][2];[2]trim=start=4,setpts=PTS-4[3];[1][3]hstack=shortest=1 -y
> test3.mp4
>
> This produces a video of 6 seconds length. But both clocks are running
> synchronously from 4 to 10. I would have expected that one clock runs
> from 0 to 6 and the other from 4 to 10.

Without actually trying to reproduce, there is one obvious (to me)
error in your command line:

> setpts=PTS-4[3]

This isn't doing what you expect it to. PTS is in "ticks", i.e. certain
incremental units, but normally not in seconds. That timebase is
"1/TB". TB is what you see as "tbn" (or "tbc"? doesn't matter) here:

> [SAR 1:1 DAR 3:2], 25 tbr, 25 tbn, 25 tbc

and here:

>      Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1200x400 [SAR 1:1 DAR 3:1], q=-1--1, 25 fps, 12800 tbn, 25 tbc

The setpts docs have this example:
  • Apply an offset of 10 seconds to the input PTS:
      setpts=PTS+10/TB

So likely you need to use:
> setpts=PTS-4/TB[3]

Hope this helps,
Moritz


More information about the ffmpeg-user mailing list