w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
941 stars 132 forks source link

WebCodecs: Missing "REXT profile signaling" in decoder config for AVC #664

Closed Vanilagy closed 1 year ago

Vanilagy commented 1 year ago

Posting here since Chromium bug tracker (still) gives me a 500 whenever I try to submit. Please fix, I feel bad for spamming the wrong channel 🥺

Chrome Version : 112.0.5615.49 (Official Build) (arm64) URLs (if applicable) : https://gossamer-unmarred-ogre.glitch.me/ Other browsers tested: No Add OK or FAIL, along with the version, after other browsers where you have tested this issue: Safari: Firefox: Edge:

What steps will reproduce the problem? https://gossamer-unmarred-ogre.glitch.me/ This will reproduce the problem. It also implements a small parser for the decoder config to verify the problem occurring.

What is the expected result? The decoder config for the AVC stream is expected to adhere to the format specified in ISO/IEC 14496-15 (https://ossrs.io/lts/zh-cn/assets/files/ISO_IEC_14496-15-AVC-format-2012-345a5b466cc73e978fd9dd0840361e8b.pdf), page 16:

aligned(8) class AVCDecoderConfigurationRecord {
    unsigned int(8) configurationVersion = 1;
    unsigned int(8) AVCProfileIndication;
    unsigned int(8) profile_compatibility;
    unsigned int(8) AVCLevelIndication;
    bit(6) reserved = ‘111111’b;
    unsigned int(2) lengthSizeMinusOne;
    bit(3) reserved = ‘111’b;
    unsigned int(5) numOfSequenceParameterSets;
    for (i=0; i< numOfSequenceParameterSets; i++) {
        unsigned int(16) sequenceParameterSetLength ;
        bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;
    }
    unsigned int(8) numOfPictureParameterSets;
    for (i=0; i< numOfPictureParameterSets; i++) {
        unsigned int(16) pictureParameterSetLength;
        bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
    }
    if( profile_idc == 100 || profile_idc == 110 ||
        profile_idc == 122 || profile_idc == 144 )
    {
        bit(6) reserved = ‘111111’b;
        unsigned int(2) chroma_format;
        bit(5) reserved = ‘11111’b;
        unsigned int(3) bit_depth_luma_minus8;
        bit(5) reserved = ‘11111’b;
        unsigned int(3) bit_depth_chroma_minus8;
        unsigned int(8) numOfSequenceParameterSetExt;
        for (i=0; i< numOfSequenceParameterSetExt; i++) {
            unsigned int(16) sequenceParameterSetExtLength;
            bit(8*sequenceParameterSetExtLength) sequenceParameterSetExtNALUnit;
        }
    }
}

What happens instead? When the profile_idc is 100, like in this case, the bottom block (with the if-statement) is incorrectly not included in the decoder config. When running an .mp4 file containing data generated by the WebCodecs API through MP4Box's -info tool, it says:

[isom/avcc] Missing REXT profile signaling, patching.

which is caused by this branch in GPAC: https://github.com/gpac/gpac/blob/647e4d353e9b90e7f675186c9162767977c3176e/src/isomedia/avc_ext.c#L2857

Scanning the GPAC code, it seems like many files forget to include this (which is why they tolerate it), but would be cool to stick to the spec here.

Djuffin commented 1 year ago

I'm sorry that https://bugs.chromium.org/ doesn't work for you, Please keep feedback going. I opened a bug against Chromium https://crbug.com/1433391