Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old April 5th, 2009   #1
FakeOutdoorsman
Chocolate-Covered Ubuntu Beans
 
FakeOutdoorsman's Avatar
 
Join Date: Sep 2006
Location: Alaska
Beans: 2,018
HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoders in FFmpeg

A common question is "why doesn't the repository FFmpeg convert to mp3, aac, mpeg4, etc?". Ubuntu doesn't make it very clear to the general user as to why to repo FFmpeg is so limited or how to fix this issue. This is reflected in the number of forum questions relating to this topic.

Why is FFmpeg from the repository so limited?
Legal reasons. Some software is limited due to geographical differences in software patents, legal restrictions on free speech, and restrictions on certain technologies. Ubuntu sidesteps these legal restrictions by not including some restricted packages by default. Users must install these packages on their own. See Restricted Formats Ubuntu Community Documentation and FFmpeg License and Legal Considerations for more details.


How do I fix FFmpeg?
There are several options:
A. Compile FFmpeg yourself
B. Install the unstripped or extra libraries
C. Medibuntu

A. Compiling FFmpeg yourself (for all Ubuntu versions)
The official FFmpeg answer is to compile it yourself, giving you the power to get what you want with the bug-fixes, enhancements, and benefits of the most recent FFmpeg revision. This is an excellent solution and is explained here:

HOWTO: Install and use the latest FFmpeg and x264

This is the option that I personally use, and although it is not too hard, compiling may not be for everyone for a variety of reasons. Off to the other options...


B. Installing the unstripped or extra libraries
This is the quickest option for most users. FFmpeg from the repository does not include many restricted encoders, formats, and codecs which may include: H.263, aac (libfaac), mp3 (libmp3lame), H.264 (libx264), xvid (libxvid), and mpeg4. You can fix this by installing the unstripped or extra (Ubuntu Karmic renamed unstripped to extra) FFmpeg libraries that will enable these restricted encoders. Open up Terminal and enter:

Ubuntu Lucid Lynx 10.04 & Ubuntu Karmic Koala 9.10
Code:
sudo apt-get install ffmpeg libavcodec-extra-52
Note: The libavcodec-extra-52 package for Lucid and Karmic do not support AAC or AMR formats. I recommend using libavcodec-extra-52 from the Medibuntu repository. See option C. Medibuntu.
Ubuntu Jaunty Jackalope 9.04
Code:
sudo apt-get install ffmpeg libavcodec-unstripped-52
Ubuntu Intrepid Ibex 8.10
Code:
sudo apt-get install ffmpeg libavcodec-unstripped-51
Alternatively, you can search for these packages in the Synaptic Package Manager.


C. Medibuntu
This option is available for Ubuntu Lucid Lynx 10.04, Ubuntu Karmic Koala 9.10 and Ubuntu Hardy Heron 8.04. Medibuntu is a third-party repository that contains packages that are unable to be included in the official Ubuntu repositories. To install FFmpeg from Medibuntu open Terminal (Applications -> Accessories -> Terminal) and run the following:

Code:
sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update
This huge command (adapted from Medibuntu - Community Ubuntu Documentation) will install the repository information to your computer then update and authenticate the new repository. Now install FFmpeg:

Ubuntu Lucid Lynx 10.04 & Ubuntu Karmic Koala 9.10
Code:
sudo apt-get install ffmpeg libavcodec-extra-52
Ubuntu Hardy Heron 8.04
Code:
sudo apt-get install ffmpeg
That's it. Now you have a non-crippled version of FFmpeg. See some usage examples at the FFmpeg x264 encoding guide.


Undoing Changes Made By This Guide
B. Uninstalling the unstripped or extra libraries
Code:
sudo apt-get remove ffmpeg libavcodec-*-5*
C. Uninstalling FFmpeg and the Medibuntu Repository
Code:
sudo apt-get autoremove ffmpeg medibuntu-keyring && sudo rm /etc/apt/sources.list.d/medibuntu.list && sudo apt-get update
Let me know if you have any questions or comments. Thanks to andrew.46 for suggesting this guide.

Last edited by FakeOutdoorsman; 2 Days Ago at 12:38 PM.. Reason: trivial typo
FakeOutdoorsman is offline   Reply With Quote
Old April 8th, 2009   #2
mocha
Quad Shot of Ubuntu
 
mocha's Avatar
 
Join Date: Sep 2006
Beans: 481
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Well done. This clears up a lot of confusion.
__________________
Biostar TA790GXB A2+ | Phenom II X4 945 | 4GB DDR2-800 | 1TB SATA II | Nvidia 9500GT (G96)
Asus P5B-E | C2D E6420 | 2GB DDR2-800 | 400GB SATA II | Nvidia 7600GS
Asus A7N8X-E Dlx | Barton 2600+ | 1GB DDR | 280GB IDE | Nvidia 6200
mocha is offline   Reply With Quote
Old April 12th, 2009   #3
wittelw
First Cup of Ubuntu
 
Join Date: Apr 2007
Beans: 8
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Excellent guide! My only suggestion is to point people wanting to encode directly to your also most excellent article on compiling the sources: http://ubuntuforums.org/showthread.php?t=786095

This solved my problems perfectly and let me convert some files .mov to .avi and I wasn't able to find the solution anywhere else! Thanks!
wittelw is offline   Reply With Quote
Old May 8th, 2009   #4
naripela
First Cup of Ubuntu
 
Join Date: Jan 2009
Beans: 1
Smile Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Men!!! Great tutorial!! Thanks a lot, I was searching this for a long time!
naripela is offline   Reply With Quote
Old May 23rd, 2009   #5
jeffers.r
First Cup of Ubuntu
 
Join Date: May 2009
Beans: 9
Xubuntu 10.04 Lucid Lynx
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Hey folks,

I've been having a very difficult time doing some very basic trimming with ffmpeg and was hoping someone might be able to provide a little input. The input video is mpeg2 and the audio is ac3, and the problem is related to the ac3 sound, which no longer plays after the trimming. I've installed ffmpeg based on the examples above, unstripped, and also tried compiling ffmpeg based on FakeOutdoorsman's other tutorial with the latest svn, but still no luck.

I'm running this very simply command:

Code:
ffmpeg -i test.mpg -vcodec copy -acodec copy -ss 00:00:00 -t 90 test_trimed.mpg
and I get what appears to be a successful trim:

Code:
FFmpeg version git-5d5fb67, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-nonfree --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libxvid
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.29. 0 / 52.29. 0
  libavformat   52.33. 0 / 52.33. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1
  built on May 23 2009 12:47:43, gcc: 4.3.3

Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (30000/1001)
Input #0, mpeg, from 'test.mpg':
  Duration: 00:04:31.23, start: 0.255589, bitrate: 9422 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 704x480 [PAR 10:11 DAR 4:3], 9510 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, mpeg, to 'test_trimed.mpg':
    Stream #0.0: Video: mpeg2video, yuv420p, 704x480 [PAR 10:11 DAR 4:3], q=2-31, 9510 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 2702 fps=  0 q=-1.0 Lsize=  100652kB time=90.02 bitrate=9159.9kbits/s    
video:97418kB audio:2813kB global headers:0kB muxing overhead 0.419587%
Yet when I play the video, I have no sound. I'm guessing I must be missing the correct library within my configuration for ac3, but can't seem to pinpoint what that is. I've also done some work with mencoder, which works fine for audio, but it has trouble trimming video instead (I think it has issues with key frames, trimming leaves the video choppy).

Do you think this is related to my configuration?
jeffers.r is offline   Reply With Quote
Old May 23rd, 2009   #6
mc4man
Fresh Ground Ubuntu
 
Join Date: Jun 2007
Beans: 5,568
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

While ffplay may playback with sound for other players you probably should add a -target dvd (specify pal or ntsc (edit: in this case ntsc

Ex.
doug@doug-desktop:~$ ffmpeg -i 2.mpg -acodec copy -vcodec copy -t 90 -target ntsc-dvd 2-1.mpg

Last edited by mc4man; May 23rd, 2009 at 05:31 PM..
mc4man is offline   Reply With Quote
Old May 23rd, 2009   #7
jeffers.r
First Cup of Ubuntu
 
Join Date: May 2009
Beans: 9
Xubuntu 10.04 Lucid Lynx
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Wow, that's fantastic. Worked like a charm. Thank you so much!

Quote:
Originally Posted by mc4man View Post
While ffplay may playback with sound for other players you probably should add a -target dvd (specify pal or ntsc

Ex.
ffmpeg -i 2.mpg -acodec copy -vcodec copy -t 90 -target ntsc-dvd 2-1.mpg
jeffers.r is offline   Reply With Quote
Old May 24th, 2009   #8
andrew.46
Still having fun...
 
andrew.46's Avatar
 
Join Date: Dec 2006
Beans: 3,814
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Hi,

Just a quick note to thank FakeOutdoorsman for putting this page together which promises to be of great assistance to the many who struggle with the necessary shortcomings of Ubuntu's stock FFmpeg package.

Andrew
__________________
Do you think that's air you're breathing?
andrew.46 is offline   Reply With Quote
Old July 4th, 2009   #9
andrew.46
Still having fun...
 
andrew.46's Avatar
 
Join Date: Dec 2006
Beans: 3,814
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Hi Fakeoutdoorsman,

Congratulations on Tutorial of the Week for this guide!! A well deserved award.

All the very best,

Andrew
__________________
Do you think that's air you're breathing?
andrew.46 is offline   Reply With Quote
Old July 6th, 2009   #10
Ralph Corderoy
First Cup of Ubuntu
 
Join Date: Apr 2008
Location: UK
Beans: 5
Ubuntu 7.10 Gutsy Gibbon
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Quote:
Originally Posted by FakeOutdoorsman View Post
D. Installing FFmpeg from Medibuntu
This option is only available for Ubuntu Hardy Heron 8.04 and Ubuntu Gutsy Gibbon 7.10.
That's wrong, e.g. it's available for 9.04. See https://help.ubuntu.com/community/Medibuntu

Quote:
Originally Posted by FakeOutdoorsman View Post
Code:
sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list; sudo apt-get -q update; sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring; sudo apt-get -q update
It would be better to use "&&" instead of ";" where possible since "cmd1 && cmd2 && cmd3" only executes cmd2 if cmd1 succeeded, etc.
Ralph Corderoy is offline   Reply With Quote

Bookmarks

Tags
codecs, ffmpeg, medibuntu, restricted, unstripped

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:11 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry