<div dir="ltr">Hi friend,<div><br></div><div>I met a problem when converting video stream into mpeg 2 format with specified max bitrate.</div><div><br></div><div>The input file has a high bitrate of about 40Mbps (resolution is 720P),</div>
<div><br></div><div>when converting with "ffmpeg -i input.mp4 -target pal-dvd dvd.mpg" then everything is OK, resulting mpeg has a bitrate of 7620kbps.</div><div><br></div><div>As we know, specifying "-taget pal-dvd" in fact supply a bunch of arguments into the command line, </div>
<div>in fact they are </div><div><div>        opt_video_codec(o, "c:v", "mpeg2video");</div><div>        opt_audio_codec(o, "c:a", "ac3");</div><div>        parse_option(o, "f", "dvd", options);</div>
<div><br></div><div>        parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);</div><div>        parse_option(o, "r", frame_rates[norm], options);</div><div>        parse_option(o, "pix_fmt", "yuv420p", options);</div>
<div>        av_dict_set(&o->g->codec_opts, "g", norm == PAL ? "15" : "18", 0);</div><div><br></div><div>        av_dict_set(&o->g->codec_opts, "b:v", "6000000", 0);</div>
<div>        av_dict_set(&o->g->codec_opts, "maxrate", "9000000", 0);</div><div>        av_dict_set(&o->g->codec_opts, "minrate", "0", 0); // 1500000;</div><div>
        av_dict_set(&o->g->codec_opts, "bufsize", "1835008", 0); // 224*1024*8;</div><div><br></div><div>        av_dict_set(&o->g->format_opts, "packetsize", "2048", 0);  // from <a href="http://www.mpucoder.com">www.mpucoder.com</a>: DVD sectors contain 2048 bytes of data, this is also the size of one pack.</div>
<div>        av_dict_set(&o->g->format_opts, "muxrate", "10080000", 0); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8</div><div><br></div><div>        av_dict_set(&o->g->codec_opts, "b:a", "448000", 0);</div>
<div>        parse_option(o, "ar", "48000", options);</div></div><div><br></div><div>So when I supply this argument one by one instead of using "-target pal-dvd", generated video is still OK.</div>
<div><br></div><div><font color="#ff0000">But once I removed "-f dvd -s 720x576", there come out lots warnings of "buffer underflow", and the generated file has an overall bitrate of 29.7Mbps although 9000k is specified to be max.</font></div>
<div><font color="#ff0000">I think that means "-target paldvd" succeeds because down scale is done, and if without resizing (in case input bitrate is high), only specifying maxrate doesn't guarantee the bitrate of the</font></div>
<div><font color="#ff0000">output file.</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">So I want to know, if there is any option available, so that no matter what the input bitrate is, output can always stay below a specified bitrate?</font></div>
<div><br></div><div>Thanks</div><div><br></div></div>