You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How do I encode a GIF? (Changing pixel format appears to not work + error when encoding GIF) #1147
Encoding to GIF does not work, as I get an error about yuv420p not being supported for that format. However, PyAV seems to ignore any attempt I make to overwrite the pixel format of the stream.
Expected behavior
I should be able to save a GIF
Actual behavior
I get an error
Traceback:
[0] for packet in writer.out_stream.encode(out_frame):
[0] File "av\stream.pyx", line 153, in av.stream.Stream.encode
[0] File "av\codec\context.pyx", line 482, in av.codec.context.CodecContext.encode
[0] File "av\codec\context.pyx", line 291, in av.codec.context.CodecContext.open
[0] File "av\error.pyx", line 336, in av.error.err_check
[0] av.error.ValueError: [Errno 22] Invalid argument; last error log: [gif] Specified pixel format yuv420p is invalid or not supported
Investigation
I tried several different ways I hoped would be able to override the pixel format, mainly setting stream.pix_fmt = "gif", assuming that would work based on the numpy example. I also tried setting the attribute elsewhere and in the stream options, to no avail.
changed the title [-]How do I encode a GIF?[/-][+]How do I encode a GIF? (Changing pixel format appears to not work + error when encoding GIF)[/+]on Jul 24, 2023
Activity
[-]How do I encode a GIF?[/-][+]How do I encode a GIF? (Changing pixel format appears to not work + error when encoding GIF)[/+]rkfg commentedon Sep 13, 2023
Use
out_pixel_format='rgb8'