Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AC3 Atom support to MP4Info and MP4Dump #122

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

GnaphronG
Copy link

MP4Info doesn't return the info of AC-3 tracks:
For example using the AC-3 file for the HLS Advanced stream example https://developer.apple.com/streaming/examples/:
https://tungsten.aaplimg.com/VOD/bipbop_adv_fmp4_example/a2/main.mp4

$ mp4info main.mp4
...
  Sample Description 0
    Coding:      ac-3 (Dolby Digital (AC-3))
    Sample Rate: 48000
    Sample Size: 16
    Channels:    2
...

The patch returns results similar to EC-3 tracks for AC-3 tracks

$ mp4info main.mp4
...
Sample Description 0
    Coding:      ac-3 (Dolby Digital (AC-3))
    Sample Rate: 48000
    Sample Size: 16
    Channels:    2
    AC3 stream:
        fscod       = 0
        bsid        = 6
        bsmod       = 0
        acmod       = 7
        lfeon       = 1
        bit_rate_code = 10
    AC3 dac3 payload: [0c3d40]
...

@nadimix
Copy link

nadimix commented Aug 14, 2017

Thanks @GnaphronG! This would be really helpful 👍

@@ -711,6 +712,13 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
atom = AP4_Dec3Atom::Create(size_32, stream);
}
break;
case AP4_ATOM_TYPE_DAC3:
if (atom_is_large) return AP4_ERROR_INVALID_FORMAT;
if (GetContext() == AP4_ATOM_TYPE_AC_3) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to support encrypted audio tracks, you could do so by changing this line to the following:
if (GetContext() == AP4_ATOM_TYPE_AC_3 || GetContext() == AP4_ATOM_TYPE_ENCA) {

@barbibulle
Copy link
Contributor

barbibulle commented Aug 16, 2017 via email

m_RawBytes.SetData(payload, payload_size);

// sanity check
if (payload_size < 2) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we want a payload of at least 3 bytes (as we read payload[2] line 86) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this should be < 3

// parse the payload
m_Fscod = (payload[0]>>6) & 0x3;
m_Bsid = (payload[0]>>1) & 0x1F;
m_Bsmod = (payload[0]<<2 | payload[1]>>6) & 0x3;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payload[0] << 2 is meaningless as the line ends with & 0x3. Perhaps we want & 0x7 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This should be masked with 0x7, not 0x3, as the field is 3 bits wide. Thanks for spotting that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants