title: FFMpeg Watermark Quality Very Bad
body: <p>I'm trying to add a watermark to a video which works fine, the only issue is the quality is greatly degraded. It also reduces the resolution of the video, making it a smaller size than it originally was. I am using the following command:</p>
  
  <pre><code>ffmpeg -i fade.mp4 -i watermark.png -filter_complex "scale=512:-2,overlay=(main_w-overlay_w)-2:(main_h-overlay_h)-2" -strict -2 final.mp4
  </code></pre>
  
  <p>I have also tried the following to specify high quality, but it produces the same bad quality video:</p>
  
  <pre><code>ffmpeg -i fade.mp4 -i watermark.png -filter_complex "scale=512:-2,overlay=(main_w-overlay_w)-2:(main_h-overlay_h)-2" -qscale 0 -strict -2 final.mp4
  </code></pre>
  
  <p>Here is the output from ffmpeg:</p>
  
  <pre><code>root@shell:~/videos# ffmpeg -i fade.mp4 -i watermark.png -filter_complex "scale=512:-2,overlay=(main_w-overlay_w)-2:(main_h-overlay_h)-2" -strict -2 final.mp4
  ffmpeg version 2.7.4-0ubuntu0.15.10.1 Copyright (c) 2000-2015 the FFmpeg developers
    built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
    configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
    libavutil      54. 27.100 / 54. 27.100
    libavcodec     56. 41.100 / 56. 41.100
    libavformat    56. 36.100 / 56. 36.100
    libavdevice    56.  4.100 / 56.  4.100
    libavfilter     5. 16.101 /  5. 16.101
    libavresample   2.  1.  0 /  2.  1.  0
    libswscale      3.  1.101 /  3.  1.101
    libswresample   1.  2.100 /  1.  2.100
    libpostproc    53.  3.100 / 53.  3.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fade.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.36.100
    Duration: 00:00:29.13, start: 0.023220, bitrate: 1158 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1027 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Input #1, png_pipe, from 'watermark.png':
    Duration: N/A, bitrate: N/A
      Stream #1:0: Video: png, rgba(pc), 200x45 [SAR 11811:11811 DAR 40:9], 25 tbr, 25 tbn, 25 tbc
  [libx264 @ 0x24743c0] using SAR=1/1
  [libx264 @ 0x24743c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
  [libx264 @ 0x24743c0] profile High, level 2.1
  [libx264 @ 0x24743c0] 264 - core 146 r2555 0c21480 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - videolan[cannotpostlink]x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'final.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.36.100
      Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 512x288 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
      Metadata:
        encoder         : Lavc56.41.100 libx264
      Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        encoder         : Lavc56.41.100 aac
  Stream mapping:
    Stream #0:0 (h264) -&gt; scale (graph 0)
    Stream #1:0 (png) -&gt; overlay:overlay (graph 0)
    overlay (graph 0) -&gt; Stream #0:0 (libx264)
    Stream #0:1 -&gt; #0:1 (aac (native) -&gt; aac (native))
  Press [q] to stop, [?] for help
  frame=  874 fps= 86 q=-1.0 Lsize=    1308kB time=00:00:29.09 bitrate= 368.2kbits/s dup=1 drop=0
  video:837kB audio:440kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.454302%
  [libx264 @ 0x24743c0] frame I:5     Avg QP:21.11  size: 10348
  [libx264 @ 0x24743c0] frame P:363   Avg QP:22.00  size:  1698
  [libx264 @ 0x24743c0] frame B:506   Avg QP:23.35  size:   371
  [libx264 @ 0x24743c0] consecutive B-frames: 17.0%  7.1% 30.5% 45.3%
  [libx264 @ 0x24743c0] mb I  I16..4: 21.1% 41.7% 37.2%
  [libx264 @ 0x24743c0] mb P  I16..4:  2.6%  3.3%  1.2%  P16..4: 26.6% 12.0%  5.2%  0.0%  0.0%    skip:49.1%
  [libx264 @ 0x24743c0] mb B  I16..4:  0.3%  0.1%  0.0%  B16..8: 32.2%  2.8%  0.3%  direct: 0.2%  skip:64.1%  L0:38.5% L1:57.9% BI: 3.6%
  [libx264 @ 0x24743c0] 8x8 transform intra:44.2% inter:71.4%
  [libx264 @ 0x24743c0] coded y,uvDC,uvAC intra: 41.7% 32.3% 8.2% inter: 6.6% 3.5% 0.1%
  [libx264 @ 0x24743c0] i16 v,h,dc,p: 50% 32%  6% 12%
  [libx264 @ 0x24743c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 21% 24%  4%  5%  7%  5%  5%  6%
  [libx264 @ 0x24743c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 30% 12%  4%  6%  7%  6%  5%  5%
  [libx264 @ 0x24743c0] i8c dc,h,v,p: 67% 19% 12%  2%
  [libx264 @ 0x24743c0] Weighted P-Frames: Y:0.0% UV:0.0%
  [libx264 @ 0x24743c0] ref P L0: 65.7% 18.3% 11.2%  4.8%
  [libx264 @ 0x24743c0] ref B L0: 84.6% 11.7%  3.7%
  [libx264 @ 0x24743c0] ref B L1: 95.2%  4.8%
  [libx264 @ 0x24743c0] kb/s:234.81
  root@shell:~/videos#
  </code></pre>