Skip to content

Instantly share code, notes, and snippets.

@orm011
Last active December 7, 2021 02:46
Show Gist options
  • Save orm011/226fc7ab8f26c9bb659a16432153812f to your computer and use it in GitHub Desktop.
Save orm011/226fc7ab8f26c9bb659a16432153812f to your computer and use it in GitHub Desktop.
ffmpeg recipe
# cheaply convert container only, given compatible internal codecs
ffmpeg -i ../panama_loop/WtoxxHADnGk_0820.ts -map 0 -c copy WtoxxHADnGk_0820.mp4
# extract every 150th frame (5s) (random ordering of files). jpeg preserve quality
ls ../panama_loop_mp4/ | shuf | xargs -L 1 -I {} -P 20 bash -c "mkdir -p {} && ffmpeg -i ../panama_loop_mp4/{} -vf 'select=not(mod(n\,150))' -q:v 2 {}/frame_%06d.jpg"
## need to add -vsync vpf above to avoid the same frame showing up multiple times
ls ../panama_loop_mp4/ | shuf | xargs -L 1 -I{} -P 120 bash -c "mkdir -p {} && ffmpeg -filter_threads 1 -i ../panama_loop_mp4/{} -threads 1 -vf 'select=not(mod(n\,300)), scale=1008:-1' -vsync vfr -f image2 -q:v 2 -threads 1 -an {}/frame_%06d.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment