2010-11-23

[Tip]enable MP3, MPEG4, AAC, and other restricted encoders in FFmpeg

Because of licenses difference between FFmpeg and libfaac/libmp3lame/etc, the offical FFmpeg doesn't support MP3, MPEG4, AAC, and other restricted encoders. However, we could make FFmpeg support these encoders by installing modified packages from third-party repository.

Medibuntu is a third-party repository that contains packages that are unable to be included in the official Ubuntu repositories. We can install modified libavcodec-extra-52 from them.

First, change repository settings:
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

Second, apt-get install libavcodec-extra-52 again:
sudo apt-get install ffmpeg libavcodec-extra-52

Then we are able to use the below command to compress any video file to mp4 with avc/aac stream inside.
ffmpeg -i input.file -acodec libfaac -ab 128k -vcodec libx264 -vpre default -crf 15 -threads 0 output_file.mp4

By the way, we could remove Medibuntu repository:
sudo apt-get autoremove ffmpeg medibuntu-keyring && sudo rm /etc/apt/sources.list.d/medibuntu.list && sudo apt-get update
But I suggest that you should remove modified libavcodec-extra-52 before restoring repository settings to default state.

沒有留言:

張貼留言