gifski icon indicating copy to clipboard operation
gifski copied to clipboard

different frame duration

Open colaub opened this issue 6 years ago • 14 comments

Hello, awesome work! Is there or are you plan to have a way to define the duration of each frame? And avoid giving ten times the same frame to get this one longer.

Thank you!

colaub avatar Oct 17 '19 13:10 colaub

The library supports this, but I don't see how to expose that on command line.

kornelski avatar Oct 17 '19 23:10 kornelski

Ideally, the way to expose it would be a flag like --acceptdelay and filenames in the folder could opt to specify the number of milliseconds in the filenames.

So for example a gif with a long pause would be something like this

frame001-3000ms.png
frame002.png
frame003.png
frame004.png
frame005.png
frame006.png

frame001 would have it's delay overridden by 3000ms, the rest would follow the normal length specified by --fps.

This could allow absolutely insane optimization for gif production if someone has the patience to use it, so I really hope you can expose it somehow to cli.

also this issue is practically a duplicate of #31

cheatfreak47 avatar Aug 05 '21 18:08 cheatfreak47

--delay 2000,2000,6000

it would be great for me. If gif have more frames than specified in the argument, then maybe to cut off the extra frames.

I understand the fact this library is designed for video, but it's useful for gif "slideshows" too. Thank you

SARFEX avatar Aug 27 '21 13:08 SARFEX

if you can build it from source, use this PR https://github.com/ImageOptim/gifski/pull/102 (unfortunately closed without reasons)

colaub avatar Aug 27 '21 13:08 colaub

I'm surprised that there's a demand for this feature. I didn't expect people would micromanage frames like that, or use it for anything other than video.

I can't think of a nice user interface for this. A command-line switch like --delay will be hard to use for more than a few frames. I'd have to invent some micro-language to specify ranges of frames to avoid typing the same delay 100 times.

Timing in file names themselves may require using some mass-renaming applications, or hundreds of mouse clicks. That doesn't feel nice either.

Maybe taking frames from a CSV file, with a column for filename and a delay?

kornelski avatar Aug 31 '21 12:08 kornelski

Yes, I am agreed with you, have a name-based frame duration is not handy... And CSV could be a bit overkill. In some cases, we composed the command line with a python loop, so manage a flag for each frame is doable. What about something like frame1.png --delay=1000 frame2.png frame3.png --delay==3000 it's close with some weird ffmpeg commandline syntax :D ?

colaub avatar Aug 31 '21 12:08 colaub

Timing in file names themselves may require using some mass-renaming applications, or hundreds of mouse clicks. That doesn't feel nice either.

I still think it'd be nice to be able to just manually override the normal delay set by --fps on just some frames you want to specifically tweak, and btw, mass renaming is already usually required, we're talking about usually hundreds of numbered PNG input files here lol

cheatfreak47 avatar Aug 31 '21 13:08 cheatfreak47

And CSV could be a bit overkill. In some cases, we composed the command line with a python loop, so manage a flag for each frame is doable.

I completely disagree with CSV or Filename based being overkill

the vast majority of gif production methods involve setting a specific delay for each frame, take GIMP for example, you can override the default by adding a number of ms to the layer in parenthesis

I actually think CSV sounds really cool assuming it's not hard for a normal person to turn a folder of files into a text file, still though, that's adding complexity where it may not be needed always

My only major suggestion, regardless of implementation is you NEED to allow setting a default delay time, and also allowing --fps as the default delay for frames with unspecified delays in a csv, or filename, or whatever

cheatfreak47 avatar Aug 31 '21 13:08 cheatfreak47

I use GifSki a lot, pretty much any time I need to make a gif for any reason my ideal implementation would allow something like

gifski frame*.png --fps 20 --delay=filename to be accepted or gifski frame*.png --defaultdelay 200 --delay=delays.csv produces a gif where all frames are 200ms delay except frames listed in delays.csv, example csv

frame01.png,200ms
frame22.png,300ms
frame43.png,400ms

the csv should not require all files to be listed, just the ones that need custom delay, if the user wants to specify all delays, they can if they want to if the user sets --fps instead of --defaultdelay it would set delays on every frame as if it were the fps specified, but override the frames specified in the csv with the specific values

cheatfreak47 avatar Aug 31 '21 13:08 cheatfreak47

Would it be an option to pass frames on stdin instead of the commandline for complex parameters? Specifically as a structured json input:

gifski --fps 20 --frames-from-stdin << EOF
[
  { "frame": "frame01.png", "delay": "200ms" },
  { "frame": "frame02.png", "_comment": "default delay chosen by fps" },
  { "frame": "frame03.png", "delay": "55000000ns" },
  { "frame": "frame04.png", "delay": 0.05 },
  { "frame": "frame05.png", "delay": 4 },
  { "frame": "frame06.png", "quality": 30, "comment": "future extension?" },
]
EOF

I suppose this could combine quite nicely with jq or other json-document manglers.

197g avatar Oct 18 '21 06:10 197g

Actually some ideas are better and some ideas not so cool but the most important thing is adding the feature, so is there any workaround or short-term plan about the issue? :)

mehmetakify avatar Jun 06 '22 17:06 mehmetakify

I need this feature as well!!

linustws avatar Apr 10 '23 13:04 linustws

I would really like to have a feature like this too!

IZeeLikeEyeZee avatar Apr 30 '23 23:04 IZeeLikeEyeZee

I would love to see this implemented, I extracted the frames from an animated webp using "anim_dump" from the webp codec, matched the initial frame duration with --fps and converted it to gif using gifski, but I noticed the resulting file was slower in some parts and missing a ton duplicate frames at the end. Using "webpmux -info" from the webp codec on the original file showed me half way through the animation the frame duration decreased from 100ms to 90ms and 80ms as well as the final frame being set to 1500ms. Although this is a pretty uncommon use case for gifski, it would be an awesome feature for situations like this.

Vexadros avatar Aug 14 '23 08:08 Vexadros