Answers.Body: <p>Here's the combined command,</p>
  
  <pre><code>ffmpeg \
  -i 1.jpg \
  -i 2.jpg \
  -i 3.jpg \
  -i 4.jpg \
  -i 'audio.mp3' \
  -i 'logo.png' \
  -filter_complex \
  "[0:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1[v0]; \
   [1:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
   [2:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
   [3:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
   [v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p,scale=800:450,setsar=1[v]; \
   [v][5]overlay=25:25,drawbox=y=ih-80:color=#ef2626@0.8:width=iw:height=80:t=fill,drawtext=text='This is a testing text example.':expansion=normal:y=h-line_h-20:x='if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))':fontfile='Lora/Lora-Regular.ttf':fontcolor=white: fontsize=40" \
  -c:a copy -shortest ./out_fade.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-02T16:14:55.123Z
Answers.Text: Thanks this worked like a charm.
Answers.UserDisplayName: Imran Khan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-02T09:09:50.723Z
Answers.LastActivityDate: 2019-10-02T09:09:50.723Z
Answers.UserDisplayName: Gyan
Body: <p>I am generating video using ffmpeg by combining images, audio, logo and some text sliding from right to left. Currently I am using four different ffmpeg commands to complete my video generation process.</p>
  
  <p>Command 1: Below command combines the images and output a video with desired animation </p>
  
  <pre><code>ffmpeg \
  -t 5 -i 1.jpg \
  -t 5 -i 2.jpg \
  -t 5 -i 3.jpg \
  -t 5 -i 4.jpg \
  -filter_complex \
  "[0:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1[v0]; \
   [1:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
   [2:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
   [3:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
   [v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p[v]" -map "[v]" -s "800x450" ./out_fade.mp4
  </code></pre>
  
  <p>Command number 2: Then I use this 2nd command to add audio to my video.</p>
  
  <pre><code>ffmpeg -i 'input_video.mp4' -i 'audio.mp3' -codec copy -shortest video_out.mp4
  </code></pre>
  
  <p>Command number 3: This is used to add logo to my video on top left location.</p>
  
  <pre><code>ffmpeg -i 'input_video.mp4' -i 'logo.png' -filter_complex "[0:v][1:v] overlay=25:25" -pix_fmt yuv420p -c:a copy 'video_out.mp4'
  </code></pre>
  
  <p>Command number 4: This is used to add the sliding text in a red box at the bottom of the video screen.</p>
  
  <pre><code>ffmpeg -i video_input.mp4 -vf "drawbox=y=ih-80:color=#ef2626@0.8:width=iw:height=80:t=fill,drawtext=text='This is a testing text example.':expansion=normal:y=h-line_h-20:x='if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))':fontfile='Lora/Lora-Regular.ttf':fontcolor=white: fontsize=40" video_final.mp4
  </code></pre>
  
  <p>This process is slow I think and I am thinking is it possible I can combine these 4 processes into one or at least reduce it to two commands?</p>
  
Tags: <video><ffmpeg>
Title: ffmpeg video generation process optimization
UserDisplayName: Imran Khan
ThreadText: # ffmpeg video generation process optimization
  
  (Asked by: username_0 on 2019-10-01)
  
  I am generating video using ffmpeg by combining images, audio, logo and some text sliding from right to left. Currently I am using four different ffmpeg commands to complete my video generation process.
  
  Command 1: Below command combines the images and output a video with desired animation
  
  ```
  ffmpeg \
  -t 5 -i 1.jpg \
  -t 5 -i 2.jpg \
  -t 5 -i 3.jpg \
  -t 5 -i 4.jpg \
  -filter_complex \
  "[0:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1[v0]; \
   [1:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
   [2:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
   [3:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
   [v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p[v]" -map "[v]" -s "800x450" ./out_fade.mp4
  
  ```
  
  Command number 2: Then I use this 2nd command to add audio to my video.
  
  ```
  ffmpeg -i 'input_video.mp4' -i 'audio.mp3' -codec copy -shortest video_out.mp4
  
  ```
  
  Command number 3: This is used to add logo to my video on top left location.
  
  ```
  ffmpeg -i 'input_video.mp4' -i 'logo.png' -filter_complex "[0:v][1:v] overlay=25:25" -pix_fmt yuv420p -c:a copy 'video_out.mp4'
  
  ```
  
  Command number 4: This is used to add the sliding text in a red box at the bottom of the video screen.
  
  ```
  ffmpeg -i video_input.mp4 -vf "drawbox=y=ih-80:color=#ef2626@0.8:width=iw:height=80:t=fill,drawtext=text='This is a testing text example.':expansion=normal:y=h-line_h-20:x='if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))':fontfile='Lora/Lora-Regular.ttf':fontcolor=white: fontsize=40" video_final.mp4
  
  ```
  
  This process is slow I think and I am thinking is it possible I can combine these 4 processes into one or at least reduce it to two commands?
  
  **Tags:** video, ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-02. Score: 0 | Accepted answer
  
  Here's the combined command,
  
  ```
  ffmpeg \
  -i 1.jpg \
  -i 2.jpg \
  -i 3.jpg \
  -i 4.jpg \
  -i 'audio.mp3' \
  -i 'logo.png' \
  -filter_complex \
  "[0:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=out:st=4:d=1[v0]; \
   [1:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
   [2:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
   [3:v]zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
   [v0][v1][v2][v3]concat=n=4:v=1:a=0,format=yuv420p,scale=800:450,setsar=1[v]; \
   [v][5]overlay=25:25,drawbox=y=ih-80:color=#ef2626@0.8:width=iw:height=80:t=fill,drawtext=text='This is a testing text example.':expansion=normal:y=h-line_h-20:x='if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))':fontfile='Lora/Lora-Regular.ttf':fontcolor=white: fontsize=40" \
  -c:a copy -shortest ./out_fade.mp4
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks this worked like a charm.  
  
  ---
  
  