Can MP3 contain AAC?

2

Can the container format MP3 contain an audio with a codec of ACC?

I know that the MP3 container format can contain audio with a codec or MP3 (MP3 is a container and a codec); I thought that was the only codec that MP3 could contain, but my thinking was contradicted.

I was looking at details about a file* with ffmpeg and saw:
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 500x500 [SAR 1:1 DAR 1:1], 48 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 320 kb/s (default)

Look at the part where it says Audio: mp3 (mp4a / 0x6134706D) -- mp4a is the FOURCC identifier of the AAC codec. This is saying that MP3 is containing AAC. I thought that was impossible; is that what is really happening?

*Full details from ffmpeg -i file.mp4:

ffmpeg version N-45325-gb173e0353-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      56.  9.100 / 56.  9.100
  libavcodec     58. 14.100 / 58. 14.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 13.100 /  7. 13.100
  libswscale      5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.18.101
  Duration: 00:05:35.76, start: 0.000000, bitrate: 376 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 500x500 [SAR 1:1 DAR 1:1], 48 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 320 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Rublacava

Posted 2019-06-01T09:15:50.917

Reputation: 113

Could you show the complete ffmpeg output for this file? – user1686 – 2019-06-01T09:32:37.123

With "ffmpeg -i file.mp4"? I'll post that soon. – Rublacava – 2019-06-01T09:38:44.820

Answers

2

MP3 isn't really a container format, it's only a self-contained audio compression format, very similar to raw .aac files. It has a small header to indicate whether the contents are MP1/MP2/MP3 (MPEG-1 layer I/II/III), but it doesn't have a fourcc field, so the mp4a indication must come from elsewhere.

So I think you are interpreting the output backwards – the outer MP4 container has a stream that is tagged with the fourcc 'mp4a', but inside that stream ffmpeg finds an MP3 header followed by normal MP3 data. This can happen if someone used ffmpeg -i Foo.mp3 -codec copy Foo.mp4.

(Raw AAC streams (ADTS) actually use a similar header, which says "MPEG version = 4, layer = 0", but that does not make it "AAC in MP3" in any way. Rather, both headers just share a common intro, and that's what allows programs to distinguish AAC data from MP3 data despite the wrong fourcc.)

user1686

Posted 2019-06-01T09:15:50.917

Reputation: 283 655

1in fact the header is frame header. There's no header for the container – phuclv – 2019-06-03T01:42:03.507

file.mp4 in the question was created with ffmpeg combining one MP3 audio file and one JPG image file into an MP4 video file. So maybe mp4a is a generic label for "MP4 audio" (maybe that is what "mp4a" is an initialism for, IDK), and when mp4a is used as fourcc it is referring to the AAC codec. https://wiki.videolan.org/VLC_Features_Formats/ states that mp3 has fourccs: "mp3", ".mp3", and "LAME" (so they are wrong if you are right). @phuclv - I'm guessing you mean the "header" of the MP3 and not the AAC.

– Rublacava – 2019-06-10T12:57:03.260

More likely ffmpeg just doesn't set the correct fourcc. – user1686 – 2019-06-10T12:58:55.290

1@Rublacava I mean the MP3 file. There's no header, just a linear concatenation of MP3 frames. There's not even a way to know the file duration without iterating through the whole file – phuclv – 2019-06-10T13:20:28.373