Introduction: Convert Video in Linux

Picture of Convert Video in Linux

FFmpeg is the best open-source video converter out there. It is plain, simple, but very powerful. FFmpeg is a command line program. There are a few graphical frontends too, but they tend to be buggy. So, the easiest way to convert video in Linux is using FFmpeg in the terminal (Linux command line).

Step 1: Opening the Terminal

Picture of Opening the Terminal

Terminal is in the applications menu in one of the sub-categories. (Depends on the distribution and the desktop environment). In Ubuntu, it is in Applications->Accessories->Terminal.

First, cd to the directory, where your video file is (cd means change directory)
If the file is on desktop, the command would be: cd Desktop
if it's in the videos folder, it would be: cd /home/$USER/Videos

Now you're virtually inside that folder.

Step 2: Converting Video

Picture of Converting Video

The basic command for converting video is: ffmpeg -i inputfile outputfile
The format of the output video comes from the file extension you specify on outputfile.
It can be any video format: flv, avi, mpg...

example: ffmpeg -i input.avi output.mpg

Now we start adding parameters.
parameters are options for converting video. they are in format: ffmpeg -i myfile.avi -parameter output.mpg

There are a number of parameters:
-ab -audio bitrate
-b -video bitrate
-sameq -produces same quality video, as the input
-target -target can be "vcd", "svcd", "dvd", "dv", "pal-vcd" or "ntsc-svcd".
example: ffmpeg -i myfile.avi -target ntsc-dvd mydvdfile.mpg
This makes a dvd video file

Examples:
I want to convert an mpg file to flv with 350 video bitrate and 64 audio bitrate:
ffmpeg -i mympgfile.mpg -b 350 -ab 64 myflvfile.flv

I want to convert an avi to mpg with the same quality:
ffmpeg -i avifile.avi -sameq output.mpg

Here is a great tutorial on this:
http://www.linuxjournal.com/article/8517

Comments

Calvinhudson (author)2017-04-13

Very informative! Thanks for showing clearly how to download convert videos in linux. I always use Acethinker Video Converter to do the conversion job on my linux laptop, it's a free online app, you don't have to download or install anything. Share it here as an alternative method.

SergeiP77 (author)2016-04-04

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! http://gks.com.ua/ keep up the good work.

ChildrenccC (author)2016-01-20

The guide will
take change MP4 file frame rate as an example and it can also serve to change
AVCHD, MTS, M2TS, MXF, XAVC, ProRes, MPG, AVI, FLV, MOV, WMV, MKV and almost
all video format frame rates at

http://www.avdshare.com/change-video-frame-rate

instructables_user_4783 (author)2010-05-17

OK, so I had a bit of a problem converting an AVI video from my camera to MP4. I kept getting an error opening output codec error message,so I had to do this:
Convert to VCD format:
ffmpeg -i MVI_1841.AVI -target ntsc-vcd firstoutput.mpg
then I converted it to MP4 format:
ffmpeg -i firstoutput.mpg -s 320x240 video.mp4
**Please note I had to set the size to 320x240 because ntsc-vcd was different and distorted the video**
It worked. Probably not the most efficient way converting the video twice but it does work. Just thought I'd let people know. Perhaps there is a way that works and requires only one conversion :)

UPDATE: Here is how I did it with only one conversion.
Find the frame rate of the input video using:
ffmpeg -i MVI_1841.AVI
then convert with the frame rate parameter set to that of the input video. In my case it was 15. Use this command.
ffmpeg -i MVI_1841.AVI -r 15 output.mp4
This way only one conversion is needed.

lokisox (author)2009-03-18

devede, makes dvd iso that play on avy dvd player, it can also convert upto 5 full movies to fit on one 4.7 dvd, it lets you resize the input image, get thru internet site or add / remove programs, never had a bad copy in the 3 years of use

stuuf (author)2009-02-07

It's a start, but you should add some more details about how ffmpeg command line options work (especially how options apply only to files listed *after* them), how to set codecs and formats (containers) including -acodev/vcodec copy, when and when not to use -target, a/v sync, threads, 2-pass video encoding...

There are some other interesting things you can do with ffmpeg beyond simple video encoding, like extracting still frames from a video and adding/extracting an audio track to a video file.

DrCoolSanta (author)2008-09-19

1) Not all distros come with ffmpeg
2) There is a windows version as well.

To add:

For help on ffmpeg run:
ffmpeg -h

to specify an audio codec add the argument
--acodec codec'

to specify the video codec add the argument
--vcodec codec

to check the codecs that you can use with ffmpeg, check
ffmpeg -formats

zupHC (author)2008-06-11

Great! Thanks! Is just what I was searching for! :)

About This Instructable

22,412views

16favorites

More by magnus0:How to open a jammed CD/DVD driveSimple overdrive effect pedalHow to install Google Earth in Linux with one command
Add instructable to: