0

I'm trying to convert an mp3 audio file to an AAC file with FFMPEG, and I need the audio to be wrapped in an MPEG-2 container. The resulting AAC file needs to be AAC-LC (Low Complexity), 1-channel, CBR mode, 44100 sample rate, and 48kb/s bitrate, so I use this command:

ffmpeg -y -i input.mp3 -ar 44100 -ab 48k -acodec libfdk_aac -ac 1 output.aac

But when I examine the ADTS headers, the audio file is always being wrapped in an MPEG-4 container. I have tried all the codecs listed here but I still end up with an mpeg-4 container wrapped around the audio: http://trac.ffmpeg.org/wiki/AACEncodingGuide.

Here are the headers I get when examining the AAC output file:

mpeg_type: 'MPEG4', profile: 2, profile_name: 'AAC LC', sample_freq: 44100, channel_config: 1, channels: 1, frame_length: 139, buffer_fullness: 157, number_of_frames: 1, frames_per_sec: 43.06640625

Any ideas as to why ffmpeg wraps an mp4 container around the audio? Can I get around this somehow? Are there any other encoders I can try aside from FFMPEG? I was giving FAAC encoder a shot and it gives me the proper encoding and ADTS headers, but alas it does not support mp3, only WAV.

3 Answers 3

2

Your terminology is a bit confused. first, mp4 is NOT the same thing as mpeg4. mpeg4 is an encompassing term to describe all sorts of codecs and containers. the mp4 container is also known as mpeg4 part 14. the aac container format is just a collection of raw aac frames with ADTS headers, it is described in mpeg4 part 3. hence .aac is a mpeg4 format but NOT an mp4 file.

http://en.wikipedia.org/wiki/MPEG-4

Now as far as wanting an mpeg2 container, It is a mpeg2 transport stream, program stream?

Sign up to request clarification or add additional context in comments.

8 Comments

Can you explain what the second value in an ADTS header refers to? Looking at the description of ADTS headers here: wiki.multimedia.cx/index.php?title=ADTS What is an MPEG Version? I need my header to have version MPEG-2, and I was actually able to achieve this by reading advice here: stackoverflow.com/questions/15133393/… I had to download the ffmpeg source code and edit the libfaac.c file to change the default config from MPEG4 to MPEG2. It then worked after using the libfaac codec with same options as before.
As far as mpeg2 stream goes, I need a transport stream since I will be using this audio for a livestream, which seems to be the better option.
Set your output file name to output.ts, and keep ADTS value as mpeg4. This will put a MPEG4 elementary stream inside a MPEG2 transport stream.
This was not the correct solution. Keeping the ADTS value as mpeg4 wraps a bunch of hexidecimal values that cannot be interpreted properly when dealing with a livestream. Headers need to begin with 0xFFF which I can achieve only through changing FFMPEG's ADTS version to MPEG-2.
What is your playback device that is requiring this format? It seems like something I am sell familiar with.
|
1

To get ffmpeg & libfdk_aac to set the flag to mpeg2 instead of mpeg4 use an mpeg2 profile:

ffmpeg -y -i input.mp3 -ar 44100 -ab 48k -acodec libfdk_aac -aprofile mpeg2_aac_low -ac 1 output.aac

Comments

0

I was able to successfully change the MPEG container by following advice here:

FFmpeg's AAC ("libfaac") Codec Options?

I needed to go into FFmpeg's source code and change the hard-coded MPEG version in libfaac.c to MPEG2, at line 115 (a few lines up from what is mentioned in the other post). I then recompiled FFmpeg, making sure to include --enable-libfaac.

1 Comment

Anyone figure out a way to do this with libfdk_aac? The quality of that library is better than libfaac.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.