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

Support for GIF looping in recorded video output #2891

Merged
merged 4 commits into from
May 12, 2023

Conversation

ztangent
Copy link
Contributor

@ztangent ztangent commented Apr 22, 2023

Description

Adds the loop option to the VideoStreamOptions struct, and adds loop as a keyword argument to VideoStream, which is passed on to FFMPEG. This allows control over the number of times a GIF is looped for videos produced by record.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

Adds the `loop` option to the `VideoStreamOptions` struct, and adds `loop` as a keyword argument to `VideoStream`, allowing control over the number of times a GIF is looped.
Copy link
Member

@asinghvi17 asinghvi17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty cool!

Is there a way to test that this works in tests? For example, if I try to set loop=2 and load it using ffmpeg, would I get 2x the frames and time?

@@ -58,11 +62,16 @@ struct VideoStreamOptions
if format in ("mp4", "webm")
(compression === nothing) && (compression = 20)
end

if format == "gif"
(loop === nothing) && (loop = 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(loop === nothing) && (loop = 0)
isnothing(loop) && (loop = 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to maintain consistency with the earlier lines of code by using === instead of isnothing, but if you prefer it this way, happy to switch!

@ztangent
Copy link
Contributor Author

@asinghvi17 Unfortunately I don't think there's an easy way to check based on the number of frames, or length of the video, alone -- it looks like the loop count for animated GIFs is stored somewhere in the header of the file (see https://en.wikipedia.org/wiki/GIF#Animated_GIF) and I'm not sure how to use FFMPEG to look up that number. Maybe it's possible to just look at that byte number (31D) directly?

@SimonDanisch SimonDanisch merged commit b5af00b into MakieOrg:master May 12, 2023
@SimonDanisch
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants