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

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

问题描述

我有三个视频:


  • 用摄像机拍摄的讲座


  • 和电子白板视频

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

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.

这个过程如下:


  1. Demux音频从源1到raw wav

  2. 来自源2的Demux音频

  3. 来自源3的Demux音频

  4. Demux视频从源1 MPEG1

  5. 从来源2的Demux视频

  6. 从来源3的Demux视频

  7. 连接音频1 +音频2 + audio 3

  8. 连接视频1 +视频2 +视频3

  9. 将Mux音频123和视频123合并到目标

  10. 编码为目标格式

  1. Demux audio from source 1 to raw wav
  2. Demux audio from source 2
  3. Demux audio from source 3
  4. Demux video from source 1 to MPEG1
  5. Demux video from source 2
  6. Demux video from source 3
  7. Concatenate audio 1 + audio 2 + audio 3
  8. Concatenate video 1 + video 2 + video 3
  9. Mux audio 123 and video 123 into target
  10. 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.

像我说的,我做到了。有一些细节遗漏,但它最确定的工作。我的程序是在一个bash脚本与ffmpeg。虽然我从来没有使用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天全站免登陆