Opened 10 years ago

Closed 10 years ago

#1767 closed defect (fixed)

24bit audio in mov is flagged as 16bit in stsd atom

Reported by: TimNich Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

ffmpeg -i 1stream-24.mov -c:a copy 1stream-copy.mov
ffmpeg version N-44123-g5d55830-by_Tim Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep  3 2012 11:18:50 with gcc 4.6 (SUSE Linux)
  configuration: --extra-version=by_Tim --enable-static --disable-shared --enable-gpl --enable-nonfree --enable-version3 --prefix=/mnt/msds-store-0/tim/ffmpeg-tux/usr/local --libdir=/mnt/msds-store-0/tim/ffmpeg-tux/usr/local/lib64 --samples=../fate-suite/ --enable-runtime-cpudetect --extra-cflags='-static -I/mnt/msds-store-0/tim/ffmpeg-tux/usr/local/include' --extra-ldflags='-static -L/mnt/msds-store-0/tim/ffmpeg-tux/usr/local/lib64' --progs-suffix=_Sep-03 --disable-ffserver --enable-libfaac --enable-libfdk-aac --enable-libx264 --enable-libfreetype --disable-ffplay
  libavutil      51. 70.100 / 51. 70.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 25.104 / 54. 25.104
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 15.102 /  3. 15.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1stream-24.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2012-09-27 15:53:44
  Duration: 00:00:41.44, start: 0.000000, bitrate: 1152 kb/s
    Stream #0:0(eng): Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, mono, s32, 1152 kb/s
    Metadata:
      creation_time   : 2012-09-27 15:53:44
      handler_name    : Apple Alias Data Handler
Output #0, mov, to '1stream-copy.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf54.25.104
    Stream #0:0(eng): Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, mono, 1152 kb/s
    Metadata:
      creation_time   : 2012-09-27 15:53:44
      handler_name    : Apple Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=    5828kB time=00:00:41.44 bitrate=1152.1kbits/s    
video:0kB audio:5828kB subtitle:0 global headers:0kB muxing overhead 0.012836%

But upon inspection moov->trak->mdia->minf->stbl atom declares that:-
"sample size= 16"

when it should be

"sample size= 24"

Same happens if you use

ffmpeg -i 1stream-24.mov -c:a pcm_s24be 1stream-recode.mov

Attachments (1)

1stream-24.mov (738.9 KB ) - added by TimNich 10 years ago.
24bit audio made with QT Pro

Download all attachments as: .zip

Change History (8)

by TimNich, 10 years ago

Attachment: 1stream-24.mov added

24bit audio made with QT Pro

comment:1 by TimNich, 10 years ago

Component: FFmpegavformat

in reply to:  description comment:2 by TimNich, 10 years ago

Replying to nichot20:

[....]

But upon inspection moov->trak->mdia->minf->stbl->stsd atom declares that:-
"sample size= 16"

when it should be

"sample size= 24"

Same happens if you use

ffmpeg -i 1stream-24.mov -c:a pcm_s24be 1stream-recode.mov

The problem looks to be in movenc.c around line 654 and on. Basically its either set to 8 or 16

Last edited 10 years ago by TimNich (previous) (diff)

comment:3 by muken, 10 years ago

According to qtff.pdf, when a sound sample description is version=1 or 2, sample size field shall be set to 16.
So, it is not a bug.
The actual sample size is placed more downward.
Early sample size field shall be ignored by readers.

comment:4 by Carl Eugen Hoyos, 10 years ago

Keywords: mov added

in reply to:  3 ; comment:5 by TimNich, 10 years ago

Replying to muken:

According to qtff.pdf, when a sound sample description is version=1 or 2, sample size field shall be set to 16.
So, it is not a bug.
The actual sample size is placed more downward.
Early sample size field shall be ignored by readers.

I note that both the original, and stream copied file have stsd version=0, not the 1 or 2 you mention.

Looking at the code the value is set based upon the value of AV_CODEC_ID_* when (version != 2) and comparison with the original file shows that Quicktime Pro uses a value of 24.

The only other differences to the original file seems to be that QT Pro adds in the extended version info which ffmpeg only adds for version 1 (line 672)

in reply to:  5 comment:6 by TimNich, 10 years ago

Replying to nichot20:

Replying to muken:

According to qtff.pdf, when a sound sample description is version=1 or 2, sample size field shall be set to 16.
So, it is not a bug.
The actual sample size is placed more downward.
Early sample size field shall be ignored by readers.

I note that both the original, and stream copied file have stsd version=0, not the 1 or 2 you mention.

Looking at the code the value is set based upon the value of AV_CODEC_ID_* when (version != 2) and comparison with the original file shows that Quicktime Pro uses a value of 24.

The only other differences to the original file seems to be that QT Pro adds in the extended version info which ffmpeg only adds for version 1 (line 672)

I have now managed to obtain a later copy of qtff.pdf dated 2012-08-14. It would appear that the correct behavior is indeed for stsd->sample size to be only either 8 or 16 for all versions of stsd. But if the actual sample size is greater than 16 bits, then the version should be changed to version 1 and the "bytes per packet" set to reflect the actual value (pages 178-179). Unfortunately Quicktime Pro 7 does not seem to follow this convention, which misled me.

However mov.c is also behaving incorrectly as it is not changing the version from 0 to 1, and adding in the "Sound Description V1 extended info" for bit depths greater than 16 in order to provide the correct value. This can lead to some applications trying to handle the sound as 16 bit.

comment:7 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: newclosed

Fixed by Tim Nicholson.

Note: See TracTickets for help on using tickets.