PyAV-Org / PyAV

Pythonic bindings for FFmpeg's libraries.
https://pyav.basswood-io.com/
BSD 3-Clause "New" or "Revised" License
2.44k stars 359 forks source link

PyAV Incorrect Decoding of QuickTime Video #1477

Closed hnhuang closed 1 month ago

hnhuang commented 1 month ago

PyAV (version 12.3.0) decodes QuickTime videos incorrectly, resulting in the color appearing with too much exposure. This issue affects the visual quality and accuracy of the decoded video.

My code to decode the QuickTime videos:

` count = 0 for fn in movieLists: print('Now processing: ', fn) try: container = av.open(fn) except Exception as e: print(e) continue

rotateCode = check_rotation(container.streams.video[0].metadata)
print("rotate code = ", rotateCode)

frames = container.decode(video=0)

for frame in frames:
    image = frame.to_image()
    if rotateCode is not None:
        image = image.transpose(method=rotateCode)

    image.save(imageFolder + '/' + str(count) + '.jpg')
    count += 1

` One of the images I obtain:

20

But it should be like this one:

20

WyattBlue commented 1 month ago
image = frame.to_image()

The Pillow library is the one actually changing the color space here.