Add multiple images to video fluent-ffmpeg

心不动则不痛 提交于 2020-12-29 08:42:38

问题


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.

This is the code I have:

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.


回答1:


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:

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

(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')


来源:https://stackoverflow.com/questions/48157766/add-multiple-images-to-video-fluent-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!