question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I Use a palette to encode a GIF using ffmpeg?

See original GitHub issue

Like this : ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif

import ffmpeg
in_filename='C:\Users\Administrator\Desktop\py\img\'
(
ffmpeg
.input(in_filename+'girl.gif')
# .filter('palettegen', stats_mode='full')
# .output(in_filename+'palettegen_full.png')
.filter(filter_name='paletteuse', dither='bayer')
.output(in_filename+'paletteuse_bayer.gif')# , vframes=1, format='image2', vcodec='mjpeg'
.run(input=b'y')
)

##Error:

Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_paletteuse_0
Traceback (most recent call last):
File ".../test_little.py", line 116, in 
.run(input=b'y')
File "...\venv\lib\site-packages\ffmpeg_run.py", line 305, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kkroeningcommented, Jun 3, 2019

Instead of using ffmpeg.concat, use the multi-input form of ffmpeg.filter. e.g.:

(
    ffmpeg.filter(
        [
            ffmpeg.input(in_filename+'girl.gif'),
            ffmpeg.input(in_filename+'palettegen-1.png'),
        ],
        filter_name='paletteuse',
        dither='heckbert',
        new='False',
    )
    .output(in_filename+'output.gif')
    .run(overwrite_output=True)
)
0reactions
SmallChocolatecommented, Apr 19, 2019

Aha,I got it.Although the output image is not the clarity I want, perhaps it is not appropriate for me to generate a palette. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make GIFs with FFMPEG - GIPHY Engineering
palettegen is a filter that generates a 256 color palette to be used in GIF encoding in the next step. Like the filter...
Read more >
How do I convert a video to GIF using ffmpeg, with reasonable ...
ffmpeg commands: Run this command so that ffmpeg can figure out a good palette:
Read more >
How to Make a GIF from a Video Using FFmpeg - Bannerbear
By default, FFmpeg uses a generic 256-color palette for every GIF encoding and doesn't take into account the colors in the input video....
Read more >
ffmpeg save or encode GIFs (with palette generation) from ...
import os. import numpy as np. def save_gif(gif_fname, images, fps=4):. """ To generate a gif from image files, first generate palette from images....
Read more >
How to Convert Videos to GIFs Using FFmpeg - Baeldung
In this article, we learned how to use the FFmpeg command-line tool to convert a video to a high-quality gif by generating a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found