Why would FFmpeg create these artifacts like remaining pixels on the edges of the animation where objects have already removed and how to remove these?
Why would it create this magenta/red colored borders and how to remove these?
Why does it choose magenta/red color for semi-transparent pixels?
This is the command:
ffmpeg -pattern_type sequence \
-i "project_1_%05d.png" \
-vf "fps=30,scale=-1:-1:flags=lanczos,palettegen" \
"pallete_1.png" \
&& \
ffmpeg -pattern_type sequence \
-i "project_1_%05d.png" -i "pallete_1.png" \
-filter_complex "fps=30,scale=-1:-1:flags=bicubic[x];[x][1:v]paletteuse" \
"animation_bicubic_1.gif"
FFmpeg version:
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
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. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
The first PNG frame of a sequence I created:
The result(palette) from the first command:
The result(animation) from the second command which previews 2 issues:
As requested in the comment section by Tetsujin, appended more variants with different effects:
The first PNG frame of a version without the glow effect:
A version without the glow effect in a PNG sequence(only artifacts exist):
A version without the transparency in the PNG sequence(no issues):
Indeed, it seems the transparency processing adds artifacts and magenta/red borders to the result.



ffmpeg -framerate 30 -i "project_1_%05d.png" -filter_complex "split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif. The scale is doing nothing so I removed it, and no need for fps filter in this case (fps filter is used in the other answers to reduce frame rate of videos for GIF). – llogan Mar 27 '21 at 17:44180frames which is6010msin total(duration) and the one you mentioned creates150frames -5010msin total. The reason I used-r 30is to have the animation smoother(60 fps makes it laggy, though). It seems like both-r 30and-framerate 30produce equal results(same size, same duration), but the inner fps differs, I suppose. For the first option it shows25 FPS, for the second -30 FPSor25 fps, 25 tbr, 25 tbn, 25 tbcvs30 fps, 30 tbr, 30 tbn, 30 tbc. – Artfaith Mar 27 '21 at 20:03-r 30, but I don't see it in your commands, so I assume your commands have changed. Need your commands and complete logs to see what's happening. Note that unless you tell it otherwise ffmpeg uses a default frame rate of 25 for image inputs. 2) I don't have your input image sequence so I can't duplicate the magenta/red artifact issue. – llogan Mar 29 '21 at 19:21