Easy Linux Encoding (FFMPEG)


After much trying and testing I have found a viable solution to encoding movies using ffmpeg.

Simply put:

ffmpeg -i /movies/film.mp4 -b 800k -vcodec xvid -acodec mp3 -ab 192 -ar 48000 -vol 1500 /movies/film.avi -y

Breaking it down:

-i /movies/film.mp4: this specifies the input file
-b 800k: this sets the film bit rate (basically the quality of the output)
-vcodec xvid: uses the xvid codec to encode the video file (Linux users install xvidcore)
-acodec mp3: uses the popular mp3 codec to encode audio
-ab 192: sets a good scope for audio quality (sometimes depends on input bit rate)
-ar 48000: sets the highest quality sample rate (ensures quality audio)
-vol 1500: sets the volume (in case the sound is bad)
/movies/film.avi: the output file
-y: necessary if you want to overwrite without existing files without prompts (useful when testing)


-t 30: this allows only 30 seconds (variable in seconds) of encoding (so you don't have to wait for the whole film to encode before testing it works as expected)

Bash Script for multiple file encoding

If you want to encode multiple files using a for loop the code below will help:

N.B. assuming you are i the directory where your video files are stored.

for N in *
ffmpeg -i $N -b 800k -vcodec xvid -acodec mp3 -ab 44100 -ar 128 /videos/$N

there it is!

leave a comment if you need help



Post a comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.