[SATLUG] Bash scripting noob could use some help with a Bash script

Don Davis dondavis at reglue.org
Sun May 30 08:13:00 CDT 2010


Nate Turnage wrote:
> I am trying to automate a process of encoding many videos into six different
> formats. That's not the part that I need help with, yet. I am starting out
> trying to batch process the image still preview images for each of the
> videos. All of the videos are quicktime '.mov' files. The ffmpeg commands I
> am working from can be found here:
> {
> 
> What I would like to do is iterate over all the '.mov' files in a directory
> and save out a preview of them using ffmpeg. Each of these preview files
> should be named 'filename_preview.jpg'. The script is trying to do what I am
> asking, but I don't know how to get it to save the file out properly.




  The
> files aren't being saved and the images are being 'written' on the terminal.
You are catting an image file. If you want to see the picture use 
'display.' (You may need to install Image Magick first.)

Using the basic version of your script:
for i in *wmv; do ffmpeg -i $i -ss 78.5 -s 640x352 -vframes 1 -an -f 
image2 ${i}_preview.jpg; done

worked fine for me. I did, however, have problems using .mov files - I 
don't know if the problem was with the .mov files or some lack of codec 
on my part.



> Can somebody take a look at the script and offer some pointers?
> 
> Script:
> 
> #!/bin/bash
> FILES="*.mov"
> for f in $FILES
> do
>   echo "Processing $f file..."
>   ffmpeg -i $f -ss 78.5 -s 640x352 -vframes 1 -an -f image2 ${f}_preview.jpg
>   cat $f
> done
> 
> 
> Thanks in advance,
> 
> Nate



More information about the SATLUG mailing list