-1

I would like to know the CLI command and the script to extract images using FFmpeg of two videos simultaneously and not sequentially. For example - the first frame of the first video the first frame of the second video and the second frame of first video and then the second frame of second video and so on.

Videos will be in mp4 or asf and image should be in jpeg

devl
  • 19
  • 6

1 Answers1

0

Use the framepack or interleave filters:

ffmpeg -i video0.mp4 -i video1.asf -filter_complex framepack=frameseq output_%04d.jpg
  • Both inputs should have the same width, height, and timebase.
  • Outputs will be named output_0001.jpg, output_0002.jpg, etc.

Additional info:

llogan
  • 121,796
  • 28
  • 232
  • 243
  • 1
    I think the OP wants to interleave the streams in a single output. – Gyan Oct 06 '21 at 18:50
  • 1
    @Gyan You're right. Answer updated. Shouldn't try to answer while on long, boring phone calls... – llogan Oct 06 '21 at 19:35
  • Can't get the expected output after running this - ffmpeg -i toys.mp4 -i toys.mp4 -filter_complex framepack=frameseq pig/output_%04d.jpg – devl Oct 06 '21 at 23:25
  • @devl Your 2 inputs are the same file so it will just make 2 copies of each frame. So output_0001.jpg will be frame #1 from the first toys.mp4, output_0002.jpg will be frame #1 from the second toys.mp4, output_0003.jpg will be frame #2 from the first toys.mp4, output_0004.jpg will be frame #2 from the second toys.mp4, and so on. – llogan Oct 07 '21 at 01:12
  • And what if I want two different naming conventions? Like imageA_0001.jpg and imageB_0001.jpg? – devl Oct 08 '21 at 06:34
  • @devl Not possible, but you can output 2 sets of sequential images `ffmpeg -i videoA.mp4 imageA_%04d.png` & `ffmpeg -i videoB.mp4 imageB_%04d.png` then use your favorite shell/scripting language to re-order them into a single sequence in your desired order. – llogan Oct 09 '21 at 17:06