Created
February 15, 2025 02:02
-
-
Save Diniboy1123/4882b143ec97bc70289f4c372712231b to your computer and use it in GitHub Desktop.
Test script to demonstrate EC-3 box transformation from Microsoft Smooth Streaming CodecPrivateData
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/hex" | |
"log" | |
"github.com/Eyevinn/mp4ff/mp4" | |
) | |
// based on https://github.com/axiomatic-systems/Bento4/blob/3bdc891602d19789b8e8626e4a3e613a937b4d35/Source/Python/utils/mp4utils.py#L1047-L1054 | |
// MFA GUID from https://www.magnumdb.com/search?q=filename%3A"mfapi.h" | |
var DDP_WAVEFORMAT_GUID = []byte{0xaf, 0x87, 0xfb, 0xa7, 0x02, 0x2d, 0xfb, 0x42, 0xa4, 0xd4, 0x05, 0xcd, 0x93, 0x84, 0x3b, 0xdd} | |
func main() { | |
customPrivateDataHex := "000603000000AF87FBA7022DFB42A4D405CD93843BDD0600200400" | |
customPrivateData, _ := hex.DecodeString(customPrivateDataHex) | |
dec3Payload := extractDolbyDigitalPlusInfoFromSmoothData(customPrivateData) | |
dec3Box, err := mp4.DecodeDec3(mp4.BoxHeader{}, 0, bytes.NewReader(dec3Payload)) | |
if err != nil { | |
panic(err) | |
} | |
log.Printf("Dec3 box: %+v", dec3Box) | |
} | |
func extractDolbyDigitalPlusInfoFromSmoothData(info []byte) []byte { | |
if bytes.Compare(info[8:24], DDP_WAVEFORMAT_GUID) != 1 { | |
panic("Missing DDP_WAVEFORMAT_GUID") | |
} | |
dec3Payload := info[6+len(DDP_WAVEFORMAT_GUID):] | |
return dec3Payload | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment