Opened 6 years ago

Last modified 3 years ago

#7287 open defect

Audiotoolbox decodes 24-bit ALAC as 16-bit

Reported by: macdavis Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: Audiotoolbox
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
The sample file is 24-bit, but Audiotoolbox decodes as 16-bit.

How to reproduce:

ffmpeg -c:a alac_at -i /Volumes/New\ Volume/Untitledsample_24_bit_alac.m4a -f null -
ffmpeg version 3.4.git Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --extra-cflags='-Ofast -march=native -m64 -finline-functions -funroll-loops -ffunction-sections -fdata-sections -ffp-contract=fast' --arch=x86_64 --cpu=haswell --disable-ffplay --disable-runtime-cpudetect --disable-debug --disable-opencl --disable-avdevice --enable-libfdk-aac --disable-doc --enable-hardcoded-tables
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 20.104 / 58. 20.104
  libavformat    58. 17.101 / 58. 17.101
  libavfilter     7. 25.100 /  7. 25.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/New Volume/Untitledsample_24_bit_alac.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2018-06-28T17:03:28.000000Z
    iTunSMPB        :  00000000 00000000 00001000 0000000000190000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  Duration: 00:00:37.24, start: 0.000000, bitrate: 219 kb/s
    Stream #0:0(eng): Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16, 1246 kb/s (default)
    Metadata:
      creation_time   : 2018-06-28T17:03:28.000000Z
Stream mapping:
  Stream #0:0 -> #0:0 (alac (alac_at) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    iTunSMPB        :  00000000 00000000 00001000 0000000000190000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    encoder         : Lavf58.17.101
    Stream #0:0(eng): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      creation_time   : 2018-06-28T17:03:28.000000Z
      encoder         : Lavc58.20.104 pcm_s16le
size=N/A time=00:00:07.24 bitrate=N/A speed= 477x    
video:0kB audio:1248kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (2)

Untitledsample_24_bit_alac.m4a (1000.0 KB ) - added by macdavis 6 years ago.
Sample_24_bit_alac
Untitledsample_24_bit_alac_patched.m4a (1000.0 KB ) - added by bpa 6 years ago.
Sample file with alac atom SampleSize set to 24bits

Download all attachments as: .zip

Change History (8)

by macdavis, 6 years ago

Sample_24_bit_alac

comment:1 by bpa, 6 years ago

The problem starts with the input file. The "alac" atom says the file has 16 bit samples (i.e. SampleSize field). I have just found this exact bug in ffmpeg when creating 24 bit ALAC file and was about to file a report. Was Untitledsample_24_bit_alac.m4a created by ffmpeg ?

Selected output from mp4file.

"Untitledsample_24_bit_alac.m4a": type stbl (moov.trak.mdia.minf.stbl)

"Untitledsample_24_bit_alac.m4a": type stsd (moov.trak.mdia.minf.stbl.stsd)

"Untitledsample_24_bit_alac.m4a": version = 0 (0x00)
"Untitledsample_24_bit_alac.m4a": flags = 0 (0x000000)
"Untitledsample_24_bit_alac.m4a": entryCount = 1 (0x00000001)
"Untitledsample_24_bit_alac.m4a": type alac (moov.trak.mdia.minf.stbl.stsd.alac)

"Untitledsample_24_bit_alac.m4a": reserved1 = <6 bytes> 00 00 00 00 00 00 |......|
"Untitledsample_24_bit_alac.m4a": dataReferenceIndex = 1 (0x0001)
"Untitledsample_24_bit_alac.m4a": soundVersion = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": reserved2 = <6 bytes> 00 00 00 00 00 00 |......|
"Untitledsample_24_bit_alac.m4a": channels = 2 (0x0002)
"Untitledsample_24_bit_alac.m4a": sampleSize = 16 (0x0010)
"Untitledsample_24_bit_alac.m4a": compressionId = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": packetSize = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": timeScale = 2890137600 (0xac440000)
"Untitledsample_24_bit_alac.m4a": type alac (moov.trak.mdia.minf.stbl.stsd.alac.alac)

"Untitledsample_24_bit_alac.m4a": decoderConfig = <28 bytes>

comment:2 by macdavis, 6 years ago

Replying to bpa:

Nah, this sample was encoded by MacOS (perhaps Core Audio?)

The problem starts with the input file. The "alac" atom says the file has 16 bit samples (i.e. SampleSize field). I have just found this exact bug in ffmpeg when creating 24 bit ALAC file and was about to file a report. Was Untitledsample_24_bit_alac.m4a created by ffmpeg ?

Selected output from mp4file.

"Untitledsample_24_bit_alac.m4a": type stbl (moov.trak.mdia.minf.stbl)

"Untitledsample_24_bit_alac.m4a": type stsd (moov.trak.mdia.minf.stbl.stsd)

"Untitledsample_24_bit_alac.m4a": version = 0 (0x00)
"Untitledsample_24_bit_alac.m4a": flags = 0 (0x000000)
"Untitledsample_24_bit_alac.m4a": entryCount = 1 (0x00000001)
"Untitledsample_24_bit_alac.m4a": type alac (moov.trak.mdia.minf.stbl.stsd.alac)

"Untitledsample_24_bit_alac.m4a": reserved1 = <6 bytes> 00 00 00 00 00 00 |......|
"Untitledsample_24_bit_alac.m4a": dataReferenceIndex = 1 (0x0001)
"Untitledsample_24_bit_alac.m4a": soundVersion = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": reserved2 = <6 bytes> 00 00 00 00 00 00 |......|
"Untitledsample_24_bit_alac.m4a": channels = 2 (0x0002)
"Untitledsample_24_bit_alac.m4a": sampleSize = 16 (0x0010)
"Untitledsample_24_bit_alac.m4a": compressionId = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": packetSize = 0 (0x0000)
"Untitledsample_24_bit_alac.m4a": timeScale = 2890137600 (0xac440000)
"Untitledsample_24_bit_alac.m4a": type alac (moov.trak.mdia.minf.stbl.stsd.alac.alac)

"Untitledsample_24_bit_alac.m4a": decoderConfig = <28 bytes>

Last edited 6 years ago by macdavis (previous) (diff)

comment:3 by bpa, 6 years ago

Interesting - AFAICT the sample size in your file is 16 bit in alac atom of the MPEG4 header. Is that what you see as well ?

I think players can determine the sample size from the audio stream so can play correctly ignoring MPEG4 ALAC atom details header except to say it is a ALAC stream.

by bpa, 6 years ago

Sample file with alac atom SampleSize set to 24bits

in reply to:  3 comment:4 by macdavis, 6 years ago

Replying to bpa:

I checked the alac atom of the sample that I provided. It does say 16-bit. Anyway, even for your patched sample, which I also checked being 24-bit, Audiotoolbox still treats as 16-bit.

ffmpeg -c:a alac_at -i /Volumes/New\ Volume/Untitledsample_24_bit_alac_patched.m4a -f null -
ffmpeg version 3.4.git Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --extra-cflags='-Ofast -march=native -m64 -finline-functions -funroll-loops -ffunction-sections -fdata-sections -ffp-contract=fast' --arch=x86_64 --cpu=haswell --disable-ffplay --disable-runtime-cpudetect --disable-debug --disable-opencl --disable-avdevice --enable-libfdk-aac --disable-doc --enable-hardcoded-tables
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 20.104 / 58. 20.104
  libavformat    58. 17.101 / 58. 17.101
  libavfilter     7. 25.100 /  7. 25.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/New Volume/Untitledsample_24_bit_alac_patched.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2018-06-28T17:03:28.000000Z
    iTunSMPB        :  00000000 00000000 00001000 0000000000190000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  Duration: 00:00:37.24, start: 0.000000, bitrate: 219 kb/s
    Stream #0:0(eng): Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16, 1246 kb/s (default)
    Metadata:
      creation_time   : 2018-06-28T17:03:28.000000Z
Stream mapping:
  Stream #0:0 -> #0:0 (alac (alac_at) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    iTunSMPB        :  00000000 00000000 00001000 0000000000190000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    encoder         : Lavf58.17.101
    Stream #0:0(eng): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      creation_time   : 2018-06-28T17:03:28.000000Z
      encoder         : Lavc58.20.104 pcm_s16le
size=N/A time=00:00:07.24 bitrate=N/A speed= 129x    
video:0kB audio:1248kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Interesting - AFAICT the sample size in your file is 16 bit in alac atom of the MPEG4 header. Is that what you see as well ?

I think players can determine the sample size from the audio stream so can play correctly ignoring MPEG4 ALAC atom details header except to say it is a ALAC stream.

comment:5 by bpa, 6 years ago

I can't test with alac_at.

So it seems just a coincidence about same error in the mpeg4 header but my bug is different to yours so I'll do a separate report.

Note: See TracTickets for help on using tickets.