I have a video that has a color I'd like to remove, and make into a transparent gif with ffmpeg. I first created a color palette using

ffmpeg -i video.mp4 -filter_complex "[0:v] palettegen" palette.png=

that went fine. Then when I go to try and make a gif I do this:

ffmpeg -i Untitled.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse;[0:v]chromakey=0xE700F4" out.gif

This however gives an error and does not create anything. Am I doing something wrong here?

here's the log:

  built with gcc 9.1.1 (GCC) 20190621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 56.101 /  7. 56.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Untitled.mp4':
    major_brand     : mp42
    minor_version   : 19529854
    compatible_brands: mp42isom
    creation_time   : 2019-07-10T05:06:10.000000Z
  Duration: 00:00:07.04, start: 0.000000, bitrate: 12629 kb/s
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 190 kb/s (default)
      creation_time   : 2019-07-10T05:06:10.000000Z
      handler_name    : Sound Media Handler
    Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 12433 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
      creation_time   : 2019-07-10T05:06:10.000000Z
      handler_name    : Video Media Handler
      encoder         : AVC Coding
Input #1, png_pipe, from 'palette.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 16x16 [SAR 1:1 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:1 (h264) -> paletteuse:default
  Stream #0:1 (h264) -> chromakey
  Stream #1:0 (png) -> paletteuse:palette
  paletteuse -> Stream #0:0 (gif)
  chromakey -> Stream #0:1 (gif)
Press [q] to stop, [?] for help
[swscaler @ 0000008b903fedc0] No accelerated colorspace conversion found from yuva420p to bgr8.
[gif @ 0000008b8ca40540] GIF muxer supports only a single video GIF stream.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
Conversion failed!
  • 2
    "gives an error" isn't descriptive and makes it hard to provide any help. You should always include the actual error. Even better is to provide the complete log from the command.
    – llogan
    Jul 10, 2019 at 17:26
  • alright i updated it
    – Alexwall
    Jul 10, 2019 at 22:37

1 Answer 1


Your command is attempting to place two streams into the GIF output (the output from paletteuse and the output from chromakey), but the GIF muxer supports only a single stream. To fix this your outputs from each filter should not be orphaned. See the filtering introduction for more info.

ffmpeg -i input.mp4 -filter_complex "[0:v]chromakey=0xE700F4,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse" output.gif
  • For better results use the chromakey filter before creating the palette.
  • With the split filter you can avoid making a temporary palette file.
  • That'll do it, thanks!
    – Alexwall
    Jul 11, 2019 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.