Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different frame duration #101

Open
colaub opened this issue Oct 17, 2019 · 14 comments
Open

different frame duration #101

colaub opened this issue Oct 17, 2019 · 14 comments

Comments

@colaub
Copy link

colaub commented Oct 17, 2019

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!

@kornelski
Copy link
Member

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

@cheatfreak47
Copy link

cheatfreak47 commented Aug 5, 2021

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

@SARFEX
Copy link

SARFEX commented Aug 27, 2021

--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

@colaub
Copy link
Author

colaub commented Aug 27, 2021

if you can build it from source, use this PR #102 (unfortunately closed without reasons)

@kornelski
Copy link
Member

kornelski commented Aug 31, 2021

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?

@colaub
Copy link
Author

colaub commented Aug 31, 2021

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 ?

@cheatfreak47
Copy link

cheatfreak47 commented Aug 31, 2021

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
Copy link

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
Copy link

cheatfreak47 commented Aug 31, 2021

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

@HeroicKatora
Copy link

HeroicKatora commented Oct 18, 2021

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.

@mehmetakify
Copy link

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? :)

@linustws
Copy link

I need this feature as well!!

@IZeeLikeEyeZee
Copy link

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

@Vexadros
Copy link

Vexadros commented Aug 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants