MP4 → Animated WebP
Assuming you're adding this to a Makefile (which requires all $ to be $$), and the MP4 files are in a directory called ./remote-assets, you can use the following to produce an animated WebP version of the MP4 file.
find ./remote-assets -type f -name '*.mp4' | xargs -P $$(nproc) -I {} bash -c 'ffmpeg -i $$1 -color_primaries film -quality 80 -loop 0 -hide_banner "$${1%.mp4}.webp"' _ {} \;This will:
- Find all .mp4files in the directory (recursively)
- Pass the list of matches to xargs
- Determine the number of CPU cores you have
- Spin up that many threads in order to parallelize the work
- Use Bash to call ffmpeg
- Output the file with the same name, but with a .webpfile extension
Written by Ryan Parman
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Ffmpeg 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#

 
 
 
 
