Kosinkadink / ComfyUI-VideoHelperSuite

Nodes related to video workflows
GNU General Public License v3.0
434 stars 76 forks source link

better use ffmpeg way to make gif,becuase it gives better result, Image comparison: #160

Closed huanggou666 closed 1 month ago

huanggou666 commented 4 months ago
1Snipaste_2024-02-23_11-26-36

in the image I uploaded,the middle one, your code generated gif , you can see the girl's lip is grey, the one on the right ,the gif I use ffmpeg way to generate ,the lip of the girl is the original red color, the nodes on the right is comfy_mtb, this node originally generates the same gif as VideoHelperSuite, but I used chatgpt to change their code to use ffmpeg way of making a gif, but failed to get VideoHelperSuite to use ffmpeg way to make a gif (keeps getting bugs), hope you guys can fix it

AustinMroz commented 4 months ago

Adding support for encoding gifs with ffmpeg was the original motivation behind the naming for multiple passes in video formats, since proper gif encoding with ffmpeg requires two passes with palettegen and paletteuse. However after doing some A/B testing with the initial implementation, I found (unexpectedly) that encoding gifs with ffmpeg was producing worse visual artifacts than pillow and scrapped the implementation.

Support has since been added for encoding gifs with gifski (see #79 and a2900c3), which uses fancy alpha blending to provide higher quality output then ffmpeg can. Consequentially, I don't foresee this feature being a particularly high priority, but when I get a chance, I'll make a follow-up post with more through testing to at least confirm I wasn't making some major mistake in my scrapped implementation.

huanggou666 commented 4 months ago

Thanks for your reply, but gifski says it can't convert video directly, you should convert video to PNG image first,

AustinMroz commented 4 months ago

Sorry about that. When adding supported for gifski I had compiled from source and failed to consider that support for converting from videos wouldn't be enabled in the binary releases.

After further testing, the visual artifacts I was seeing when producing gifs with ffmpeg were merely a result of the default settings used for dither. I will add support for producing gifs with ffmpeg.

huanggou666 commented 4 months ago

I got this error ,when I try ffmpeg gifs , Error occurred when executing VHS_VideoCombine:

An error occurred in the ffmpeg prepass: [image2 @ 000002c4166e38c0] Could not open file : temp/palette.png [vost#0:0/png @ 000002c4166e64c0] Error submitting a packet to the muxer: I/O error [out#0/image2 @ 000002c4166bb2c0] Error muxing a packet

File "E:\ALLWEBUI\comfyui\ComfyUI_windows_portable\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\ALLWEBUI\comfyui\ComfyUI_windows_portable\ComfyUI\execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\ALLWEBUI\comfyui\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\ALLWEBUI\comfyui\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-VideoHelperSuite\videohelpersuite\nodes.py", line 371, in combine_video raise Exception("An error occurred in the ffmpeg prepass:\n" \