我有四个视频,我想以 2x2 的方式平铺它们来制作一个新视频。 有没有一种方法可以轻松地做到这一点,最好是免费的并且在 Linux 下? 我愿意编写适量的程序,也许是为了与某些库交互,但不愿意自己编写整个视频处理程序。 您可以假设输入和输出视频采用最方便的常见格式。
gm montage 命令(用于图像)的类似物会很棒。
I have four videos that I would like to tile in a 2x2 fashion to make a new video. Is there a way I can do this easily, preferably free and under Linux? I am willing to program a moderate amount, perhaps in order to interact with some library, but unwilling to write an entire video-processing program myself. You may assume that the input and output videos are in whatever commonly-occurring format is most convenient.
An analogue of the gm montage command (for images) would be fantastic.
发布评论
评论(4)
我目前正在使用 GStreamer 进行类似的项目(讲座捕获)。 您可能正在寻找 videomixer 元素。 查看此示例:视频4路分屏gstreamer管道(脚本位于此处)。
GStreamer 在 Windows 上也能完美运行。 如果您感兴趣,您可能需要查看 GStreamer WinBuilds。
示例
这是一个在 Windows 上适用于我的基本脚本(它没有反斜杠,因为我使用 gst_parse_launch 从 C 代码调用以解析管道描述):
I am currently using GStreamer for a similar project (lecture-capture) myself. You are probably looking for the videomixer element. Check out this example: Video 4-way split screen gstreamer pipeline (script is located here).
GStreamer works perfectly fine on Windows too. You may want to check out the GStreamer WinBuilds if you are interested.
Example
Here's a basic script that works for me on Windows (it doesn't have the backslashes because I use the gst_parse_launch call from C code to parse the pipeline description):
以下 ffmpeg 命令将完全满足提问者的要求:
首先,pad 过滤器将第一个输入视频的大小加倍,将原始视频保留在左上角。 然后,串行覆盖过滤器将其他输入放置在填充过滤器添加的黑色填充上。
如果视频的分辨率不同,则命令将需要进行一些修改。
The following ffmpeg command will do exactly what the questioner wanted:
First, the pad filter doubles the size of the first input video, leaving the original video in the top-left corner. The serial overlay filters then place the other inputs over the the black padding added by the pad filter.
If the videos are of different resolutions, the command will require some modification.
这听起来像是 AviSynth 旨在解决的问题。
AviSynth 本质上是一种用于操作视频流的脚本语言。 文本文件描述您想要应用于一个或多个输入视频流的操作。 文本文件被传递给 AviSynth 引擎,该引擎提供一个虚拟 .AVI 文件,在您获取源流时一次一帧地对其进行操作。
将 AviSynth 与一个单独的工具结合起来,该工具从虚拟 .AVI 文件中读取数据并写入新文件以保存更改。
This sounds like the sort of problem that AviSynth was designed to solve.
AviSynth is essentially a scripting language for manipulating video streams. A text file describes that operations you want to apply to one or more input video streams. The text file is handed to the AviSynth engine, which provides a virtual .AVI file that manipulates the source streams one frame at a time as you fetch them.
Combine AviSynth with a separate tool that reads from the virtual .AVI file and writes to a new file to save the changes.
一种可能的解决方案是使用多媒体标记语言 SMIL 来描述视频蒙太奇的布局。 这需要一个用于编写 SMIL 文档的文本编辑器和一个 SMIL 视频播放器(例如,Ambulant、Quicktime 或 Realplayer )用于显示它。
One possible solution would be to describe the layout of your video montage with SMIL, a multimedia markup language. This requires a text editor for writing your SMIL document and a SMIL video player (e.g., Ambulant, Quicktime or Realplayer) for displaying it.