How to Use Movie Thumbnailer (mtn) — Tips, Commands, and ExamplesMovie Thumbnailer (mtn) is a lightweight command-line tool for extracting thumbnails from video files. It’s fast, scriptable, and ideal for generating preview images for media libraries, web galleries, or automated workflows. This guide covers installation, basic usage, useful options, batch processing, automation examples, troubleshooting, and best practices.
What mtn does and when to use it
- mtn extracts one or more thumbnails from video files at specified positions, automatically scaling and saving them in common image formats (JPEG, PNG).
- Use mtn when you need fast, consistent thumbnails for large collections, when you want to automate thumbnail generation in scripts, or when a minimal-dependency tool is preferred over GUI applications.
Installing mtn
Installation methods depend on your operating system.
-
On Debian/Ubuntu:
sudo apt update sudo apt install mtn
-
On Fedora:
sudo dnf install mtn
-
On Arch Linux:
sudo pacman -S mtn
-
macOS (Homebrew):
brew install mtn
-
From source:
- Download the source tarball from the project page or clone the repo.
- Unpack and run:
./configure make sudo make install
(Dependencies such as libav/ffmpeg headers and imagemagick may be required depending on build options.)
Basic usage and command structure
The simplest command extracts a single thumbnail:
mtn -i input.mp4 -o thumb.jpg
Key options:
- -i, –input FILE — input video file.
- -o, –output FILE — output image file (use templates like %f or %n for batch names).
- -t, –time TIME — time position to capture (seconds or HH:MM:SS).
- -n, –number N — number of thumbnails to extract.
- -s, –size WxH — resize output (e.g., 320×180).
- -q, –quality N — JPEG quality (1–100).
Examples:
- Capture at 10 seconds:
mtn -i movie.mkv -o thumb.jpg -t 10
- Capture at 00:01:30:
mtn -i movie.mkv -o thumb.jpg -t 00:01:30
- Create three thumbnails evenly spaced:
mtn -i movie.mkv -o thumb_%02d.jpg -n 3
Time selection options
- Specify absolute times with -t (seconds or HH:MM:SS).
- Use -n to request N thumbnails spread across the file duration. By default, mtn chooses evenly spaced frames.
- Use -f, –frame FRAME to extract a specific frame index (if supported).
- Use -S, –start and -E, –end to constrain extraction to a segment and then use -n within that range.
Example — three thumbnails between 00:01:00 and 00:05:00:
mtn -i input.mp4 -o thumb_%02d.jpg -S 00:01:00 -E 00:05:00 -n 3
Output formatting and image options
- Output filename templates: use %f for source filename, %n for sequence number, %t for timestamp. Example:
mtn -i movie.mp4 -o "%f_thumb_%02n.jpg" -n 5
- Resize with -s, e.g.,
-s 320x180
. Use only width-s 320x
to keep aspect ratio. - Set JPEG quality with -q:
-q 85
. - Choose PNG output by using .png extension:
-o thumb.png
. - Add metadata or custom naming in scripts by parsing mtn’s output variables.
Filters and image processing
mtn relies on image libraries available at build/runtime. It can perform basic resizing and color handling. For advanced processing (watermarks, overlays, cropping), pipe mtn output or run post-processing with ImageMagick/GraphicsMagick or ffmpeg.
Example — add a 10px border and caption using ImageMagick:
mtn -i movie.mp4 -o temp.jpg -t 60 convert temp.jpg -bordercolor black -border 10 -gravity South -annotate +0+5 "My Caption" final.jpg rm temp.jpg
Batch processing and automation
For a folder of videos, use a simple shell loop. Examples assume a Unix-like shell.
Extract one thumbnail per file:
for f in *.mp4; do mtn -i "$f" -o "${f%.*}_thumb.jpg" -n 1 -t 10 done
Generate 5 thumbnails per file:
for f in *.mkv; do mtn -i "$f" -o "${f%.*}_%02n.jpg" -n 5 -s 320x180 done
Integrate into a script that writes JSON metadata:
#!/usr/bin/env bash echo "[" > thumbs.json first=true for f in *.mp4; do base="${f%.*}" mtn -i "$f" -o "${base}_%02n.jpg" -n 3 if [ "$first" = true ]; then first=false; else echo "," >> thumbs.json; fi echo "{"file":"$f","thumbs":" >> thumbs.json # collect generated files for this movie... echo "]}" >> thumbs.json done echo "]" >> thumbs.json
For large libraries, run parallel jobs with GNU parallel or xargs -P to speed up processing.
Examples for common tasks
-
Single thumbnail at midpoint:
DUR=$(ffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4) MID=$(printf "%.0f" "$(echo "$DUR / 2" | bc -l)") mtn -i input.mp4 -o mid.jpg -t "$MID"
-
Thumbnails at scene changes (approximate): use ffmpeg/ffprobe to detect scenes, then pass timestamps to mtn.
-
Create contact sheet (thumbnails arranged in grid) using ImageMagick after generating multiple images:
mtn -i movie.mp4 -o thumb_%02n.jpg -n 12 -s 320x180 montage thumb_*.jpg -tile 4x3 -geometry +2+2 contact_sheet.jpg
Troubleshooting
- “Unsupported format” — ensure mtn was built with suitable libav/ffmpeg libraries or install ffmpeg and rebuild mtn.
- Blurry thumbnails — increase target size/quality or use a different frame (avoid frames with motion blur).
- Incorrect timestamps — confirm -t format and check for variable frame rate; use ffprobe to inspect durations.
- Permissions errors — check output directory write permissions.
- Performance issues — process in parallel, reduce image quality/size, or pre-transcode problematic files.
Best practices and tips
- Use even spacing (-n) for representative thumbnails, but supplement with targeted timestamps for important scenes.
- Resize to the smallest acceptable size for your use case to save disk space and bandwidth.
- Use filenames that include source name and index or timestamp to avoid collisions.
- For web use, generate both JPEG (small, lossy) and WebP (better compression) versions if supported.
- Cache thumbnails and only regenerate when the source file changes (compare mtime or checksums).
Security and resource considerations
- Run thumbnail generation in a controlled environment for untrusted files—FFmpeg/libav vulnerabilities can be exploited. Use sandboxing or containerization for public uploads.
- Limit CPU and memory for batch jobs on shared servers.
Quick reference: common commands
- Single thumbnail at 10s:
mtn -i input.mp4 -o thumb.jpg -t 10
- Three thumbnails evenly spaced and resized:
mtn -i input.mp4 -o "%f_%02n.jpg" -n 3 -s 320x180
- Batch process all mp4 files:
for f in *.mp4; do mtn -i "$f" -o "${f%.*}_thumb.jpg" -n 1 -t 10; done
If you want, I can: generate ready-to-run scripts for Windows (PowerShell), macOS, or Linux; produce a tutorial video script; or tailor commands for specific workflows (Plex, Jellyfin, static websites).
Leave a Reply