[FFmpeg-user] Lossless and colour preserving pix_fmt?

Jim DeLaHunt from.ffmpeg-user at jdlh.com
Mon Jan 8 07:29:58 EET 2018


Hello, ffmpeg'rs:

I'm trying to overlay animated GIFS onto one white background, with some 
text at the top.  I'm looking for an incantation which a) does the job 
and b) leaves all the colours of the animated gifs unchanged.

What options tell ffmpeg not to mess with the colour values, not to 
change colour spaces, not to reduce precision of colour coordinate values?

When I try what seems obvious, I get an animated GIF result which has 
the right layout, but has pixelation of some of the colours in the 
animated gifs. For instance, solid 0000FF pixels in the input image 
animated_blue_12.gif became speckled with black pixels in the output. I 
suspect there is a colour space transform happening, and I don't want that.

% ffmpeg -i animated_blue_12.gif -filter_complex "
color=white at 1.0:size=696x400,
drawtext=fontsize=20:font=Arial:x=10:y=10:text=Hamburgefons Hamburgefons Hamburgefons
       [background];
[0:v] setpts=PTS-STARTPTS [gs1];
[background][gs1] overlay=shortest=1:x=20:y=40
" -y blue+text_pixfmt.696x400.gif

I tried to insert `-pix_fmt +` to get all the parts of the overlay to 
agree on the same pixel format, but that failed:

% ffmpeg -i animated_blue_12.gif -filter_complex "
color=white at 1.0:size=696x400,
drawtext=fontsize=20:font=Arial:x=10:y=10:text=Hamburgefons Hamburgefons Hamburgefons
       [background];
[0:v] setpts=PTS-STARTPTS [gs1];
[background][gs1] overlay=shortest=1:x=20:y=40
" -pix_fmt + -y blue+text_pixfmt.696x400.gif
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
   built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
   configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample
--enable-libmp3lame --enable-libvorbis --enable-libopus --enable-librsvg --enable-libtheora
--enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex
--enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype
--enable-libfribidi --disable-indev=jack --enable-opencl --disable-outdev=xv --enable-audiotoolbox
--enable-videotoolbox --enable-sdl2 --mandir=/opt/local/share/man --enable-shared --enable-pthreads
--cc=/usr/bin/clang --arch=x86_64 --enable-x86asm --enable-libx265 --enable-gpl --enable-postproc
--enable-libx264 --enable-libxvid
   libavutil      55. 78.100 / 55. 78.100
   libavcodec     57.107.100 / 57.107.100
   libavformat    57. 83.100 / 57. 83.100
   libavdevice    57. 10.100 / 57. 10.100
   libavfilter     6.107.100 /  6.107.100
   libavresample   3.  7.  0 /  3.  7.  0
   libswscale      4.  8.100 /  4.  8.100
   libswresample   2.  9.100 /  2.  9.100
   libpostproc    54.  7.100 / 54.  7.100
Input #0, gif, from 'animated_blue_12.gif':
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: gif, bgra, 212x318, 100 tbr, 100 tbn, 100 tbc
[Parsed_drawtext_1 @ 0x7f83c3e35620] Using "/Library/Fonts/Arial.ttf"
Stream mapping:
   Stream #0:0 (gif) -> setpts
   overlay -> Stream #0:0 (gif)
Press [q] to stop, [?] for help
[Parsed_drawtext_1 @ 0x7f83c3c0f560] Using "/Library/Fonts/Arial.ttf"
The filters 'Parsed_setpts_2' and 'Parsed_overlay_3' do not have a common format and automatic conversion is disabled.
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!

How do I tell ffmpeg not to mess with the colour values of this 
video/animated GIF?

Thanks in advance,
       —Jim DeLaHunt, Vancouver, Canada

-- 
     --Jim DeLaHunt, jdlh at jdlh.com     http://blog.jdlh.com/ (http://jdlh.com/)
       multilingual websites consultant

       355-1027 Davie St, Vancouver BC V6E 4L2, Canada
          Canada mobile +1-604-376-8953



More information about the ffmpeg-user mailing list