views:

46

answers:

3

I want to batch convert a directory containing hundreds of FLV files so that each file has a MP4 equivalent. I'm trying to automate this process by writing a shell script and running it from the Terminal. How do I go about doing that? Most of the instructions available are for Linux using ffmpeg but I think OS X doesn't have it. Thanks.

+2  A: 

You can install ffmpeg via MacPorts. The command to install ffmpeg is sudo port install ffmpeg. Once you've installed ffmpeg, here is a simple (and somewhat naive) script for converting the files. You may need to throw in some additional flags, depending on your desired output options.

#! /bin/bash
function convert_all_to_mp4(){
for file in *.flv ; do
    local bname=`basename "$file" .flv`
    local mp4name="$bname.mp4"
    ffmpeg -i "$file" "$mp4name"
done
}
convert_all_to_mp4
Michael Aaron Safyan
This code has great potential. Will try it out. I can imagine so many uses for it other than this task. Thanks. ;-)
GeneQ
+1  A: 
#!/bin/bash

shopt -s nullglob
shopt -s nocaseglob
for file in *.flv
do
  ffmpeg -i "$file" "${file%flv}mp4"
done
ghostdog74