Techno Blog Just another Technology Blog

16Apr/110

How to convert audio / video media with ffmpeg

Ever need to convert 50 audio files to another format? This is made easy with ffmpeg and a for loop.

Install ffmpeg and dependencies if necessary.

$ yum install ffmpeg

Refer to this post for information on how to install RPM Fusion repositories.

In this example, we will convert all of the .m4a files in the current directory to .mp3.
# ls -l
total 18680
-rw-r--r-- 1 root root 9542706 Apr 16 11:54 test1.m4a
-rw-r--r-- 1 root root 9542706 Apr 16 11:54 test2.m4a

for i in $(ls -1 *.m4a)
do
ffmpeg -i "$i" -acodec libmp3lame -ac 2 -ab 128 "${i%m4a}mp3"
done

# ls -l
total 26696
-rw-r--r-- 1 root root 9542706 Apr 16 11:54 test1.m4a
-rw-r--r-- 1 root root 4092688 Apr 16 12:03 test1.mp3
-rw-r--r-- 1 root root 9542706 Apr 16 11:54 test2.m4a
-rw-r--r-- 1 root root 4092688 Apr 16 12:03 test2.mp3

Related Posts
Adding RPM Fusion Repositories

Filed under: Linux, Media Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.