mediasnacks
v0.16.3
Published
Utilities for optimizing and preparing videos and images for the web
Readme
mediasnacks
Utilities optimizing and preparing video and images for the web.
Overview
FFmpeg and Node.js must be installed.
npx mediasnacks <command> <args>Commands
avifConverts images to AVIFsqcropSquare crops imagesresizeResizes videos or imagesedgespicExtracts first and last framesgif: Video to GIFdropdupsRemoves duplicate frames in a videoframediff: Plays a video of adjacent frames diffhev1tohvc1: Fixes video thumbnails not rendering in macOS Findermoov2frontRearranges .mov and .mp4 metadata for fast-start streamingvconcat: Concatenates videosvdiff: Plays a video with the difference of two videosvsplit: Splits a video into multiple clips from CSV timestampsvtrim: Trims video from start to end timeflattendir: Moves unique files to the top dir and deletes empty dirsqdirSequentially runs all *.sh files in a folderseqcheckFinds missing sequence numberdlaudio: yt-dlp best audiodlvideo: yt-dlp best videounemoji: Removes emojis from filenamesrmcover: Removes cover artcurltime: Measures request response timings
Globs
Glob patterns are expanded by Node.js.
mediasnacks avif file[234].png
# Expands to: file2.png, file3.png, file4.pngmediasnacks avif -- file[234].png
# Literal filename: "file[234].png"Commands
Converting Images to AVIF
mediasnacks avif [-y | --overwrite] [--output-dir=<dir>] <images> Resizing Images or Videos
Resizes videos and images. The aspect ratio is preserved when only one dimension is specified.
--width and --height are -2 by default:
-1auto-compute while preserving the aspect ratio (may result in an odd number)-2same as-1but rounds to the nearest even number
mediasnacks resize [--width=<num>] [--height=<num>] [-y | --overwrite] [--output-dir=<dir>] <files>Example: Overwrites the input file (-y)
mediasnacks resize -y --width 480 'dir-a/**/*.png' 'dir-b/**/*.mp4'Example: Output directory (-o)
mediasnacks resize --height 240 --output-dir /tmp/out video.movFast-Start Streaming Video
Rearranges .mov and .mp4 metadata to the start of the file for fast-start streaming.
Files are overwritten
mediasnacks moov2front <videos>What is Fast Start?
- https://wiki.avblocks.com/avblocks-for-cpp/muxer-parameters/mp4
- https://trac.ffmpeg.org/wiki/HowToCheckIfFaststartIsEnabledForPlayback
Adding a macOS Quick Action

For example, for dropdups -n2 file.mov
- Open Automator
- Select: Quick Action
- Workflow receives current:
movie filesinFinder.app - Action:
Run Shell Script
export PATH="/opt/homebrew/bin"
for f in "$@"; do
$HOME/bin/mediasnacks dropdups -n2 "$f"
doneIt will be saved to ~/Library/Services
