videoencodingffmpegdvdmpeg-2

How to avoid pumping artifacts when encoding still images into a mpeg-2 video using ffmpeg


I'm encoding a still image into a dvd compliant mpeg stream using a command line like this:

ffmpeg.exe -y -loop 1 -t 00:00:30 -r 1 -i "image.jpg" -target pal-dvd -b:v 6000000 video.mpg

This generates a video of 30s showing a single still image. When watching the video I notice strange (and ugly) "pumping" artifacts, approximately at the end of each GOP. Using a stream analyzer tool I noticed that two consecutive I frames in a sequence of IPPPPPPPPPPPPPPIPPPPPPPPPPPPPP... do not look the the same as I would expect it, since there should be no reason for the encoder to change encoding parameters that influence quality.

I also encoded the same image using the command line

ffmpeg.exe -y -loop 1 -t 00:00:30 -r 1 -i "image.jpg" -f dvd -pix_fmt yuv420p -r 25 -s 720x576 -aspect 16:9 -vcodec mpeg2video -b:v 6000000 -maxrate 9000000 -bufsize 1835008 -muxrate 10080000 -minrate 0 -packetsize 2048 -g 15 video.mpg

which applies more or less the same parameters that are implied by -target pal-dvd above. The result is the same as expected.

Note: non still material shows less to no "pumping". It also nearly disappears when setting vbv buffer size to a higher value like 3670016 bytes, doubling it effectively. Unfortunately this is no option since the stream should be dvd compliant which enforces a vbv buffer size like in the command lines above.

So how can I avoid these visual artifacts and get a stream that (really) shows a still image?


Solution

  • I was able to reproduce your problem and fixed it by specifying the quantizer scale (set to maximum quality) like so:

    ffmpeg.exe -y -loop 1 -t 00:00:30 -r 1 -i "image.jpg" -q:v 2 -target pal-dvd -b:v 6000000 video.mpg