Cyderize.org

Cyderize.org is my personal website, started in 2011 which I use to write about computers, the Internet, electronics, music, and whatever else I feel like. I'm a computer nerd and musician, residing in Melbourne, Australia.

Read the About page to find out more.

Using FFMPEG to convert videos

Posted July 12th, 2011 by

FFmpeg is tool that’s used to convert audio and video to other formats. It’s very versatile, and is cross-platform and supports input from files, streams and video/audio devices. Pretty much every codec I can think of is supported, making FFmpeg my favourite tool for converting videos for viewing on my phone. In this article, you’ll learn how to use FFmpeg, with its many parameters and properties explained.

Getting FFmpeg

Depending on what operating system you’re using, you’ll need to get a different version of FFmpeg. For Windows, the pre-compiled binaries (Ready to use applications) are available here. If you’re unsure of which version you should get, the most likely one is the latest build from the 32-bit Builds (Static) section. If you’re running a Linux distro like Debian or Ubuntu, you can run the command
apt-get install ffmpeg
Other operating systems may have a pre-compiled package, or you may have to download the source code and compile it yourself.

Compiling FFmpeg if you don’t have a pre-compiled package

It may be necessary to compile FFmpeg by yourself, and you’ll need a suitable compiler to do this. GCC with make works fine, and if you’ve got that, you’re almost set. To get the source code, you can use GIT if you’ve got it available, by using the command
git clone git://git.videolan.org/ffmpeg.git
Alternatively, you can download a tarball with the source from here. Once you’ve got your source in a folder (Must be extracted if downloaded from a tarball), you can ‘cd’ to the source directory and run the following commands:
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
--enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
make
make install
Once its built, you’re ready to start using FFMPEG!

Using FFmpeg

To use FFmpeg, you must use the command line. In Windows, you can open the command prompt by pressing [Windows Key] + [R] to open the Run dialogue. Then type “cmd” into the text box and click OK. On Linux, you can use the Bash prompt or open a terminal window.
The basic syntax for FFmpeg is FFMPEG -i "<input file name>" [options] "<output file name>"

This syntax is used for converting files. You can replace [options] with several options for converting your video. For a full reference of the parameters, see the FFMPEG Documentation.

Here are some options I frequently use:
-s widthxheightChanges video size on converted video. For example: FFMPEG -i “a.avi” -s 640×360 “b.avi”
———-
-vcodec codecTells FFMPEG to convert the video to a specific format. For example: FFMPEG -i “a.avi” -vcodec mpeg4 “b.mp4”
———-
-acodec codecTells FFMPEG to convert the audio to a specific format. For example: FFMPEG -i “a.avi” -acodec libmp3lame “b.avi”
———-
To find out the names of codecs, use the command:FFMPEG -codecs
To save the codecs reference to a file, use this command:FFMPEG -codecs > "codecs.txt"

That’s the most basic of basics of using the extremely powerful FFmpeg. For more information, read the documentation available on the FFMPEG website.

Comments: none yet | Filed under: articles, tutorials | Tagged: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *