Body: <p>This code compose 3 mp4 into 1 with ffmepg, it works, but there is no animation:</p>
  <pre><code>ffmpeg()
                      .input(`./media/001.mp4`)
                      .inputFormat('mp4')
                      .input(`/tmp/looped_video.mp4`)
                      .inputFormat('mp4')
                      .input(`./media/003.mp4`)
                      .inputFormat('mp4')
                      .noAudio()
                      .videoCodec('libx264')
                      .format('mp4')
                      .complexFilter([
                          '[0]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          `[v0][v1][v2]concat=n=3:v=1:a=0`,
                      ])
                      .outputOptions([
                          '-tune animation',
                          '-loop 1',
                          '-profile:v baseline',
                          '-level 3.0',
                          '-preset medium',
                          '-threads 4',
                      ])
                      .output(`/tmp/output.mp4`)
                      .on('end', () =&gt; {
                          console.log('MP4 video generated')
                          const endTime = Date.now()
                          console.log(
                              `FFmpeg took ${endTime - startTime} milliseconds to render.`
                          )
                      })
                      .on('error', (e) =&gt; {
                          console.log(e)
                      })
                      .run()
  </code></pre>
  <p>I tried adding animation like this</p>
  <pre><code>ffmpeg()
                      .input(`./media/001.mp4`)
                      .inputFormat('mp4')
                      .input(`/tmp/looped_video.mp4`)
                      .inputFormat('mp4')
                      .input(`./media/003.mp4`)
                      .inputFormat('mp4')
                      .noAudio()
                      .videoCodec('libx264')
                      .format('mp4')
                      .complexFilter([
                          '[0]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          '[0:v][1:v]crossfade=duration=1[faded]',
                          `[faded][v2]concat=n=3:v=1:a=0`,
                      ])
                      .outputOptions([
                          '-tune animation',
                          '-loop 1',
                          '-profile:v baseline',
                          '-level 3.0',
                          '-preset medium',
                          '-threads 4',
                          '-map [faded]',
                      ])
                      .output(`/tmp/output.mp4`)
                      .on('end', () =&gt; {
                          console.log('MP4 video generated')
                          const endTime = Date.now()
                          console.log(
                              `FFmpeg took ${endTime - startTime} milliseconds to render.`
                          )
                      })
                      .on('error', (e) =&gt; {
                          console.log(e)
                      })
                      .run()
  </code></pre>
  <p>but it raise an error:</p>
  <pre><code>yarn run dev
  yarn run v1.22.19
  $ ts-node index.ts
  MP4 video generated
  FFmpeg took 2063 milliseconds to render.
  Error: ffmpeg exited with code 1: Error initializing complex filters.
  Invalid argument
  
      at ChildProcess.&lt;anonymous&gt; (/Users/janoskukoda/Workspace/test/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
  </code></pre>
  <hr />
  <p>I tried <code>xfade</code> filter also, but raise an error:</p>
  <pre><code>.complexFilter([
                          '[0:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          `[v0][v1]xfade=duration=1:offset=3:crossfade=1[xf0]`,
                          `[xf0][v2]xfade=duration=1:offset=3:crossfade=1[out]`,
                      ])
  </code></pre>
  <blockquote>
  <p>Error: ffmpeg exited with code 1: Error initializing complex filters.
  Option not found</p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-11T04:05:28.080Z
Comments.Text: You will need to use the xfade filter: http://www.ffmpeg.org/ffmpeg-filters.html#xfade
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-11T04:35:31.273Z
Comments.Text: I tried `xfade` filter also, but raise an error, would you look at my post?
Comments.UserDisplayName: János
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-11T05:35:25.903Z
Comments.Text: See the syntax in the example: http://www.ffmpeg.org/ffmpeg-filters.html#Examples-137
Comments.UserDisplayName: Gyan
Tags: <ffmpeg>
Title: How to make animation when composing mp4 with ffmpeg?
UserDisplayName: János
ThreadText: # How to make animation when composing mp4 with ffmpeg?
  
  (Asked by: username_0 on 2023-02-10)
  
  This code compose 3 mp4 into 1 with ffmepg, it works, but there is no animation:
  
  ```
  ffmpeg()
                      .input(`./media/001.mp4`)
                      .inputFormat('mp4')
                      .input(`/tmp/looped_video.mp4`)
                      .inputFormat('mp4')
                      .input(`./media/003.mp4`)
                      .inputFormat('mp4')
                      .noAudio()
                      .videoCodec('libx264')
                      .format('mp4')
                      .complexFilter([
                          '[0]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          `[v0][v1][v2]concat=n=3:v=1:a=0`,
                      ])
                      .outputOptions([
                          '-tune animation',
                          '-loop 1',
                          '-profile:v baseline',
                          '-level 3.0',
                          '-preset medium',
                          '-threads 4',
                      ])
                      .output(`/tmp/output.mp4`)
                      .on('end', () => {
                          console.log('MP4 video generated')
                          const endTime = Date.now()
                          console.log(
                              `FFmpeg took ${endTime - startTime} milliseconds to render.`
                          )
                      })
                      .on('error', (e) => {
                          console.log(e)
                      })
                      .run()
  
  ```
  
  I tried adding animation like this
  
  ```
  ffmpeg()
                      .input(`./media/001.mp4`)
                      .inputFormat('mp4')
                      .input(`/tmp/looped_video.mp4`)
                      .inputFormat('mp4')
                      .input(`./media/003.mp4`)
                      .inputFormat('mp4')
                      .noAudio()
                      .videoCodec('libx264')
                      .format('mp4')
                      .complexFilter([
                          '[0]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          '[0:v][1:v]crossfade=duration=1[faded]',
                          `[faded][v2]concat=n=3:v=1:a=0`,
                      ])
                      .outputOptions([
                          '-tune animation',
                          '-loop 1',
                          '-profile:v baseline',
                          '-level 3.0',
                          '-preset medium',
                          '-threads 4',
                          '-map [faded]',
                      ])
                      .output(`/tmp/output.mp4`)
                      .on('end', () => {
                          console.log('MP4 video generated')
                          const endTime = Date.now()
                          console.log(
                              `FFmpeg took ${endTime - startTime} milliseconds to render.`
                          )
                      })
                      .on('error', (e) => {
                          console.log(e)
                      })
                      .run()
  
  ```
  
  but it raise an error:
  
  ```
  yarn run dev
  yarn run v1.22.19
  $ ts-node index.ts
  MP4 video generated
  FFmpeg took 2063 milliseconds to render.
  Error: ffmpeg exited with code 1: Error initializing complex filters.
  Invalid argument
  
      at ChildProcess.<anonymous> (/Users/janoskukoda/Workspace/test/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
  
  ```
  
  ---
  
  I tried `xfade` filter also, but raise an error:
  
  ```
  .complexFilter([
                          '[0:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v0]',
                          '[1:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v1]',
                          `[2:v]pad=1080:1080:-1:-1,setsar=1,fps=30,format=yuv420p[v2]`,
                          `[v0][v1]xfade=duration=1:offset=3:crossfade=1[xf0]`,
                          `[xf0][v2]xfade=duration=1:offset=3:crossfade=1[out]`,
                      ])
  
  ```
  
  > Error: ffmpeg exited with code 1: Error initializing complex filters.
  > Option not found
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: You will need to use the xfade filter: http://www.ffmpeg.org/ffmpeg-filters.html#xfade  
  > **username_0**: I tried `xfade` filter also, but raise an error, would you look at my post?  
  > **username_1**: See the syntax in the example: http://www.ffmpeg.org/ffmpeg-filters.html#Examples-137  
  
  ---
  
  ## 0 answers
  
  