<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi <span style="font-variant-ligatures: no-common-ligatures" class="">Simon,<br></span><br></div><div>I want to select the two-pass rate control method, which can hit exact file size. But I'm satisfied with the redundancy incurred by encoding video sequence twice.<br><br>i'm reading x264 source code, and want to change the algorithm of two-pass rate control. But I haven't followed the x264 update for long time, and need some person's advice. Is it possible to change rc algorithm so that video sequence is encoded once with two-pass option and without obvious deviation of file size?<br></div><div><br>Thanks!<br><br>Andrew<br><br><br></div><div style="position:relative;zoom:1"></div><div id="divNeteaseMailCard"></div>At 2016-05-12 11:59:33, "Simon Horlick" <simonhorlick@gmail.com> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div><div>Hi Andrew,</div><div class=""><br class=""></div><blockquote type="cite" class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class="">x264 adopts several rate control methods, one of which is of two pass. For 1st pass, x264 encoder will generate two files, i.e. rate control file and mb tree file. For 2nd pass, x264 encoder will read the two files, and estimate qp value to encode each frame.<br class=""><br class="">It's redundant to encode video sequence twice, one for each pass. Is it possible to encode video sequence once without making big change into rate control algorithm?<br class=""></div></div></blockquote></div><div><br class=""></div><div>Perhaps consult the documentation before posting here? x264 supports c<span style="background-color: rgb(254, 254, 254);" class="">onstant quality mode, constant quantiser and constant bitrate:</span></div><div><span style="background-color: rgb(254, 254, 254);" class=""><font class="" face="Ubuntu Mono" color="#4f4f4f" size="3"><br class=""></font></span></div><div><span style="background-color: rgb(254, 254, 254);" class="">From x264 --help:</span></div><div><span style="background-color: rgb(254, 254, 254);" class=""><br class=""></span></div><div><div style="margin: 0px; line-height: normal; background-color: rgb(254, 254, 254);" class=""></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""></div></div><blockquote type="cite" class=""><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Ratecontrol:</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254); min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  -B, --bitrate <integer>     Set bitrate (kbit/s)</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">      --crf <float>           Quality-based VBR (0-51) [23.0]</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">      --vbv-maxrate <integer> Max local bitrate (kbit/s) [0]</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">      --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [0]</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  -p, --pass <integer>        Enable multipass ratecontrol</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">                                  - 1: First pass, creates stats file</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: 'Ubuntu Mono'; color: rgb(79, 79, 79); background-color: rgb(254, 254, 254);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">                                  - 2: Last pass, does not overwrite stats file</span></div></div></blockquote><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">If you aren¡¯t bothered about hitting an exact file size then there is no need to use two-pass encoding.</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">For example, the default is --</span><span style="background-color: rgb(254, 254, 254);" class="">crf 23, which aims to keep constant quality and bitrate depends only on the complexity of the source material. This is done in a single pass.</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Regards,</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Simon</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div></blockquote></div><br><br><span title="neteasefooter"><p> </p></span>