Showing posts with label encoder. Show all posts
Showing posts with label encoder. Show all posts

MPEG-2 Video Support missing in ffmpeg

Today I tried to encode a MPEG-2 video in Ubuntu 8.10 (intrepid) with the following instruction:
ffmpeg -i in.avi -vcodec mpeg2video -r 25 -s pal -vb 2048 out.mpg

ffmpeg blamed about not being able to encode to mpeg2video.
ffmpeg -formats | grep mpeg2video

gave
 D VSDT mpeg2video
as result, where the E is missing which would indicate the encoding support.
Don't know when exactly this support got lost (ffmpeg also disappeared from Medibuntu repository), but after some investigation I found the solution.
You have to install different packages which include this video codec.

Install instructions


You need to have the multiverse repository enabled (see this post about how to do this from the command line).
sudo -v
sudo aptitude install ~nlibav.+-unstripped.+

If you already have installed the stripped packages, you'll be asked to remove them as they are in conflict with the unstripped one.
Now, the previous instructions give this output
 DEVSDT mpeg2video
and encoding to MPEG-2 works fine.

MediBuntu

Medibuntu (Multimedia, Entertainment & Distractions In Ubuntu) is a repository of packages that cannot be included into the Ubuntu distribution for legal reasons.

Its main focus is on multimedia support, something similar to the Combined Community Codec Pack for Windows.

The most interesting feature is a full version of ffmpeg (including MP3 and x264 encoding).

More help on adding the repository and installing individual packages can be found in the Ubuntu online help.

ffmpeg

ffmpeg is a very powerful video coding suite. It is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. ffmpeg is developed under Linux, but it can be compiled under most operating systems, including Windows.

How to enable mp3 support?


Because of license rights, ffmpeg doesn't include encoding support of mp3 by default.
So we have to recompile it or get a non-free version of ffmpeg.

Install from non-free repository


You can find an already compiled version of ffmpeg in the MediBuntu repository.
It contains a ffmpeg compiled with risky option.

Recompile by yourself


In Ubuntu this can be done quite simply.
Just follow these steps in a shell.

  • Install necessary development packs:
    sudo apt-get install quilt libsdl1.2-dev libogg-dev libvorbis-dev liba52-dev
    libdts-dev libimlib2-dev texi2html libraw1394-dev libdc1394-13-dev
    libtheora-dev libgsm1-dev
    liblame-dev libxvidcore-dev libfaac-dev libfaad2-dev libx264-dev

  • Download ffmpeg sources:
    cd /usr/local/src
    sudo apt-get source ffmpeg
    cd ffmpeg

  • The most important step: enable support for mp3, x264, etc:
    export DEB_BUILD_OPTIONS=risky

  • Build installable debian packages
    sudo dpkg-buildpackage
    cd ..

  • Finally, install all generated debian packages:
    sudo dpkg -i ffmpeg_0.cvs20060823-3.1ubuntu4+medibuntu2_x86.deb libavcodec0d_0.cvs20060823-3.1ubuntu4+medibuntu2_x86.deb libavcodec-dev_0.cvs20060823-3.1ubuntu4+medibuntu2_x86.deb ... 

    Essentially, you have to list all generated debian packages here.

    Maybe you could do something like this:
    sudo dpkg -i `ls *.deb`

Test the non-free version


That's it. Now we can test the installation:
 ffmpeg -i some_of_your_movies.avi -ar 44100 test.flv

This should convert one of your AVI movies into a Flash Video.
ffmpeg shouldn't claim any longer about unknown codec for output stream 0.1 (the audio one).