The other day I was thinking about how to make screencaps for the anime I watch. Windows users often use Media Player Classic, which can create a video contact sheet (i.e., a series of captures) out of a movie file. I had two problems with this:
The biggest is that it runs on Windows, and I don’t use Windows;
The frames needed to be manually cropped every time, which was slow.
Therefore, inspired by a video contact sheet script for Linux, I decided to write a small piece of code to make captures. It works rather easy, by taking snapshots every X minutes, where X is an integer number.
The code is here: it requires bash, python (just for checks) and mplayer to work correctly. It should work with every format mplayer suppports. It’s hackish, but if you find it useful, let me know.
EDIT: I changed a line (thanks, greg) because this syntax highlighter messes up some formatting.
(C) 2007 Luca Beltrame - licensed under the terms of the GPL v2
Simple script to output video frames with MPlayer. It takes the file
and a step argument to indicate how many minutes a capture should
be taken. The step must be an integer!
if [ $# -ne “2” ]
echo “Usage: $0 “
Requires python 2.5
python -c "value = 0 if isinstance($step,float) else 1;print value"
if [ $verification -eq “0” ]
echo “Step must be an integer!”
mplayer -benchmark -ao null -vo null -identify -frames 0 -quiet $file 2>/dev/null | grep ID_LENGTH | cut -f2 -d'='
echo $length/60| bc
while [ $i -lt $end ]
We take two captures as the first will be always black - mplayer bug?
mplayer -sws 9 -ao null -quiet -benchmark -vo “png:z=0” -frames 2 -ss $minutes “$1” &> /dev/null
mv 00000002.png $name
rm -f 00000001.png
echo “Screenshots saved.”
Luca Beltrame GENERAL · LINUX
bash Linux python script