axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
1.98k stars 481 forks source link

MP4Info giving incorrect Audio Channel count. Manifest from MP4 Dash has wrong audio channels. #821

Open dgomes-uk opened 1 year ago

dgomes-uk commented 1 year ago

Hi there,

I'm having an issue where MP4Info sees 5.1 audio as:

MPEG-4 Audio Object Type: 2 (AAC Low Complexity) MPEG-4 Audio Decoder Config: Sampling Frequency: 48000 Channels: 6 Sample Rate: 48000 Sample Size: 16 Channels: 2

And manifest from MP4Dash will show file as having 2 channels.

" StreamIndex Chunks="3591" Language="en" Name="audio_en" QualityLevels="1" TimeScale="10000000" Type="audio" Url="QualityLevels({bitrate})/Fragments(audio_en={start time})" QualityLevel AudioTag="255" Bitrate="272050" BitsPerSample="16" Channels="2" CodecPrivateData="131056e598" FourCC="AACL" Index="0" PacketSize="4" SamplingRate="24000"/ " I have tried different version of Bento4 with no luck.

Any ideas?

Thanks

barbibulle commented 1 year ago

There are many variants for how AAC audio info is signaled in MP4 files. If you can share an example file that shows this behavior, we can check if the issue is with the file, or the tool.

riba101 commented 1 year ago

Hi There,

I experience the same with this file. It is an Audio only MP4 with 6 channels (5.1) encoded in aac-lc.

https://user-images.githubusercontent.com/7966755/213494986-6c65e678-0df3-4941-8c6f-00f6e5ffbd20.mp4

Many thanks in advance!

dgomes-uk commented 1 year ago

Hi, Please see audio file and screenshot of MP4Info below.

Thanks

https://user-images.githubusercontent.com/119940566/213653084-09c45e30-6731-403b-8e4e-02b27891be55.mp4

channels

barbibulle commented 1 year ago

This looks normal. The way multi-channel audio is supported in MP4 files is a bit odd, having to do with some level of backward compatibility. For AAC in mp4, the "outer" signaling, in the "sample description", is ignored when the codec has its own signaling for multi-channel. This is why here mp4info shows you the "outer" value (read from the mp4 file) as "Channels: 2", and the "inner" value (which it gets by parsing the actual codec-specific info) as "Channels: 6". mp4info just reflects what's found in the file. Now, for dash, that should be handled correctly. The output of mp4dash for this file will have a manifest like this:

<?xml version="1.0" ?>
<MPD mediaPresentationDuration="PT2M0.043S" minBufferTime="PT2.00S" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011">
  <!-- Created with Bento4 mp4-dash.py, VERSION=2.0.0-639 -->
  <Period>
    <!-- Audio -->
    <AdaptationSet lang="en" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
      <SegmentTemplate duration="2000" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4s" startNumber="1" timescale="1000"/>
      <Representation audioSamplingRate="48000" bandwidth="317361" codecs="mp4a.40.2" id="audio/en/mp4a.40.2">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="6"/>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

As you can see, the channel count is correct: <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="6"/>.

Which invalid mp4 dash manfiest are you referring to? Did you generate it with the mp4dash tool? Which version.

dgomes-uk commented 1 year ago

Hi Gilles, Thanks for looking into this and all your help so far.

I have tried it again and got the same results. it could be something with the commands I'm sending, so will try to share everything here.

Please note I can only complete all the steps with v. Bento4-SDK-1-5-0-613 - I can see you have used 2.0 in your example.

I've tried Bento4-SDK-1-6-0-639 and got invalid syntax. With Bento4-SDK-1-5-1-628 I get Error AVC_sps

Commands I'm using are: Fragment: C:\Bento4-SDK-1-6-0-639.x86_64-microsoft-win32\bin\mp4fragment.exe --index --trim --timescale 10000000 --fragment-duration 2000 --track 1 "input_location\input_file” “output_location\output_file”

Manifest: C:\Python27\python.exe C:\Bento4-SDK-1-5-0-613.x86-microsoft-win32-vs2010\utils\mp4-dash.py --always-output-lang --language-map=und:EN --no-media --smooth --smooth-client-manifest-name=test_mp4dash.ismc --smooth-server-manifest-name=test_mp4dash.ism -f -o Output_location Input_file_01 Input_file_02 Input_file_03

Manifest shows 5.1 as 2.0: image

Maybe something wrong in one of the commands I'm using?

Thank you!

riba101 commented 1 year ago

Ive dove a build from the latest code and when using mp4dash with the -hls flag. I get a correct 6 channel audio entry in the dash manifest but in HLS it says 2 channels.

image

Here are the commands i've used.

mp4fragment './aaclc-51.mp4' './aaclc-51-fragmented.mp4' --track audio
mp4fragment './avc-720p.mp4' './avc-720p-fragmented.mp4' --track video

mp4dash \
    './avc-720p-fragmented.mp4' \
    './aaclc-51-fragmented.mp4' \
    -f \
    --hls \
    --language-map=und:eng \
    --profiles=live \
    --use-segment-timeline \
    --hls-master-playlist-name index.m3u8 \
    --mpd-name index.mpd \
    -o 'output-dash/'