0

I am trying to take ~50K images and turn them into a movie using ffmpeg. I am running this on a HPC setup, hence the slurm commands. My attempt does not work since I am running into a hard limit due to the shear volume of images. I cannot just list a start number since the pipeline will reject some images so I do not have a proper sequence.

I know a loop could circumvent both issues but I am not sure how to use that with ffmpeg so that it builds one long movie.

The cat command has worked for shorter movies but i just have too many images now.

#!/bin/bash

img_dir='foo/bar/1/2/123456'
folder='fooo'
#BATCH -p general
#SBATCH -N 1
#SBATCH -t 03-00:00:00
#SBATCH --mem=8g
#SBATCH -n 1
#SBATCH --mail-type=BEGIN,REQUEUE,END,FAIL,REQUEUE   
#SBATCH --mail-user=<snip>

singularity exec /$img_dir/foo_container cat /$img_dir/processed_images/$folder/*.jpeg | ffmpeg -f image2pipe -i pipe:.jpeg -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" /$img_dir/processed_images/$folder/$folder.mp4

TheCodeNovice
  • 750
  • 14
  • 35
  • Is it an idea to create videos for partial sets of images and then concatenate those videos also using ffmpeg like so https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg . – Dries Meerman Sep 10 '21 at 20:27
  • Have you tried the glob pattern type? `ffmpeg -pattern_type glob -framerate 25 -i '*.jpeg' -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p" -movflags +faststart output.mp4` – llogan Sep 10 '21 at 20:57
  • @DriesMeerman Ideally i would like the make the videos in one shot. I do not want to mess around in making chunks and doing an additional step to join them. – TheCodeNovice Sep 11 '21 at 01:41
  • @llogan The problem with a lob is that i do not have uninterrupted sequence. So I would have frames 3,4,5,7,8 etc... ffmpeg will throw an error because it cannot find image 6. – TheCodeNovice Sep 11 '21 at 01:42
  • @TheCodeNovice Did you try it? The glob should work no matter what the basename is. – llogan Sep 11 '21 at 02:14
  • @llogan I tried it and it does not even start because the glob is too big for bash ` Argument list too long` – TheCodeNovice Sep 16 '21 at 22:53

0 Answers0