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

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

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

 
Thread Tools Display Modes
Old April 5th, 2009   #1
FakeOutdoorsman
May the Ubuntu Be With You!
 
FakeOutdoorsman's Avatar
 
Join Date: Sep 2006
Location: Alaska
Beans: 1,585
HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding 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 from the repository
C. Install the ubuntu-restricted-extras package
D. Install FFmpeg from 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 big-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

However, this isn't for everyone. Sometimes you want an official package that works right now. Off to the other options...


B. Installing the unstripped or extra libraries from the repository
This is the quickest option for most users. FFmpeg from the repository does not include many restricted encoders, formats, and codecs including: h261, h263, h263p, aac (libfaac), mp3 (libmp3lame), h264 (libx264), xvid (libxvid), mpeg2video, mpeg4, msmpeg4, msmpeg4v1, and msmpeg4v2. 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 (Applications -> Accessories -> Terminal) and enter:

Ubuntu Karmic Koala 9.10
Code:
sudo apt-get install ffmpeg libavcodec-extra-52
Note: Right now there is no way to encode AAC audio with FFmpeg from the Karmic Koala repository. You will have to compile FFmpeg yourself to do so. Refer to option A. Compile FFmpeg yourself if you would like to encode to AAC audio with FFmpeg. Another option is to use a separate encoder and then combine the video and audio.
Quote:
Originally Posted by paul.gevers View Post
For Karmic the libfaac codec has been disabled in the "extra" (formerly known as unstripped) libraries because it is considered non-free. The only way to get it (AFAICT) is to compile ffmpeg yourself.
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. Installing the ubuntu-restricted-extras package
Another option for Jaunty and Ibex is to install the ubuntu-restricted-extras package (this is not an option for Karmic). This is a metapackage, which means that it will install multiple packages including the "unstripped" FFmpeg libraries. This is a sledgehammer approach, especially if you are bandwidth limited, and will install a large amount of other packages that you may not want. To install this package, open up Terminal (Applications -> Accessories -> Terminal) and enter:

Code:
sudo apt-get install ffmpeg ubuntu-restricted-extras

D. Installing FFmpeg from Medibuntu
This option is only available for 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:

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 the ubuntu-restricted-extras package
Code:
sudo apt-get remove ubuntu-restricted-extras
D. 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 Weeks Ago at 04:03 PM.. Reason: made the titles an ugly baby-poop brown for easier to see topic separation
FakeOutdoorsman is offline   Reply With Quote
Old April 8th, 2009   #2
mocha
Ubuntu Extra Shot
 
mocha's Avatar
 
Join Date: Sep 2006
Beans: 385
Re: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg

Well done. This clears up a lot of confusion.
__________________
System 1: Asus P5B-E | C2D E6420 | 2GB DDR2 | 900GB SATA II | Nvidia 9500GT (G96) | Hauppauge PVR-250 | Twinhan 1022A
System 2: Asus A7N8X-E Dlx | Barton 2600+ | 1GB DDR | 280GB IDE | Nvidia 6200 | WinTV 401
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: 2
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
Ubuntu addict and loving it
 
Join Date: Jun 2007
Beans: 4,168
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: 2
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,006
Ubuntu 9.10 Karmic Koala
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,006
Ubuntu 9.10 Karmic Koala
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 07:38 AM.


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