Skip to content

Instantly share code, notes, and snippets.

@manzke
Created February 26, 2022 14:58
Show Gist options
  • Save manzke/99e9aed5cbd6216184e5c52bfbfe20fb to your computer and use it in GitHub Desktop.
Save manzke/99e9aed5cbd6216184e5c52bfbfe20fb to your computer and use it in GitHub Desktop.
Converting stylegan2 fakes generated during evaluation to video
# script to create movie from multiple png files
# taken in choronoligcal order
# start at 0
count=0
# take all files named shot - something ordered by date
for f in `ls fakes*.jpg`
do
# get the index in 0000 format
printf -v counts "%06d" $count
# link file to a frame_0000 named symbolic link
ln -s $f frame_$counts.jpg
# increment counter
count=`expr $count + 1`
done
# create movie
# slowed down by factor 5
# ffmpeg -f image2 -i frame_%04d.png -vcodec mpeg4 -vf "setpts=5*PTS" movie.mp4
#ffmpeg -y -r 12 -pix_fmt yuv420p -i frame_%06d.jpg movie.mp4
#ffmpeg -f image2 -r 4 -i frame_%06d.jpg -y -r 25 movie.mp4
ffmpeg -y -f image2 -i frame_%06d.jpg -vcodec mpeg4 -vf "setpts=5*PTS" movie.mp4
#ffmpeg -y -r 12 -pix_fmt yuv420p -pattern_type glob -i "fakes*.jpg" ../test.mp4
# remove the links
rm frame_*.jpg
ffmpeg -i movie.mp4 -vf "crop=ih*(9/16):ih" -crf 21 -c:a copy output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment