Search code examples
pythonvideoubuntuffmpegvideo-encoding

Ffmpeg how to encode mpg into 2 channel aac?


This command will of course work:

avconv -i input.mpg -c:v libx264 -s 852x480 -c:a libfaac output.mp4

But that encodes the mpg into a file with these audio settings:

    {
        "index": 1,
        "codec_name": "mp2",
        "codec_long_name": "MP2 (MPEG audio layer 2)",
        "codec_type": "audio",
        "codec_time_base": "1/48000",
        "codec_tag_string": "mp4a",
        "codec_tag": "0x6134706d",
        "sample_fmt": "s16",
        "sample_rate": "48000",
        "channels": 2,
        "bits_per_sample": 0,
        "r_frame_rate": "0/0",
        "avg_frame_rate": "0/0",
        "time_base": "1/48000",
        "start_time": "0.000000",
        "duration": "60.000000",
        "nb_frames": "2500",
        "tags": {
            "language": "und",
            "handler_name": ""
        }
    }

This is what I need:

Resolution: 480p
Ratio: 1.78
Audio: 2 channel AAC
Video Bitrates: 600 / 800 / 1200 / 2000
Audio Bitrates: 96
Codec: H.264 - High

I tried:

avconv -i input.mpg -c:v libx264 -s 852x480 -c:a libfaac output.mp4

But I get error:

Unknown encoder 'libfaac'

Even after I installed libfaac-dev like this:

sudo apt-get install libfaac-dev

Solution

  • ffmpeg(avconv) by default is not built with faac. So, if you did sudo apt-get install avconv, then may not have faac. This can be checked by running ffmpeg -formats , also in the configuration check for --enable-libfaac. To fix it, you will have re-install ffmpeg by adding --enable-libfaac in the ./config step. I follow this guide to build ffmpeg: https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide