0

I want to get a frame from video to combine with other image

using two ffmpeg commands as:

command 1:

  ffmpeg -ss 3 -i video.mp4 -vf \"select=gt(scene\,0.4)\" 
 -frames:v 5 -vsync vfr -vf fps=fps=1/100 
 -vf scale=150:150  output.jpeg

command 2:

  ffmpeg -i output.jpeg -i other.png -filter_complex "[0:v][1:v] 
  overlay=(W-w)/2:(H-h)/2:enable='between(t,0,20)'" 
 -pix_fmt yuv420p -c:a copy output2.jpg

how to combine two commands in one, or how to get frame from video and combine other image in one?

Metin Bulak
  • 537
  • 4
  • 8
  • 30

1 Answers1

1

You can combine the two commands using the and && after the first command which allows you to execute the second command based on whether the first command completed successfully:

 ffmpeg -ss 3 -i video.mp4 -vf "select=eq(n\,4)" 
 -frames:v 5 -vsync vfr -vf fps=fps=1/100 
 -vf scale=150:150  output.jpeg 

&& 

ffmpeg -i output.jpeg -i other.png -filter_complex "[0:v][1:v] 
  overlay=(W-w)/2:(H-h)/2:enable='between(t,0,20)'" 
 -pix_fmt yuv420p -c:a copy output2.jpg

Now if you want to combine multiple images onto one, Take a look at this solution

asendjasni
  • 963
  • 1
  • 16
  • 36
  • Ok thanks, but how to pass output.jpg to second command. This create two output.jpg just only one – Metin Bulak Mar 14 '19 at 09:08
  • @MetinBulak I think you have a typo in the first command: `\"select=gt(scene\,0.4)\"` **should be** `"select=eq(n\,4)"`. – asendjasni Mar 14 '19 at 09:35
  • @MetinBulak Well, it didn't for me, so I concluded it didn't for you either. Now, were you able to execute both commands in a single one? – asendjasni Mar 14 '19 at 10:05
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/190005/discussion-between-sendjasni-and-metin-bulak). – asendjasni Mar 14 '19 at 10:28