ws = create_connection(url, headers=headers)# Then send a message through the tunnelws.send('ping')start = timeit.default_timer()flag = Trueoutput = []while flag: output.append(ws.recv()) if timeit.default_timer() - start > 90: flag = Falseresult = output[0][8:]for msg in output[1:]: if msg[0] == 249: moofmdat = b'' moof = b'' continue if msg[0] == 252: vidbuf = msg[4:] if msg[0] == 251: moof += msg[4:] if msg[0] == 254: mdat = msg[4:] if msg[0] == 255: moofmdat += moof moofmdat += mdat moofmdat += vidbuf result += moofmdatwith open('test.mp4', 'wb') as file: file.write(result)
Figured it out. The MOOV header has 8 bytes of unnecessary information that must be removed. Each additional message (besides PBT_Begin and PBT_End) have 4 bytes of player specific data. Just needed to clean up each message and place in the correct order. Then save the raw bytes out as a mp4 and voila, video that plays in vlc.