Saturday, 16 January 2010

How to convert a directory of videos using ffmpeg

Here is a simple command useful for using a wildcard (not a regular expression) to select filenames to convert from one video format (or audio, for that matter) to another using FFMPEG on Linux.

The command below will convert a directory of .flac files into .mp3s:

for f in *.flac; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k  "${f%.flac}.mp3"; done

To convert videos, we could use this command:

for f in *.flv; do ffmpeg -i "$f" "${f%.flv}.avi"; done

This converts a directory of .flv video files into .avi files.


No comments: