用ffmpeg覆盖视频 [英] 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.
这是我正在做的: p>
Here's what I'm doing:
-
将左视频展开到最终的视频维度
Expand the left video to the final video dimensions
ffmpeg -i left.avi -vfpad = 640:240:0:0:blackleft_wide.avi
ffmpeg -i left.avi -vf "pad=640:240:0:0:black" left_wide.avi
在左上方覆盖正确的视频
Overlay the right video on top of the left one
ffmpeg -i left_wide.avi -vfmovie = right.avi [mv]; [in] [mv] overlay = 320:0combined_video.avi
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?
推荐答案
像用户65Fbef05所说,两个视频必须相同帧速率
使用-f帧率和帧率必须在两个视频中相同。
要查找帧率使用:
ffmpeg -i video1
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
ffmpeg -i video2
并查找包含Stream#0.0:Video:的行
在那条线上你会发现在电影中的fps。
and look for the line which contains "Stream #0.0: Video:"
on that line you'll find the fps in movie.
另外我不知道通过混合2个音轨将遇到什么问题。
从我的角度来看,我将尝试使用电影中的音频,将覆盖
,并放弃其余的。
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.
这篇关于用ffmpeg覆盖视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!