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

GIF two-pass rendering #1276

Closed
JonnyBurger opened this issue Aug 31, 2022 · 3 comments · Fixed by #3204
Closed

GIF two-pass rendering #1276

JonnyBurger opened this issue Aug 31, 2022 · 3 comments · Fixed by #3204
Assignees

Comments

@JonnyBurger
Copy link
Member

JonnyBurger commented Aug 31, 2022

Hi! I'm creating a gif using remotion but it gets rendered in low quality. Instead, if I create an .mp4 video and then render a gif using ffmpeg and creating a collor pallete I get a higher quality gif.

  • Gif creation with Remotion
    $ npx remotion render --codec=gif src/index.tsx TemplateExample out/created-with-remotion.gif
  • Gif creation with FFMpeg
    $ npx remotion render src/index.tsx TemplateExample out/video.mp4
    $ ffmpeg -ss 00:00:00 -t 5 -i out/video.mp4 -filter_complex "[0:v] palettegen" palette.png
    $ ffmpeg -ss 00:00:00 -t 5 -i out/video.mp4 -i palette.png -filter_complex "[0:v] fps=10,scale=720:-1 [new];[new][1:v] paletteuse" created-with-ffmpeg.gif
    Do you know if there's some way to configure this pallete directly from remotion? Or another way to create a higher quality gif? > Thanks!

Use cases:

  • Sample a palette to make the GIF prettier
  • Support transparent GIFs
@JonnyBurger JonnyBurger changed the title GIF does not look pretty because it does not sample the palette from the input GIF two-pass rendering Sep 6, 2022
@AgusPk
Copy link

AgusPk commented Sep 7, 2022

how about something like this to do it in one step?

ffmpeg out/video.mp4 -filter_complex "[0:v] fps=15,scale=w=720:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1"out.gif

@gexin1
Copy link
Contributor

gexin1 commented Sep 12, 2022

I found a way to generate gifs from png

  1. we set options get transparent png
 --image-format=png
  1. Combine PNG into gif
ffmpeg -i element-%2d.png  -filter_complex split[v],palettegen,[v]paletteuse test.gif
  1. I got

test3

@JonnyBurger
Copy link
Member Author

Thanks a lot for those suggestions, I will try them!

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 a pull request may close this issue.

4 participants