<p>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 <code>.mpg</code>. You can force MPEG-2 DVD by specifying <code>-f dvd</code>. And for a standard like PAL, set <code>-target pal-dvd</code></p>

<p>Try</p>

<pre><code>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
</code></pre>

CC BY-SA 3.0
2017-12-11T11:51:03.270Z
What about quality output without considering the output type
For example I wanted to merge mp4 videos and my target is also mp4 then what should I write for better quality??@Mulvya
Akash Dubey
CC BY-SA 3.0
2017-12-11T13:03:25.827Z
For MP4 output, remove `-target` option. ffmpeg will automatically set  output to CRF 23.
Gyan
CC BY-SA 3.0
2017-12-12T04:52:16.350Z
Thanks for the reply but can u plz tell me about high quality let me post my command and u do check that!!
Akash Dubey
CC BY-SA 3.0
2016-08-23T11:10:50.507Z
2016-08-23T11:10:50.507Z
Gyan
<p>0
down vote
favorite
I am merging an image with a video, my command looks like this:</p>

<pre><code>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
</code></pre>

<p>That works, but something strange happens.</p>

<p>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).</p>

<p>Any ideas of how this is happening and maybe solutions?</p>

<p><strong>Edit:</strong></p>

<p>I specified a bitrate like Mulvya suggest me to do:</p>

<p>Command looks like this now:</p>

<pre><code>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
</code></pre>

<p>Console ouput:</p>

<pre><code>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%
</code></pre>

CC BY-SA 3.0
2016-08-19T08:31:39.200Z
It's defaulting to a bitrate of 200k. Specify a rate e.g. `-b:v 2000k`
Gyan
CC BY-SA 3.0
2016-08-19T08:51:31.607Z
@Mulvya I tried it out did not solve the issue
utdev
CC BY-SA 3.0
2016-08-19T09:01:44.790Z
Show the full console output
Gyan
CC BY-SA 3.0
2016-08-19T09:10:10.130Z
That's not the full console output. Anyway, add `-c:v mpeg2video -bufsize 2000k`
Gyan
CC BY-SA 3.0
2016-08-19T09:12:06.313Z
sorry, I somehow though to post just the error message. Shall I remove -c:a ?
utdev
CC BY-SA 3.0
2016-08-19T09:17:17.860Z
@Mulvya could you post the full command somehow it does not seem to work when I add it
utdev
CC BY-SA 3.0
2016-08-19T09:34:07.267Z
Show the full console output.
Gyan
CC BY-SA 3.0
2016-08-19T09:44:39.833Z
@Mulvya ok added it into my question
utdev
CC BY-SA 3.0
2016-08-19T09:48:05.413Z
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`
Gyan
CC BY-SA 3.0
2016-08-23T10:44:20.523Z
@Mulvya sorry for the late reply it worked thanks, but you like to give an answer so that I can check it:)
utdev
<video><ffmpeg><video-quality>
FFmpeg merge image with video looses quality
utdev
# FFmpeg merge image with video looses quality

(Asked by: username_0 on 2016-08-19)

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) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> 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%

**Tags:** video, ffmpeg, video-quality

> **Comments:**
> **username_1**: It's defaulting to a bitrate of 200k. Specify a rate e.g. `-b:v 2000k`  
> **username_0**: @Mulvya I tried it out did not solve the issue  
> **username_1**: Show the full console output  
> **username_1**: That's not the full console output. Anyway, add `-c:v mpeg2video -bufsize 2000k`  
> **username_0**: sorry, I somehow though to post just the error message. Shall I remove -c:a ?  
> **username_0**: @Mulvya could you post the full command somehow it does not seem to work when I add it  
> **username_1**: Show the full console output.  
> **username_0**: @Mulvya ok added it into my question  
> **username_1**: 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`  
> **username_0**: @Mulvya sorry for the late reply it worked thanks, but you like to give an answer so that I can check it:)  

---

## 1 answers

### Answer by username_1 on 2016-08-23. Score: 1 | Accepted answer

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

> **Comments:**
> **username_2**: What about quality output without considering the output type For example I wanted to merge mp4 videos and my target is also mp4 then what should I write for better quality??@Mulvya  
> **username_1**: For MP4 output, remove `-target` option. ffmpeg will automatically set  output to CRF 23.  
> **username_2**: Thanks for the reply but can u plz tell me about high quality let me post my command and u do check that!!  

---

