使用 ffmpeg 叠加视频
我正在尝试编写一个脚本,将 2 个独立的视频文件合并为 1 个更宽的视频文件,其中两个视频同时播放。我已经基本弄清楚了,但是当我查看最终输出时,我叠加的视频非常慢。
这就是我正在做的事情:
将左侧视频扩展到最终视频尺寸
ffmpeg -i left.avi -vf "pad=640:240:0:0:black" left_wide.avi
将右侧视频叠加在左侧视频之上
ffmpeg -i left_wide.avi -vf "movie=right.avi [mv]; [in][mv]overlay=320:0"combined_video.avi
在生成的视频中,在右侧视频的速度约为左侧视频的一半。知道如何让这些文件同步吗?
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:
Expand the left video to the final video dimensions
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 -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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如用户 65Fbef05 所说,两个视频必须具有相同的帧率
使用 -f 帧速率并且两个视频中的帧速率必须相同。
要查找帧速率,请使用:
ffmpeg -i video1
ffmpeg -i video2
并查找包含“Stream #0.0: Video:”的行
在那条线上,您会找到电影中的 fps。
另外,我不知道混合 2 个音轨会遇到什么问题。
从我的角度来看,我将尝试使用电影中将被覆盖的音频
结束并丢弃其余的。
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.