Easy Linux Encoding (FFMPEG)

Hi,

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)

Optional

-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 *
do
ffmpeg -i $N -b 800k -vcodec xvid -acodec mp3 -ab 44100 -ar 128 /videos/$N
done

there it is!

leave a comment if you need help

cheers

Leave a Reply

You must be logged in to post a comment.