Created
May 19, 2022 19:03
-
-
Save whatisor/b74399037b3158bf5d33c4ffc70b3013 to your computer and use it in GitHub Desktop.
Decode h265 bitstream
This file contains 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
#Dependencies: Python 3 | |
# pip install av pillow | |
import av | |
import sys | |
def h265ToJpg(): | |
inputFileName = "rawStream-1-20220519-132954.hevc" | |
container = av.open(inputFileName) | |
print("container:", container) | |
print("container.streams:", container.streams) | |
print("container.format:", container.format) | |
# seek to middle | |
print(container.duration) | |
for frame in container.decode(video = 0): | |
print("process frame: %04d (width: %d, height: %d)" % (frame.index, frame.width, frame.height)) | |
if frame.index > 4000: | |
frame.to_image().save("output//frame-%04d.jpg" % frame.index) | |
def main(): | |
h265ToJpg() | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment