<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1440845565430_4436"><span id="yui_3_16_0_1_1440845565430_4435">Found the problem.</span></div><div id="yui_3_16_0_1_1440845565430_4434">Some research shows that without a specified bit buffer size ("-bufsize"), single-pass bitrate-centric encoding/rate control can (and has) produce(d) some very strange bitrate profiles. I do not know what it uses when not specified, but apparently it's not the right thing.</div><div id="yui_3_16_0_1_1440845565430_4434"><br></div><div id="yui_3_16_0_1_1440845565430_4434">By specifying a bufsize in the 0.5 to 2 seconds of video works quite well (i.e. bitrate=4.5Mbps, bufsize between 2.25 megabits and 9 megabits).</div><div id="yui_3_16_0_1_1440845565430_4434"><br></div><div id="yui_3_16_0_1_1440845565430_4434" dir="ltr">If this facet is already in the FFMPEG documentation (by that I mean the black pages with the green text), can someone please point it out? If not, can someone please add it?</div><div id="yui_3_16_0_1_1440845565430_4434" dir="ltr"><br></div><div id="yui_3_16_0_1_1440845565430_4434" dir="ltr"><thread closed></div><div id="yui_3_16_0_1_1440845565430_4434" dir="ltr">-Mark</div>  <br><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"> <font size="2" face="Arial"> On Friday, August 28, 2015 11:53 AM, Mister K-bar <misterkbar@yahoo.com> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container"><div id="yiv8378333340"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv8378333340"><div id="yiv8378333340yui_3_16_0_1_1440787641960_3227"><div style="background-color:rgb(255, 255, 255);" id="yiv8378333340yui_3_16_0_1_1440787641960_3226"><div id="yiv8378333340yui_3_16_0_1_1440785890129_4269" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">I am seeing a problem in the single-pass version of the x264 encoder where there appears to be a huge bitrate at the beginning, resulting in unacceptable amounts of compression to maintain the bitrate in the video that follows the initial high bitrate.</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4268" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">From what I can tell, the issue appears to be a bug, and SEEMS to be related to some kind of 1/2 second wallclock timer within the encoder: any encoding performed in that wallclock time has an ridiculously high bitrate. And once that time period has passed, massive compression follows. It can take several seconds for the resultant artifacts to clear up.</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">If you slow down the encoding process (such as reducing the number of threads severely, or using a slower machine), the amount of playtime high bitrate goes down, with the simple formula:</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">NumberOfHighRateFrames = ~0.5  seconds  / NumberFramesProcessedPerSecond</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">Running a 2-pass encoding of course fixes this, but such a solution clearly won't scale: it increases the wallclock time of the encoding process severely about 40% on an unloaded machine, and cannot be used with any sort of live stream (easily).</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;">For complete information on this topic, complete with a timeline of research into this issue (it was originally posted as "Linux quality worse than Mac"), graphs supporting the current theory, and links to MP4 files to reproduce the issue, please see this FFMPEG thread:</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr"><a rel="nofollow" target="_blank" href="http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6651#p6651" id="yiv8378333340yui_3_16_0_1_1440787641960_3264">Buggy, unacceptably high initial bitrate with libx264 codec • FFmpeg Support Forum</a><br></div><div style="width:450px;font-family:'Georgia', 'Times', 'Times New Roman', 'serif';margin-top:5px;margin-bottom:5px;background-color:#ffffff;" id="yiv8378333340enhancrCard_0" class="yiv8378333340link-enhancr-attachment yiv8378333340link-enhancr-element yiv8378333340richcompose-card"><table class="yiv8378333340link-enhancr-element" cellspacing="0" cellpadding="0" border="0" style="width:450px;height:170px;display:block;" id="yiv8378333340yui_3_16_0_1_1440787641960_3288"><tbody id="yiv8378333340yui_3_16_0_1_1440787641960_3287"><tr class="yiv8378333340link-enhancr-element"><td class="yiv8378333340link-enhancr-element" colspan="8" style="height:1px;background-color:#e5e5e5;font-size:1px;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="height:1px;background-color:#e5e5e5;font-size:1px;line-height:0px;"> </div></td></tr><tr class="yiv8378333340link-enhancr-element" id="yiv8378333340yui_3_16_0_1_1440787641960_3374"><td rowspan="5" class="yiv8378333340link-enhancr-element" style="width:1px;background-color:#e5e5e5;font-size:1pt;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="width:1px;background-color:#e5e5e5;font-size:1pt;"> </div></td><td class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-image-wrap" rowspan="5" style="vertical-align:middle;width:168px;height:168px;background-color:#000000;border-collapse:collapse;" id="yiv8378333340yui_3_16_0_1_1440787641960_3375"><div class="yiv8378333340link-enhancr-element" style="width:168px;" align="center"><a rel="nofollow" target="_blank" href="http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6651#p6651" class="yiv8378333340link-enhancr-card-urlWrapper yiv8378333340link-enhancr-element" style="text-decoration:none;text-decoration:none;color:#000000;"><img alt="image" class="yiv8378333340link-enhancr-thumbnail-image yiv8378333340link-enhancr-element yiv8378333340yahoo-ignore-inline-image" width="168" height="42" style="display:block;margin:auto;"></a></div></td><td rowspan="5" class="yiv8378333340link-enhancr-element" style="width:1px;background-color:#e5e5e5;font-size:0pt;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="width:1px;background-color:#e5e5e5;font-size:1pt;"> </div></td><td rowspan="5" class="yiv8378333340link-enhancr-element" style="width:14px;background-color:#ffffff;font-size:0pt;border-collapse:collapse;" id="yiv8378333340yui_3_16_0_1_1440787641960_3373"><div class="yiv8378333340link-enhancr-element" style="width:14px;background-color:#ffffff;font-size:14pt;"> </div></td><td colspan="2" class="yiv8378333340link-enhancr-element" style="height:6px;background-color:#ffffff;font-size:0pt;border-collapse:collapse;" id="yiv8378333340yui_3_16_0_1_1440787641960_3467"><div class="yiv8378333340link-enhancr-element" style="height:6px;background-color:#ffffff;font-size:6pt;" id="yiv8378333340yui_3_16_0_1_1440787641960_3466"> </div></td><td rowspan="5" class="yiv8378333340link-enhancr-element" style="width:20px;background-color:#ffffff;font-size:0pt;border-collapse:collapse;" id="yiv8378333340yui_3_16_0_1_1440787641960_3418"><div class="yiv8378333340link-enhancr-element" style="width:20px;background-color:#ffffff;font-size:20pt;"> </div></td><td class="yiv8378333340link-enhancr-element" rowspan="5" width="1" style="width:1px;background-color:#e5e5e5;font-size:1pt;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="width:1px;background-color:#e5e5e5;font-size:1pt;"> </div></td></tr><tr id="yiv8378333340yui_3_16_0_1_1440787641960_3286"><td class="yiv8378333340link-enhancr-element" colspan="2" style="width:100%;vertical-align:middle;font-family:'Georgia', 'Times', 'Times New Roman', 'serif';" id="yiv8378333340yui_3_16_0_1_1440787641960_3285"><div class="yiv8378333340link-enhancr-text-part yiv8378333340link-enhancr-element" style="line-height:16.5px;background-color:#ffffff;height:135px;width:245px;" id="yiv8378333340yui_3_16_0_1_1440787641960_3284"><div class="yiv8378333340link-enhancr-element" style="word-wrap:break-word;" id="yiv8378333340yui_3_16_0_1_1440787641960_3420"><span class="yiv8378333340link-enhancr-element yiv8378333340icon  yiv8378333340icon-shrink yiv8378333340link-enhancr-toggle"></span><span class="yiv8378333340link-enhancr-element yiv8378333340icon yiv8378333340icon-close yiv8378333340link-enhancr-delete" id="yiv8378333340yui_3_16_0_1_1440787641960_3419"></span><a rel="nofollow" target="_blank" href="http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6651#p6651" class="yiv8378333340link-enhancr-card-urlWrapper yiv8378333340link-enhancr-element" style="text-decoration:none;text-decoration:none;color:#000000;line-height:100%;font-size:18px;display:block;" id="yiv8378333340yui_3_16_0_1_1440787641960_3465"><span class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-card-title" style="margin:0;font-weight:normal;margin-bottom:3px;font-size:18px;line-height:21px;max-height:43px;color:#000000;overflow:hidden;display:inline-block;" id="yiv8378333340yui_3_16_0_1_1440787641960_3464">Buggy, unacceptably high initial bitrate with libx264 co...</span></a><div style="font-size:13px;line-height:20px;color:#999999;max-height:81px;font-family:'Georgia', 'Times', 'Times New Roman', 'serif';overflow:hidden;" class="yiv8378333340link-enhancr-card-description yiv8378333340link-enhancr-element">Buggy, unacceptably high initial bitrate with libx264 codec - FFmpeg support forum</div></div></div></td></tr><tr><td colspan="2" class="yiv8378333340link-enhancr-element" style="height:4px;background-color:#ffffff;font-size:0pt;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="height:4px;background-color:#ffffff;font-size:4pt;"></div></td></tr><tr id="yiv8378333340yui_3_16_0_1_1440787641960_3599"><td class="yiv8378333340link-enhancr-element" style="vertical-align:middle;font-family:'Arial', 'Helvetica Neue', 'Helvetica', 'sans-serif';"><div class="yiv8378333340link-enhancr-element" style="font-size:0pt;"><a rel="nofollow" target="_blank" href="http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6651#p6651" class="yiv8378333340link-enhancr-card-url yiv8378333340link-enhancr-element" style="color:black;text-decoration:none;text-decoration:none;cursor:pointer;"><span class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-view-on" style="display:inline-block;line-height:11px;max-width:145px;min-width:85px;overflow:hidden;max-height:13px;" id="yiv8378333340yui_3_16_0_1_1440787641960_3281"><span class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-mobile-no-resize" style="vertical-align:middle;font-size:9px;line-height:11px;color:#999999;">View on <span style="font-weight:bold;" class="yiv8378333340link-enhancr-view-on-domain">ffmpeg.gusari.org</span></span></span></a></div></td><td class="yiv8378333340link-enhancr-element" style="vertical-align:middle;width:100px;font-family:'Arial', 'Helvetica Neue', 'Helvetica', 'sans-serif';" id="yiv8378333340yui_3_16_0_1_1440787641960_3598"><div class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-preview-wrapper" style="max-width:100px;min-width:80px;overflow:hidden;text-align:right;line-height:11px;max-height:13px;font-size:0pt;" id="yiv8378333340yui_3_16_0_1_1440787641960_3597"><span class="yiv8378333340link-enhancr-element yiv8378333340link-enhancr-preview-by yiv8378333340link-enhancr-mobile-no-resize" style="vertical-align:middle;font-size:9px;line-height:11px;color:#999999;">Preview by Yahoo</span></div></td></tr><tr><td colspan="2" class="yiv8378333340link-enhancr-element" style="height:9px;background-color:#ffffff;font-size:0pt;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="height:9px;background-color:#ffffff;font-size:9pt;"></div></td></tr><tr class="yiv8378333340link-enhancr-element"><td class="yiv8378333340link-enhancr-element" colspan="8" style="height:1px;background-color:#e5e5e5;font-size:1px;border-collapse:collapse;"><div class="yiv8378333340link-enhancr-element" style="height:1px;background-color:#e5e5e5;font-size:1px;line-height:0px;"> </div></td></tr></tbody></table></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr">As an aside, it was mentioned that a large number of threads is a BAD thing in the x264 codec. Can someone please explain why this is? Without knowing implementation details, this seems highly counter-intuitive.</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr">Thanks!</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" dir="ltr">-Mark</div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div><div id="yiv8378333340yui_3_16_0_1_1440785890129_4254" style="color:rgb(0, 0, 0);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><br></div></div></div></div></div></div></div><br><br></div>  </div> </div>  </div></div></body></html>