[FFmpeg-user] MPEG-2 encoding problem

Moritz Barsnick barsnick at gmx.net
Thu Feb 14 15:46:48 EET 2019


Hi Jane,

On Thu, Feb 14, 2019 at 21:14:07 +0800, Jane wrote:
>   Hello everyone! I'm encoding video to MPEG-2 using Zeranoe's Windows builds.  The source file is 720p 60fps, progressive. I want to keep high quality and compatibility with DVD standards, so I use:
> ffmpeg -hwaccel auto -i "input" -vf scale=ntsc,interlace,fps=fps=29.97 -c:v mpeg2video -q:v 3 -g 15 -mpeg_quant 1 -aspect 16:9 -sc_threshold 40 -bf 2 -intra_vlc 1 -b_stratgey 2 -flags ilme+ildct -maxrate 9M -bufsize 224k -c:a mp2 -b:a 224k "output"

For best assistance, we recommend to also post the complete, uncut
output of this ffmpeg command.

Furthermore:
* " -b_stratgey 2" won't be accepted by ffmpeg, there's a typo in
  there.

* ffmpeg provides a set of defaults for maximum DVD compatibility,
  provided by "-target dvd". I wonder whether you really need to fiddle with
  any of the other parameters you provided.

  Here's what this "target" sets (from the source code):
        opt_video_codec(o, "c:v", "mpeg2video");
        opt_audio_codec(o, "c:a", "ac3"); // you can of course set mp2 instead // Moritz
        parse_option(o, "f", "dvd", options);

        parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
        parse_option(o, "r", frame_rates[norm], options);
        parse_option(o, "pix_fmt", "yuv420p", options);
        opt_default(NULL, "g", norm == PAL ? "15" : "18");

        opt_default(NULL, "b:v", "6000000");
        opt_default(NULL, "maxrate:v", "9000000");
        opt_default(NULL, "minrate:v", "0"); // 1500000;
        opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;

        opt_default(NULL, "packetsize", "2048");  // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
        opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8

        opt_default(NULL, "b:a", "448000");
        parse_option(o, "ar", "48000", options);

* As far as I understand, DVD supports progressive content just fine,
  so you can actually avoid interlacing (and requiring those flags).

* "-q:v 3" will result in quite low bandwith, IIRC. This may be one of
  your issues. Note how the defaults above specify a bandwidth, with a
  significant size. (If we saw your output, we could see which
  bandwidth your ffmpeg command resulted in. Probably much too low.)

> After disabled ildct and ilme, the quality is normal. Is the command incorrect?

That's interesting. Possibly, your "-flags" parameter is erasing other
flags. You should try "-flags +ilme+ildct". (Just a hunch, I'm not sure.)

> Due to the lack of information about codec mpeg2 video, I'm not sure
> about the sc_threshold, b_strategy and the dia_size value. How can i
> get detailed information?

Can't you just leave them at their/ffmpeg's defaults, if you don't know
what to do about them? Especially since you don't have knowledge of the
codec and their influences on it?

Cheers,
and let us know how it goes,
Moritz


More information about the ffmpeg-user mailing list