Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlaying video with ffmpeg

I'm attempting to write a script that will merge 2 separate video files into 1 wider one, in which both videos play back simultaneously. I have it mostly figured out, but when I view the final output, the video that I'm overlaying is extremely slow.

Here's what I'm doing:

  1. Expand the left video to the final video dimensions

    ffmpeg -i left.avi -vf "pad=640:240:0:0:black" left_wide.avi

  2. Overlay the right video on top of the left one

    ffmpeg -i left_wide.avi -vf "movie=right.avi [mv]; [in][mv] overlay=320:0" combined_video.avi

In the resulting video, the playback on the right video is about half the speed of the left video. Any idea how I can get these files to sync up?

like image 722
elee Avatar asked Nov 13 '22 23:11

elee


1 Answers

Like the user 65Fbef05 said, the both videos must have the same framerate
use -f framerate and framerate must be the same in both videos.
To find the framerate use:
ffmpeg -i video1

ffmpeg -i video2

and look for the line which contains "Stream #0.0: Video:"
on that line you'll find the fps in movie.

Also I don't know what problems you'll encounter by mixing 2 audio tracks.
From my part I will try to use the audio from the movie which will be overlayed
over and discard the rest.

like image 101
user898297 Avatar answered Dec 10 '22 14:12

user898297