VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Member
    Join Date
    Aug 2023
    Location
    Turkey
    Search Comp PM
    Hi
    can anyone help to figure out i am stuck and not undertand why ist not work kid to pssh

    also the link its
    https://cdn.bitmovin.com/content/assets/art-of-motion_drm/mpds/11331.mpd

    License URL: https://cwip-shaka-proxy.appspot.com/no_auth

    the defualt kid its
    eb676abbcb345e96bbcf616630f1a3da

    its standing in mpd file and see same with init mp4 same kid thad ok

    so if i calculate the kid to pssh



    import base64

    def get_pssh(keyId):
    array_of_bytes = bytearray(b'\x00\x00\x002pssh\x00\x00\x00\x00')
    array_of_bytes.extend(bytes.fromhex("edef8ba979d64 acea3c827dcd51d21ed"))
    array_of_bytes.extend(b'\x00\x00\x00\x12\x12\x10')
    array_of_bytes.extend(bytes.fromhex(keyId.replace( "-", "")))
    return base64.b64encode(bytes.fromhex(array_of_bytes.hex( )))

    kid = input("Please input KID : ")
    kid = kid.replace(' ', '')
    kid = kid.replace('-', '')
    assert len(kid) == 32 and not isinstance(kid, bytes), "wrong KID length"
    print("PSSH {}".format(get_pssh(kid).decode('utf-8')))


    its calculate wrong pssh
    example its calculate
    pssh : AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEOtnar vLNF6Wu89hZjDxo9o=

    bud thad will not work get b'INVALID_REQUEST'

    bud if i use the pssh from mpd file
    AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsIARIQ62 dqu8s0Xpa7z2FmMPGj2hoNd2lkZXZpbmVfdGVzdCIQZmtqM2xq YVNkZmFsa3IzaioCSEQyAA==

    --key ccbf5fb4c2965be7aa130ffb3ba9fd73:9cc0c92044cb1d694 33f5f5839a159df
    --key 9bf0e9cf0d7b55aeb4b289a63bab8610:90f52fd8ca48717b2 1d0c2fed7a12ae1
    --key eb676abbcb345e96bbcf616630f1a3da:100b6c20940f779a4 589152b57d2dacb
    --key 0294b9599d755de2bbf0fdca3fa5eab7:3bda2f40344c7def6 14227b9c0f03e26
    --key 639da80cf23b55f3b8cab3f64cfa5df6:229f5f29b643e2030 04b30c4eaf348f4

    get the keys

    what is wrong or how can be coreckted this can can budy help me to understand this stration ?

    kind regarts
    Quote Quote  
  2. KID: eb676abbcb345e96bbcf616630f1a3da

    PSSH: AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEOtnar vLNF6Wu89hZjDxo9pI49yVmwY=

    My KID to PSSH output above

    --key eb676abbcb345e96bbcf616630f1a3da:100b6c20940f779a4 589152b57d2dacb

    from Cached data
    Quote Quote  
  3. Member
    Join Date
    Aug 2023
    Location
    Turkey
    Search Comp PM
    Originally Posted by Spectrumhsm View Post
    KID: eb676abbcb345e96bbcf616630f1a3da

    PSSH: AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEOtnar vLNF6Wu89hZjDxo9pI49yVmwY=

    My KID to PSSH output above

    --key eb676abbcb345e96bbcf616630f1a3da:100b6c20940f779a4 589152b57d2dacb

    from Cached data

    i dont need the key
    its about kid to pssh
    Quote Quote  
  4. Member
    Join Date
    Feb 2022
    Location
    Search the forum first!
    Search PM
    Originally Posted by senkron24 View Post
    Hi
    can anyone help to figure out i am stuck and not undertand why ist not work kid to pssh

    pssh : AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEOtnar vLNF6Wu89hZjDxo9o=
    The pssh string contains many fields that identify the media content. The generic kid to pssh scripts cannot work out all the fields. The media provider identity is not in the kid but it 'may' be in the pssh.

    Most sites do not check all the pssh fields so a short form pssh will work - unfortunately for you - your site checks everything it would appear.

    The only way around that is to use a tool to download and search the init.mp4 (usually audio) and find the pssh therein.

    There was a script posted a while back to do this.

    Image
    [Attachment 75695 - Click to enlarge]
    Last edited by A_n_g_e_l_a; 23rd Dec 2023 at 07:30.
    Noob Starter Pack. Just download every Widevine mpd! Not kidding!.
    https://files.videohelp.com/u/301890/hellyes6.zip
    Quote Quote  
  5. Member
    Join Date
    Aug 2023
    Location
    Turkey
    Search Comp PM
    Originally Posted by A_n_g_e_l_a View Post
    Originally Posted by senkron24 View Post
    Hi
    can anyone help to figure out i am stuck and not undertand why ist not work kid to pssh

    pssh : AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEOtnar vLNF6Wu89hZjDxo9o=
    The pssh string contains many fields that identify the media content. The generic kid to pssh scripts cannot work out all the fields. The media provider identity is not in the kid but it 'may' be in the pssh.

    Most sites do not check all the pssh fields so a short form pssh will work - unfortunately for you - your site checks everything it would appear.

    The only way around that is to use a tool to download and search the init.mp4 (usually audio) and find the pssh therein.

    There was a script posted a while back to do this.

    Image
    [Attachment 75695 - Click to enlarge]

    thank you for you answer

    I am sure that
    It does not find PSSH with the init.mp4 method, it searches for kid and calculates it in the traditional way.
    Like the example above, but it is wrong and pssh calculates it wrongly.


    ps : bud will try again with init.mp4
    Last edited by senkron24; 24th Dec 2023 at 03:32.
    Quote Quote  
  6. Member
    Join Date
    Aug 2023
    Location
    Turkey
    Search Comp PM
    Originally Posted by A_n_g_e_l_a View Post
    Originally Posted by senkron24 View Post
    Hi
    can anyone help to figure out i am stuck and not undertand why ist not work kid to pssh

    pssh : AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEOtnar vLNF6Wu89hZjDxo9o=
    The pssh string contains many fields that identify the media content. The generic kid to pssh scripts cannot work out all the fields. The media provider identity is not in the kid but it 'may' be in the pssh.

    Most sites do not check all the pssh fields so a short form pssh will work - unfortunately for you - your site checks everything it would appear.

    The only way around that is to use a tool to download and search the init.mp4 (usually audio) and find the pssh therein.

    There was a script posted a while back to do this.

    Image
    [Attachment 75695 - Click to enlarge]

    big big thanks angela for your help its works

    Code:
    import requests
    import base64
    import subprocess
    import os
    import glob
    import shutil
    
    def find_wv_pssh_offsets(raw: bytes) -> list:
        print('Searching pssh offsets')
        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:
        print('Extracting PSSHs from init file:', file_path)
        return to_pssh(open(file_path, 'rb').read())
    
    def generate_init_mp4(url: str):
        print('Generating init.mp4 using direct MP4 URL...')
        response = requests.get(url, stream=True)
        if response.status_code == 200:
            with open('init.mp4', 'wb') as out_file:
                shutil.copyfileobj(response.raw, out_file)
        else:
            print('Failed to download file. Status code:', response.status_code)
            return None
        return 'init.mp4'
    
    def find_and_process_mp4():
        mp4_files = glob.glob('*.mp4')
        if mp4_files:
            for mp4_file in mp4_files:
                pssh_list = from_file(mp4_file)
                target_pssh = None
                for pssh in pssh_list:
                    if 70 < len(pssh) < 190:
                        target_pssh = pssh
                        break  # Stop searching once a suitable PSSH is found
                if target_pssh:
                    print(f'\n{target_pssh}\n')
                    with open("pssh.txt", "w") as file:
                        print(target_pssh, file=file)
                    return
            print('No suitable PSSH found in any MP4 files.')
        else:
            print('No MP4 files found in the current directory.')
    
    def from_url_or_file():
        user_input = input('Please press Enter to search for *.mp4 files or provide the URL: ')
        if user_input.startswith(('http://', 'https://')):
            if user_input.endswith('.mpd'):
                print('MPD URL detected. Generating init.mp4 using yt-dlp...')
                subprocess.run(['yt-dlp', '--allow-u', '--no-progress', '--console-title', '--output', 'init.mp4', user_input],
                               stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
                find_and_process_mp4()
            else:
                generated_file = generate_init_mp4(user_input)
                if generated_file:
                    find_and_process_mp4()
        else:
            # User pressed Enter, search for *.mp4 files
            find_and_process_mp4()
    
    from_url_or_file()
    Quote Quote  



Similar Threads

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