nicholaswmin
nicholaswmin

Reputation: 22939

Specify start time of video when creating ffmpeg mosaic

I'm trying to create a mosaic video by combining recordings of video streams for a WebRTC call application. Each recording is made up of 2 files, it's .mkv video and it's .mka audio.

The problem I'm facing is that each recording starts at a different time. A participant might have started the call and is recording himself while the 2nd participant joins after 1 minute.

For example, Recording 1 starts at 1657135694178 while Recording 2 starts at 1657135711762, both being Unix timestamps.

This is what I currently do to create the mosaic:

$ ffmpeg 
  -i video-1.mkv 
  -i audio-1.mka 
  -i video-2.mkv 
  -i audio-2.mka 
  -filter_complex 
  vstack=inputs=2 
  output-1.mkv

Upvotes: 0

Views: 354

Answers (1)

kesh
kesh

Reputation: 5463

Use tpad filter to insert blank frames like this:

ffmpeg -i video-1.mkv -i video-2.mkv -filter_complex \
  "[0:v]tpad=start_duration=1[v1];\
   [1:v]tpad=start_duration=2[v2];\
   [v1][v2]vstack=inputs=2" \
  out.mkv

The first frame of the first input starts showing at output time = 1s and 2nd input's first frame to appear at time t=2.

Upvotes: 1

Related Questions