This content originally appeared on DEV Community and was authored by Mansour Moufid
Convert the string "H264" to an integer code:
sum([ord(c) << (i * 8) for i, c in enumerate("H264")])
Convert the integer code (0x34363248) back to a string:
''.join([chr((0x34363248 >> (i * 8)) & 0xff) for i in range(4)])
See this gist: https://gist.github.com/eliteraspberries/b017f998c97c395881f0d2f05a08ec60
This content originally appeared on DEV Community and was authored by Mansour Moufid

Mansour Moufid | Sciencx (2022-03-28T23:37:33+00:00) Encode and decode FourCC codes, in Python. Retrieved from https://www.scien.cx/2022/03/28/encode-and-decode-fourcc-codes-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.