FFmpeg merge image with video looses quality 0
down vote
favorite
I am merging an image with a video, my command looks like this:

ffmpeg -i background.mpg -i Menu.png -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,30)'" -pix_fmt yuv420p -c:a copy merge1.mpg


That works, but something strange happens.

If I run that merged video it continuously looses quality at each second, at the first few seconds the quality is ok but later on it looses quality(the resolution becomes worse).

Any ideas of how this is happening and maybe solutions?

Edit:

I specified a bitrate like Mulvya suggest me to do:

Command looks like this now:

ffmpeg -i background.mpg -i Menu.png -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,30)'" -pix_fmt yuv420p -b:v 2000k -c:a copy merge1.mpg


Console ouput:

ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfr
eetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enab
le-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink
--enable-zlib
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpeg, from 'C:\xampp\htdocs\myApp\storage\generator\projects\dvdrom\Ged\Menus\background.mpg':
  Duration: 00:00:30.00, start: 0.540000, bitrate: 1792 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 1800 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Input #1, png_pipe, from 'C:\xampp\htdocs\myApp\storage\generator\projects\dvdrom\Ged\Menus\imageSel.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 720x480 [SAR 2835:2835 DAR 3:2], 25 tbr, 25 tbn, 25 tbc
File 'C:\xampp\htdocs\myApp\storage\generator\projects\dvdrom\Ged\Menus\image1.mpg' already exists. Overwrite ? [y/N] y
[mpeg @ 04dca7e0] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'C:\xampp\htdocs\myApp\storage\generator\projects\dvdrom\Ged\Menus\image1.mpg':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mpeg1video, yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 2000 kb/s, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc56.60.100 mpeg1video
Stream mapping:
  Stream #0:0 (mpeg2video) -&gt; overlay:main
  Stream #1:0 (png) -&gt; overlay:overlay
  overlay -&gt; Stream #0:0 (mpeg1video)
Press [q] to stop, [?] for help
frame=  750 fps=443 q=2.0 Lsize=    5650kB time=00:00:29.96 bitrate=1544.9kbits/s
video:5624kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.468742%
Looks like you're aiming for DVD-spec output. By default, FFmpeg encodes to MPEG-1 video into a MPEG-1 program stream, when the output extension is .mpg. You can force MPEG-2 DVD by specifying -f dvd. And for a standard like PAL, set -target pal-dvd

Try

ffmpeg -i background.mpg -i Menu.png -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,30)'" -pix_fmt yuv420p -target pal-dvd -f dvd merge1.mpg