VideoHelp Forum



Support our site by donate $5 directly to us Thanks!!!

Try StreamFab Downloader and download streaming video from Netflix, Amazon!



+ Reply to Thread
Results 1 to 3 of 3
  1. When I run
    Code:
    mp4dump --verbosity 3 --format json XXX.mp4 > pssh.txt
    it can get the hex code for the data that required to produce a full info PSSH. However, it will have a pretty big txt file.

    Image
    [Attachment 78866 - Click to enlarge]


    Any quick way to dump this info ?
    Quote Quote  
  2. Jep, at least if you just search for the PSSH. Posted several times already - here's my way:

    Code:
    import base64
    import sys
    from pywidevine import PSSH
    
    def find_wv_pssh_offsets(raw: bytes) -> list:
        offsets = []
        offset = 0
        while True:
            offset = raw.find(b'pssh', offset)
            if offset == -1:
                break
            size = int.from_bytes(raw[offset-4:offset], byteorder='big')
            pssh_offset = offset - 4
            offsets.append(raw[pssh_offset:pssh_offset+size])
            offset += size
        return offsets
    
    def to_pssh(content: bytes) -> list:
        wv_offsets = find_wv_pssh_offsets(content)
        return [base64.b64encode(wv_offset).decode() for wv_offset in wv_offsets]
    
    def from_file(file_path: str) -> list:
        with open(file_path, 'rb') as f:
            buffer = f.read(2048) # 1_048_576)
        return to_pssh(buffer)
    
    pssh_list = from_file(sys.argv[1])
    target_pssh = None
    for item in pssh_list:
        pssh = PSSH(item)
        if pssh.system_id == PSSH.SystemId.Widevine:
            print(pssh)
    The "2048" in line 24 might be too small and might only work for "faststart MP4" where the moov atom is located at the very beginnig of the file. You can raise that number to e.g. 1 MB.
    Quote Quote  
  3. Originally Posted by Obo View Post
    Jep, at least if you just search for the PSSH. Posted several times already - here's my way:

    Code:
    import base64
    import sys
    from pywidevine import PSSH
    
    def find_wv_pssh_offsets(raw: bytes) -> list:
        offsets = []
        offset = 0
        while True:
            offset = raw.find(b'pssh', offset)
            if offset == -1:
                break
            size = int.from_bytes(raw[offset-4:offset], byteorder='big')
            pssh_offset = offset - 4
            offsets.append(raw[pssh_offset:pssh_offset+size])
            offset += size
        return offsets
    
    def to_pssh(content: bytes) -> list:
        wv_offsets = find_wv_pssh_offsets(content)
        return [base64.b64encode(wv_offset).decode() for wv_offset in wv_offsets]
    
    def from_file(file_path: str) -> list:
        with open(file_path, 'rb') as f:
            buffer = f.read(2048) # 1_048_576)
        return to_pssh(buffer)
    
    pssh_list = from_file(sys.argv[1])
    target_pssh = None
    for item in pssh_list:
        pssh = PSSH(item)
        if pssh.system_id == PSSH.SystemId.Widevine:
            print(pssh)
    The "2048" in line 24 might be too small and might only work for "faststart MP4" where the moov atom is located at the very beginnig of the file. You can raise that number to e.g. 1 MB.
    My lazy..haha no idea for the keywords.

    But works perfectly, for my case 4096 (2MB) is needed
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!