多个视频源合二为一 [英] Multiple video sources combined into one
问题描述
我正在寻找一种有效的方法来执行以下操作:
I am looking for an efficient way to do the following:
使用多个源视频(长度大致相同),我需要生成一个输出视频,该视频由所有在其自己区域中运行的原始源组成(例如一堆 PIP 有几种不同的尺寸).所以,最终的结果是所有的原件都是并排运行的,每个都在自己的区域/盒子里.
Using several source videos (of approximately the same length), I need to generate an output video that is composed of all of the original sources each running in its own area (like a bunch of PIPs in several different sizes). So, the end result is that all the original are running side-by-side, each in its own area/box.
源和输出必须是 flv
并且我使用的平台是 Windows(在 Windows 7 64 位上开发,部署到 Windows Server 2008).
The source and output need to be flv
and the platform I am using is Windows (dev on Windows 7 64bit, deployment to Windows server 2008).
我查看了 avisynth 但不幸的是它无法处理 flv
和非插件和我试过的 flv 分离器.
I have looked at avisynth but unfortunately it can't handle flv
and non of the plugins and flv splitters I have tried worked.
我目前的流程使用 ffmpeg 的方式如下:
My current process uses ffmpeg in the following manner:
- 使用 ffmpeg 为每个视频每秒生成 25 个 png,并根据需要调整原始大小.
- 使用
System.Drawing
命名空间将每组帧组合成一个新图像,从静态背景开始,然后将每个帧加载到Image
并绘制到背景Graphics
对象 - 这给了我组合的框架. - 使用 ffmpeg 将生成的图像组合成视频.
- Use ffmpeg to generate 25 png's per second per video, resizing the original as needed.
- Use the
System.Drawing
namespace to combine each set of frames into a new image, starting with a static background, then loading each frame into anImage
and drawing to the backgroundGraphics
object - this gives me the combined frames. - Use ffmpeg to combine the generated images to a video.
所有这些都是非常 IO 密集型的(这是我目前的处理瓶颈),我觉得必须有一种更有效的方法来实现我的目标.我在视频处理方面没有太多经验,也不知道有哪些选择.
All this is very IO intensive (which is my processing bottleneck at the moment) and I feel there must be a more efficient way to reach my goal. I do not have much experience with video processing, and don't know what options are out there.
谁能提出更有效的处理方法?
Can anyone suggest a more efficient way of processing these?
推荐答案
在 ffmpeg 中做所有事情.您可以使用 视频过滤器 做很多事情.例如并排加入两个视频:
Do everything inside ffmpeg. You can do a lot of things with video filters. For example to join two videos side by side:
ffmpeg -i input0.avi -vf "movie=input1.avi [in1]; [in]pad=640*2:352[in0]; [in0][in1] overlay=640:0 [out]" out.avi
@Oded:这基本上就是这个命令的作用.您可以移除 pad
过滤器并更改 overlay
过滤器的参数以将第二个视频移动到您喜欢的任何位置.
@Oded: That's basically what this command does. You can remove the pad
filter and change the parameters of overlay
filter to move the second video wherever you like.
ffmpeg -i big.avi -vf "movie=small.avi [small]; [in][small] overlay=10:10 [out]" out.avi
我提供的链接描述了过滤器语法.您可以将多个过滤器链接在一起:
The link I provided describes the filter syntax. You can chain multiple filters together:
ffmpeg -i big.avi -vf "movie=small0.avi [small0]; [in][small0] overlay=10:10 [tmp];
movie=small1.avi [small1]; [tmp][small1] overlay=30:10 [out]" out.avi
这篇关于多个视频源合二为一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!