Convert Video in Linux

25,438

16

9

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).

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    9 Discussions

    None
    Calvinhudson

    2 years ago

    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.

    None
    SergeiP77

    3 years ago

    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.

    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 :)

    1 reply

    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.

    None
    lokisox

    10 years ago on Introduction

    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

    None
    stuuf

    10 years ago on Introduction

    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.

    None
    DrCoolSanta

    11 years ago on Introduction

    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

    None
    zupHC

    11 years ago on Introduction

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