ffmpeg gif compiling gif frames out of order

   2026   4   0
User Avatar
Member
20 posts
Joined: Nov. 2013
Offline
I have a tops tree that exports an image sequence (jpeg) perfectly, moves to another wedge value, and then exports another sequence, and so on. Then downstream I have an "ffmpeg encode video" which is kinda working -- meaning it generates a gif for each sequence which is what I was hoping for --- except some of the frames seem to be out of order, so the gif appears as if it's skipping or glitching, and it does this for each one of the sequences.

The image sequence is exported with frame padding ($F4) and the frame range never exceeds the 4th digit, in fact it easily stays safely within 3 digits. Does anyone have any suggestions on how I might be able to fix this? ss of ffmpeg settings is attached
Edited by mhspadez - April 8, 2022 14:55:48

Attachments:
Capture.PNG (49.4 KB)

User Avatar
Staff
600 posts
Joined: May 2014
Offline
Can you attach a .hip file that reproduces the issue you're seeing?
User Avatar
Member
20 posts
Joined: Nov. 2013
Offline
yup! I've attached a .hip that should replicate the issues, and the mp4 and the gif that they generate -- thank you for looking into this

Attachments:
debug_v1.hiplc (2.1 MB)
char_1.gif (369.7 KB)
char_1.mp4 (237.0 KB)

User Avatar
Staff
600 posts
Joined: May 2014
Offline
There are a few issues with the TOP network in that file.

The first issue is that the Wedge node creates three wedges, with integer "seed" values of 0, 0, and 1. That means that the second set of 30 frames is a duplicate of the first set of 30. Since the Wait for All is configured to split by the "seed" attribute, the first partition in that node ends up with 60 work items in it. The partition will therefore contain two frame 1 work items, two frame 2s, etc. To fix that, either a) the Wedge should be changed to not create duplicate values for "seed" or b) the Wait for All should instead by configured to split by the "wedgeindex" attribute.

The second issue, which is also the main problem, is that your Wait for All has the "Sort Contents" parameter set to "None". That means the partitions in that node will be completely unsorted/in random order. The output files on the partition match the sort order of the work items in that partition, so the file order will also be jumbled. The FFMPEG node uses the files in the order that they're specified on the input, so that also affects the .gif. Setting "Sort Contents" back to the default "Work Item Index", along with the change mentioned in the previous paragraph, should fix your .gifs.
Edited by tpetrick - April 11, 2022 18:25:15
User Avatar
Member
20 posts
Joined: Nov. 2013
Offline
Thank you for taking a look at this and figuring it out. You exactly figured out what was going on and making those changes have fixed the issue I was having. Much appreciated!

"Sort contents: none" was a bit misleading to me -- friendly suggestion to change that to "random" -- for sidefx consideration. :S
  • Quick Links