Skip to content

Instantly share code, notes, and snippets.

@tsumare
Last active August 29, 2015 14:01
Show Gist options
  • Save tsumare/bf19466721b72be1698b to your computer and use it in GitHub Desktop.
Save tsumare/bf19466721b72be1698b to your computer and use it in GitHub Desktop.
Extract still images (artwork) from Youtube songs, or other video files.
youtube-dl --restrict-filenames --auto-number https://www.youtube.com/playlist?list=$PLAYLIST # --playlist-start 1
for I in *.mp4; do
nice -n20 \
mplayer $I -vf framestep=30,decimate=100000000:512:256:0.1 -nosound -speed 100 -vo jpeg:outdir="${I%.mp4}"
done
# Key point is 'decimate', which tosses similar frames. See manpage.
# Consider the effects of decimate combined with frameskip, for notable tuning.
# And, obviously, experiment!
#
# Regarding Parameters:
#
# I think you want to set frameskip based on the change rate of images so you
# get at least one good capture for sure (maybe two) of each image in its full
# form. Then configure the decimate parameters based on how many captures are
# likely to occur in even the longer fades. Higher values will result in less
# captures during a fade, but it will also reduce the worst-case quality of a
# image proper. Higher parameters might 'not detect changes' between a 80%
# fade-in and a 100% stable image. Lower ones will result in more captures
# during a fade, if there are multiple samples there, but will also mean that
# you get perhaps a 95% or 97% fade-in as your worst case here.
#
# frameskip is effectively your max capture rate
# decimate is effectively your acceptable worst-case quality level
#
# If there's fading, this is a tradeoff. If it just cuts between images, use
# an appropriate frameskip and rather low decimate parameters, and you should
# end up with one image per image basically every time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment