将多张图像添加到视频流利的ffmpeg [英] Add multiple images to video fluent-ffmpeg

查看:66
本文介绍了将多张图像添加到视频流利的ffmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法在某个时间开始到某个时间结束时将单个图像添加到视频中,但是我找不到对多个图像执行此操作的方法.我使用fluent-ffmpeg.

I manage to add a single image to a video starting at a certain time and ending at a certain time, but I cannot find a way to do this for multiple images. I use fluent-ffmpeg.

这是我的代码:

ffmpeg('../videos/testklein.mp4')
     .input('../src/test.png')
     .input('../src/0.png')
     .input('../src/1.png')
     .addOptions([
        "-strict -2"
     ])

     .complexFilter([
        {
          filter: 'overlay',
          options: {
            x: 200,
            y: 200,
            enable: 'between(t,1,3)',

          }}, {
          filter: 'overlay',
          options: {
            x: 200,
            y: 200,
            enable: 'between(t,3,5)',
          }},
           {
          filter: 'overlay',
          options: {
             x: 200,
            y: 200,
            enable: 'between(t,5,7)',
          }
      },

    ])

我想我需要明确说明哪个过滤器应该获取哪个文件,但是我不确定该语法.

I suppose I need to explicitly state what filter should take what file, but I am not sure about the syntax for that.

推荐答案

这是正确的语法:第一个将输入[0:v] [1:v]和输出['tmp']相加然后添加['tmp']作为下一个的输入.对于2张图片:

This is the right syntax: The first one add inputs [0:v][1:v] and outputs ['tmp'] Then add ['tmp'] as inputs for the next one. For 2 images:

我可以添加任意数量的图像.将'tmp'作为第二个参数传递给complexFilter!

I can add as many images as I want. Pass the 'tmp' as 2nd argument to complexFilter!

(您当然可以将tmp更改为任何字符串)

(You can ofcourse change tmp to any string)

.complexFilter(
    [
      {
        "filter": "overlay",
        "options": {
          "enable": "between(t,2,4)",
          "x": "810",
          "y": "465"
        },
        "inputs": "[0:v][1:v]",
        "outputs": "tmp"
      },
      {
        "filter": "overlay",
        "options": {
          "enable": "between(t,13,14)",
          "x": "810",
          "y": "465"
        },
        "inputs": "[tmp][2:v]",
        "outputs": "tmp"
      }
    ], 'tmp')

这篇关于将多张图像添加到视频流利的ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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