将多个视频合并为一个 [英] Combine multiple videos into one

查看:360
本文介绍了将多个视频合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个视频:


  • 用摄像机拍摄的演讲


  • 和白板的视频

我想创建一个最终的视频,这三个组件占据了屏幕的某个区域。

I want to create a final video with those three components taking up a certain region of the screen.

是允许我这样做的开源软件(mencoder,ffmpeg,virtualdub ..)?你推荐哪个?

Is open-source software that would allow me to do this (mencoder, ffmpeg, virtualdub..)? Which do you recommend?

还是有一个C / C ++ API,可以让我以编程方式创建一些这样的东西?

Or is there a C/C++ API that would enable me to create something like that programmatically?

编辑
将来会有多个录音讲座。这意味着我需要一个通用/自动化的解决方案。

Edit
There will be multiple recorded lectures in the future. This means that I need a generic/automated solution.

我正在检查我是否可以用GStreamer编写一个应用程序来完成这项工作。有任何意见?

I'm currently checking out if I could write an application with GStreamer to do this job. Any comments on that?

已解决!

我用GStreamer的videomixer元素成功了。我使用gst-launch语法创建一个管道,然后使用gst_parse_launch加载它。这是实现复杂管道的一个非常有效的方式。

Solved!
I succeeded in doing this with GStreamer's videomixer element. I use the gst-launch syntax to create a pipeline and then load it with gst_parse_launch. It's a really productive way to implement complex pipelines.

这是一条管道,它需要两个传入的视频流和一个标志图像,将它们混合成一个流,并将其重复,以便它同时显示并保存到磁盘。

Here's a pipeline that takes two incoming video streams and a logo image, blends them into one stream and the duplicates it so that it simultaneously displayed and saved to disk.

  desktop. ! queue
           ! ffmpegcolorspace
           ! videoscale
           ! video/x-raw-yuv,width=640,height=480
           ! videobox right=-320
           ! ffmpegcolorspace
           ! vmix.sink_0
  webcam. ! queue
          ! ffmpegcolorspace
          ! videoscale
          ! video/x-raw-yuv,width=320,height=240
          ! vmix.sink_1
  logo. ! queue
        ! jpegdec
        ! ffmpegcolorspace
        ! videoscale
        ! video/x-raw-yuv,width=320,height=240
        ! vmix.sink_2
  vmix. ! t.
  t. ! queue
     ! ffmpegcolorspace
     ! ffenc_mpeg2video
     ! filesink location="recording.mpg"
  t. ! queue
     ! ffmpegcolorspace
     ! dshowvideosink
  videotestsrc name="desktop"
  videotestsrc name="webcam"
  multifilesrc name="logo" location="logo.jpg"
  videomixer name=vmix
             sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0
             sink_1::xpos=640 sink_1::ypos=0 sink_1::zorder=1
             sink_2::xpos=640 sink_2::ypos=240 sink_2::zorder=2
  tee name="t"


推荐答案

可以用ffmpeg来完成;我自己做了也就是说,它在技术上是复杂的。也就是说,再次,您可能使用的任何其他软件将以其核心本质来做。

It can be done with ffmpeg; I've done it myself. That said, it is technically complex. That said, again, it is what any other software you might use is going to do in its core essence.

该过程的工作原理如下:

The process works like this:


  1. 从源1到原始的Demux音频wav


    • 来自源2的Demux音频

    • 源3的Demux音频

    • 来自源1到MPEG1的Demux视频

    • 源2的Demux视频

    • 源3的Demux视频


    • 连接视频1 +视频2 +视频3

    • Mux音频123和视频123进入目标

    • 编码为目标格式

  1. Demux audio from source 1 to raw wav
    • Demux audio from source 2
    • Demux audio from source 3
    • Demux video from source 1 to MPEG1
    • Demux video from source 2
    • Demux video from source 3
    • Concatenate audio 1 + audio 2 + audio 3
    • Concatenate video 1 + video 2 + video 3
    • Mux audio 123 and video 123 into target
    • encode to target format

想想有什么惊喜,你可以从字面上连接两个原始的PCM wav音频文件,结果是有效的。真正令人惊讶的是,您可以使用MPEG1 / h.261视频来实现。

I think what surprises folks is that you can literally concatenate two raw PCM wav audio files, and the result is valid. What really, really surprises people is that you can do the same with MPEG1/h.261 video.

像我已经说过,我已经做到了。有一些细节被遗漏,但最明确的是。我的程序是用ffmpeg的bash脚本完成的。虽然我从来没有使用ffmpeg C API,但我不明白为什么你不能使用它来做同样的事情。

Like I've said, I've done it. There are some specifics left out, but it most definately works. My program was done in a bash script with ffmpeg. While I've never used the ffmpeg C API, I don't see why you could not use it to do the same thing.

这是一个高度教育性的项目如果你倾向于如果您的目标只是将一些视频一起拍下来,就可以使用GUI工具更好。

It's a highly educational project to do, if you are inclined. If your goal is just to slap some videos together for a one off project, then maybe using a GUI tool is a better idea.

这篇关于将多个视频合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆