Create Cover-Preview from Moviefile Screenshot

From AwkwardTV
Jump to: navigation, search

You can use this script to create covers/previews for movies in browsed by ATVFiles. Ths script checks, if there is a already a cover, if not it takes a screenshot of the movie and saves it as cover by using the mplayer binary.

I used the mplayer from nitoTV Plugin (nitoTV.frappliance/Contents/Resources/mplayer) and copied it to /usr/bin (you have to Mount ReadWrite before). But you can also use the one from the MPlayer OS X (MplayerOSXB8r5/MPlayer OS X Don't forget to make the binary executable (chmod +x /usr/bin/mplayer).

Now you can create screenshots from the commandline. The following command creates a screenshot with the name 00000001.png, scaled to 400 pixel width with correct aspect ratio:

 mplayer -ss 20 -frames 1 -vf scale=400:-2 -vo png Movies/filename.mp4
  • 20: take screenshot after 20 seconds of movie file
  • 400: screenshot(00000001.png) width 400 pixel
  • Movies/filename.mp4: movie file to take a screenshot from

This could be used to create preview-covers for movies like iTunes does. Works with most movie formats/codecs.

The following bash script creates missing covers (only checks for .png) by taking a screenshot from 20 seconds after start of all movie files in /Users/frontrow/Movies/:

 extensions="avi mov mp4 mkv mpeg mpg"
 for ext in $extensions 
   for file in $path*.$ext
     base=$(echo $file | sed -e "s/\....$//")
     if [ -s "$file" -a ! -s "$base.png" ]
       echo "Create Cover: $file"
       /usr/bin/mplayer -really-quiet -ss $seconds -frames 1 -vf scale=$width:-2 -vo png:z=1 "$file"
       mv 00000001.png "$base.png"

To create Mosiac Cover-Previews of video files, try this script.