Export Animated gif with Image Magick and FFMPEG TOP nodes

   7794   6   6
User Avatar
Member
23 posts
Joined: 7月 2015
Offline
Hello from 2020!
in the era of ImageMagick and FFmpeg integrated in Houdini's TOP, generating our beloved gif should be pretty straight forward.

But, there is something I must be missing.
I am not able to export gif correctly neither using FFMpeg Encode Video TOP nor ImageMagick.

Could you please point me in the right direction?
Below some test and results of my research



TEST 1 - IMAGE MAGICK

1A - gif from image sequence (ROP fetch > IM gif)
2A - gif from mp4 ( rop fetch > ffmpeg to mp4 > IM to gif)


1A - gif is created but seems like the frames are overwriting each other rather than appending in sequence
tried with output file tag file/video and file/image
2A - errors: there are no input images






TEST 2 - FFMPEG ENCODE VIDEO

Getting these errors in the log:
Codec AVOption apply_trc (color transfer characteristics to apply to EXR linear input) specified for input file #0 ([i]"path to framelist"[/i]) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some decoder which was not actually used for any stream.

GIF muxer supports only a single video GIF stream.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
Conversion failed!









Conversation about animated gif:

https://www.sidefx.com/forum/topic/46690/# [www.sidefx.com]

Mestela's Tokeru on ImageMagick and FFMPEG commands:
http://www.tokeru.com/cgwiki/index.php?title=GeneralUtilties#Gifs [www.tokeru.com]
(I have tried these in the command line of IM / FFMPEG tops, no luck)



https://forums.odforce.net/topic/33138-some-looping-rnd-animations/?do=findComment&comment=191821 [forums.odforce.net]
iFightForTheUser posted this code for FFMPEG:

convert-to-GIF(){
    for ARG in $@; do
        file=$ARG
        file_name=${file%.*}
        palette="/tmp/palette.png"
        ffmpeg -y -i $file -vf fps=10,scale=500:-1:flags=lanczos,palettegen $palette
        ffmpeg    -i $file -i $palette -filter_complex "fps=10,scale=500:-1:flags=lanczos[x];[x][1:v]paletteuse" $file_name.gif
    done
    }

not sure how to implement this correctly in the command line.




I am having trouble sending a hip file atm, will do asap if helpful.
TAGs: export animated gif from houdini using ffmpeg image magick TOP PDG nodes. gif conversion. gif output.

Attachments:
IM1.JPG (49.4 KB)
FFMPEG1_mp4_works.JPG (35.9 KB)
FFMPEG1_gif_NOTwork.JPG (43.4 KB)

User Avatar
スタッフ
387 posts
Joined: 8月 2017
Offline
I've attached a .hip file that demonstrates how to configure the FFmpeg node to create a gif from a series of images. You will need a more recent version of Houdini 18.0 as it uses the updated FFmpeg nodes. I will file an RFE to add a preset to the FFmpeg node for creating a gif.

Let me know if you have any other questions.

Attachments:
gif_example.hip (42.7 KB)

User Avatar
Member
58 posts
Joined: 11月 2014
Offline
BrandonA
I've attached a .hip file that demonstrates how to configure the FFmpeg node to create a gif from a series of images. You will need a more recent version of Houdini 18.0 as it uses the updated FFmpeg nodes. I will file an RFE to add a preset to the FFmpeg node for creating a gif.

Let me know if you have any other questions.
Hi I am trying to export gif from flipbooks using the FFmpeg mp4 output so by wirting extension as .gif, output is giving lower quality and lower size gif with jpeg option while
with png option it is output full quality as filp book but far large size gifs like 60mb for 120 frames,
any suggestions to reduce the size while keeping the quality
Houdini Fx Artist (Build)
User Avatar
Member
49 posts
Joined: 2月 2016
Offline
Naga Pavan
BrandonA
I've attached a .hip file that demonstrates how to configure the FFmpeg node to create a gif from a series of images. You will need a more recent version of Houdini 18.0 as it uses the updated FFmpeg nodes. I will file an RFE to add a preset to the FFmpeg node for creating a gif.

Let me know if you have any other questions.
Hi I am trying to export gif from flipbooks using the FFmpeg mp4 output so by wirting extension as .gif, output is giving lower quality and lower size gif with jpeg option while
with png option it is output full quality as filp book but far large size gifs like 60mb for 120 frames,
any suggestions to reduce the size while keeping the quality

https://www.tokeru.com/cgwiki/index.php?title=GeneralUtilties#Gifs [www.tokeru.com]
https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/ [engineering.giphy.com]
These are good guides on reducing the gif sizes
This process involes generating a palatte before the gif so it only keeps minimal number of color in the gif. I haven't try it in TOPS before but it should work with custom commands in two ffmpeg nodes.
User Avatar
Member
20 posts
Joined: 11月 2013
Offline
BrandonA
I've attached a .hip file that demonstrates how to configure the FFmpeg node to create a gif from a series of images. You will need a more recent version of Houdini 18.0 as it uses the updated FFmpeg nodes. I will file an RFE to add a preset to the FFmpeg node for creating a gif.

Let me know if you have any other questions.


So I have a project where I'm using tops to create image sequences each in their own folders which changes using a wedge node. I'd love to use tops to also create a gif of that image sequence. I'm a little bit confused on the ffmpeg node and how to tell it to do this. I saw your example file, and it does technically create gifs of my images, but I don't know how to attach it properly or maybe how to generate the correct frame file list so that it does what I want. If I just connect it to my tops tree after the rop fetch I'm using to generate the sequences it just creates a gif per frame instead of a gif per sequence. Would anyone be able to help me out?


UPDATE: I was able to get this to kind of work by using a "wait for all" node in between the fetch and the ffmpeg nodes. Not fully working, 30% of my gifs failed, but this is looking promising at least
Edited by mhspadez - 2022年4月5日 21:34:37

Attachments:
Capture.PNG (24.3 KB)

User Avatar
Member
13 posts
Joined: 4月 2024
Offline
BrookeA
I've attached a .hip file that demonstrates how to configure the FFmpeg node to create a gif from a series of images. You will need a more recent version of Houdini 18.0 as it uses the updated FFmpeg nodes. I will file an RFE to add a preset to the FFmpeg node for creating a gif.

Let me know if you have any other questions.

Hey! i'm tryin to do this because animated GIF all the things! I lode in an image sequence (PNG) with a filerange top and that cooks fine, but when it gets to the ffmpeg top each one fails, but i don't see an error message...

The PNGs are quite small (32x32) because i'm making psuedo-pixel art (donkey kong country style).

i noticed that in mplay sometimes ffmpeg will fail at that resolution depending on the settings, but it seemed to be an issue with the container/codec there... seems like it should be no problem to make a gif of any size, right?


here is a zip with the files + hip, if anybody can help? ty

Attachments:
gif_example.zip (26.9 KB)

User Avatar
Member
200 posts
Joined: 1月 2014
Offline
Who know how to add a cropping option to that example?
just simple additional option fails
-vf "fps=24, scale=iw*min(1,1/dar):ih*min(1,dar), crop=min(iw,ih):min(iw,ih)"
I contribute to the beauty of this world
https://houdininotes.ivanlarinin.com/ [houdininotes.ivanlarinin.com]
  • Quick Links