0% found this document useful (0 votes)
2 views

Asp

The document describes a Video Bitrate Calculator designed to help users determine the optimal bitrate for encoding video files. It includes various input fields for video dimensions, frame rates, and audio tracks, and provides calculations for file sizes and bitrates based on user inputs. The document also contains JavaScript functions for dynamic updates and calculations related to video encoding parameters.

Uploaded by

Momon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Asp

The document describes a Video Bitrate Calculator designed to help users determine the optimal bitrate for encoding video files. It includes various input fields for video dimensions, frame rates, and audio tracks, and provides calculations for file sizes and bitrates based on user inputs. The document also contains JavaScript functions for dynamic updates and calculations related to video encoding parameters.

Uploaded by

Momon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 17

<!

DOCTYPE html>
<HTML lang="en">
<HEAD>
<TITLE>Video Bitrate Calculator</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<META name="author" content="Alexander Thomas">
<META name="generator" content="HTML TagWriter 3.8 by A.T.">
<META name="keywords" content="Convert, convertor, conversion, video, encoding,
bitrate, bit rate, KiloByte, MegaByte, GigaByte, TeraByte, ExaByte, KibiByte,
MebiByte, GibiByte, TebiByte, ExbyByte, online">
<META name="description" content="A calculator that helps to determine the optimal
bitrate for encoding movie files.">
<META name="viewport" content="width=device-width, initial-scale=1.0">
<LINK rel="stylesheet" href="../lexStyles.css" type="text/css">
<LINK rel="canonical" href="https://www.dr-lex.be/info-stuff/videocalc.html">
<STYLE><!--
TR {vertical-align:text-top}
TD.Label {font-weight:bold; text-align:right}
TD.Action {color:#038}
INPUT {font-family:monospace; text-align:left; margin:.1em .5em}
INPUT[type=button] {margin:.3em .5em}
.sml {font-size:.8em}
.flash {background:#FF0}
.plain {background:#FFF}
.in {background:#BFB}
.out {background:#FFB}
TR.set0 {background:#EEE}
TR.set1 {background:#CCC}
TR.set2 {background:#AAA}
TD.bottom {padding-bottom:.3em}
TD.title {height:2em; padding:.1em .8em; font-style:italic; vertical-align:middle}
SELECT.drop {display:inline-block; color:#0000; width:24px; height:24px; -moz-
appearance:none; -webkit-appearance:none; appearance:none;
background:url('../imags/drop_down.svg') #eee; border:1px solid #888; border-
radius:3px; margin-left:.5em}
SELECT.drop option {color:#000}
.code {font-family:monospace; background:#DDD; text-align:left}
@media (pointer: coarse) {
INPUT {margin:.3em .5em}
INPUT[type=button] {margin:.4em .5em}
SELECT.drop {margin-top:.25em; margin-bottom:.4em}
}
--></STYLE>
<!--HTMLTW includeFile="../ga.emb"--><!-- Google tag (gtag.js) -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=G-763QGHGK34"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-763QGHGK34');
</script><!--/HTMLTW-->
</HEAD>

<BODY class="edu">

<!--HTMLTW includeFile="nav-info-header.emb" leaf="Video Bitrate Calculator"--><DIV


id="header" class="navbar2">
<OL class="nav" vocab="https://schema.org/" typeof="BreadcrumbList">
<LI class="nav0" property="itemListElement" typeof="ListItem"><A
href="https://www.dr-lex.be/" property="item" typeof="WebPage"><SPAN
property="name">Dr. Lex' Site</SPAN></A><META property="position"
content="1"></LI><LI class="nav1" property="itemListElement" typeof="ListItem"><A
href="https://www.dr-lex.be/info-stuff/" property="item" typeof="WebPage"><SPAN
property="name">Educative</SPAN></A><META property="position" content="2"></LI><LI
class="nav2" property="itemListElement" typeof="ListItem"><SPAN
property="name">Video Bitrate Calculator</SPAN><META property="position"
content="3"></LI>
</OL>
</DIV><!--/HTMLTW-->

<DIV id="wrapper">
<DIV id="headMargin">&nbsp;</DIV>

<DIV class="mRoot"><DIV class="article">


<!--HTMLTW includeFile="videocalc-script.emb"--><SCRIPT><!--
//Version 20230711
var lastSource = 'bytes';
var isTouch = false;

// Set passive EventListener option if supported


let optionPassive = false;
try {
const options = {
get passive() {
optionPassive = { passive: true };
return false;
}
};
window.addEventListener("test", null, options);
window.removeEventListener("test", null, options);
} catch (err) {
optionPassive = false;
}

function roundN(x, n) {
return Number(Math.round(x + 'e' + n) + 'e-' + n);
}

// Update the other file size fields according to the current value of the source
field.
function updateCalc(source)
{
var oVal=0, val=0;
if(typeof source == "undefined" || source == "") {
source = lastSource;
} else {
lastSource = source;
}

eval("oVal = document.Calc."+source+".value;");
val = oVal;
switch(source) {
case "kB":
val *= 1000;
break;
case "KiB":
val *= 1024;
break;
case "MB":
val *= 1e6;
break;
case "MiB":
val *= 1048576;
break;
case "GB":
val *= 1e9;
break;
case "GiB":
val *= 1073741824;
break;
case "bits":
val /= 8;
break;
}

document.Calc.bytes.value = Math.ceil(val);
if(source == "bits") {
document.Calc.bits.value = oVal;
} else {
document.Calc.bits.value = Math.ceil(val)*8;
}

document.Calc.kB.value = roundN(val/1000, 2);


document.Calc.KiB.value = roundN(val/1024, 2);
document.Calc.MB.value = roundN(val/1e6, 2);
document.Calc.MiB.value = roundN(val/1048576, 2);
document.Calc.GB.value = roundN(val/1e9, 2);
document.Calc.GiB.value = roundN(val/1073741824, 2);
flash('bytes,bits,kB,KiB,MB,MiB,GB,GiB');
}

function getBPP()
{
var width = parseInt(document.Calc.Width.value);
var height = parseInt(document.Calc.Height.value);
var pixRate = width*height*parseFloat(document.Calc.FPS.value);
document.Calc.BPP.value =
roundN(1000*parseFloat(document.Calc.RVideo.value)/pixRate, 6);
flash('BPP');
}

function getAR()
{
var width = parseInt(document.Calc.Width.value);
var height = parseInt(document.Calc.Height.value);
document.Calc.AR.value = roundN(width/height, 2);
flash('AR');
}

function updateHMS(hms)
{
var s, HH, MM, SS;
if(hms == 's') {
s = parseInt(document.Calc.secs.value);
} else { // need to add the base, otherwise "08" is parsed as octal and
becomes 0
s =
parseInt(document.Calc.HH.value,10)*3600+parseInt(document.Calc.MM.value,10)*60+par
seInt(document.Calc.SS.value,10);
}

HH = Math.floor(s/3600);
MM = Math.floor((s%3600)/60);
SS = s%60;

if(HH < 10) { HH = '0'+HH; }


if(MM < 10) { MM = '0'+MM; }
if(SS < 10) { SS = '0'+SS; }
document.Calc.secs.value = s;
document.Calc.HH.value = HH;
document.Calc.MM.value = MM;
document.Calc.SS.value = SS;
}

// Update the bitrate fields that are affected by a change in fields of type 'typ'.
function updateRate(typ)
{
var s = parseInt(document.Calc.secs.value),
at = parseInt(document.Calc.ATrack.value),
ro = parseFloat(document.Calc.ROver.value),
ra = parseFloat(document.Calc.RAudio.value),
rv = parseFloat(document.Calc.RVideo.value);
if(typ == 'total') {
document.Calc.RVideo.value = parseFloat(document.Calc.RTotal.value)-ro-
at*ra;
flash('RVideo');
} else if(typ == 'video' || typ == 'vidFromBPP' || typ == 'audio' || typ ==
'over') {
document.Calc.RTotal.value = roundN(rv+at*ra+ro, 2);
flash('RTotal');
if(typ == 'video') {
getBPP();
}
} else {
var rTotal = roundN(8*document.Calc.bytes.value / (1000*s), 2);
document.Calc.RTotal.value = rTotal;
if(typ == 'time2vid') {
document.Calc.RVideo.value = roundN(rTotal-ro-at*ra, 2);
flash('RTotal,RVideo');
getBPP();
} else if(typ == 'time2aud') {
if(at != 0)
document.Calc.RAudio.value = roundN((rTotal-ro-rv)/at, 2);
else {
document.Calc.RAudio.value = 0;
}
flash('RTotal,RAudio');
} else if(typ == 'time2ovh') {
document.Calc.ROver.value = roundN(rTotal-rv-at*ra, 2);
flash('RTotal,ROver');
}
}
}

function setARate(r)
{
document.Calc.RAudio.value = r;
flash('RAudio');
updateRate('audio');
}

function arPreset()
{
var sel = document.getElementById("AR_pre");
var numOpt = sel.options.length;
for(var i=0; i<numOpt; i++) {
var opt = sel.options[i];
if(opt.selected) {
setARate(opt.value);
sel.selectedIndex = -1;
return;
}
}
}

function moreATracks()
{
var tracks = parseInt(document.Calc.ATrack.value);
if(isNaN(tracks) || tracks < 0)
tracks = 0;
document.Calc.ATrack.value = tracks + 1;
updateRate('audio');
}

function fewerATracks()
{
var tracks = parseInt(document.Calc.ATrack.value);
if(isNaN(tracks) || tracks < 1)
tracks = 1;
document.Calc.ATrack.value = tracks - 1;
updateRate('audio');
}

// Time for given bitrate and media size


function getTime()
{
var r = parseFloat(document.Calc.RTotal.value);
var b = parseInt(document.Calc.bits.value);
document.Calc.secs.value = Math.floor(b/1000/r);
updateHMS('s');
flash('TB,HH,MM,SS');
}

// Update file sizes for given stream type


function getSize(what)
{
var s = parseInt(document.Calc.secs.value);
if(what == 'total') {
document.Calc.bytes.value =
Math.round(s*parseFloat(document.Calc.RTotal.value)*125);
} if(what == 'video') {
document.Calc.bytes.value =
Math.round(s*parseFloat(document.Calc.RVideo.value)*125);
} if(what == 'audio') {
var at = parseInt(document.Calc.ATrack.value);
document.Calc.bytes.value =
Math.round(s*parseFloat(document.Calc.RAudio.value)*at*125);
}
updateCalc('bytes');
}

// Make a guesstimate for a reasonable video bitrate based on frame size and rate
and fudge factors.
function guessRate(codec)
{
var bpp;
var pixRate =
parseInt(document.Calc.Width.value)*parseInt(document.Calc.Height.value)*parseFloat
(document.Calc.FPS.value);
if(codec == 'raw') {
bpp = 24;
} else if(codec == 'mp4') {
bpp = 0.25;
} else if(codec == 'h264') {
bpp = 0.13;
} else if(codec == 'h264+') {
bpp = 0.11;
} else { //if(codec == 'h265')
bpp = 0.075;
}

if(codec != 'raw') {
if(document.Calc.cgi.checked) { bpp *= 0.75; }
if(document.Calc.dark.checked) { bpp *= 0.85; }
if(document.Calc.noise.checked) { bpp *= 1.25; }
}

document.Calc.BPP.value = roundN(bpp, 6);


flash('BPP');
bppChanged();
}

function setSize(s)
{
document.Calc.bytes.value = s;
updateCalc('bytes');
}

function szPreset()
{
var sel = document.getElementById("sz_pre");
var numOpt = sel.options.length;
for(var i = 0; i < numOpt; i++) {
var opt = sel.options[i];
if(opt.selected) {
setSize(opt.value);
sel.selectedIndex = -1;
return;
}
}
}

function setFPS(f)
{
document.Calc.FPS.value = f;
flash('FPS');
getBPP();
}

function fpsPreset()
{
var sel = document.getElementById("FPS_pre");
var numOpt = sel.options.length;
for(var i = 0; i < numOpt; i++) {
var opt = sel.options[i];
if(opt.selected) {
setFPS(opt.value);
sel.selectedIndex = -1;
return;
}
}
}

function frameChanged()
{
getAR();
getBPP();
}

function ratioChanged()
{
var width = parseInt(document.Calc.Width.value);
var aRatio = document.Calc.AR.value;
if(aRatio.match(/^\d*\.?\d+:\d*\.?\d+$/)) {
var parts = aRatio.split(':');
aRatio = parts[0]/parts[1];
}
else {
aRatio = parseFloat(aRatio);
}
document.Calc.Height.value = Math.round(width/aRatio);
flash('Height');
getBPP();
}

function whPreset()
{
var sel = document.getElementById("WH_pre");
var numOpt = sel.options.length;
for(var i=0; i<numOpt; i++) {
var opt = sel.options[i];
if(opt.selected) {
var wh = opt.value.split("x");
document.Calc.Width.value = wh[0];
document.Calc.Height.value = wh[1];
getAR();
getBPP();
sel.selectedIndex = -1;
return;
}
}
}

function bppChanged()
{
var width = parseInt(document.Calc.Width.value);
var height = parseInt(document.Calc.Height.value);
var pixRate = width*height*parseFloat(document.Calc.FPS.value);
document.Calc.RVideo.value = roundN(pixRate *
parseFloat(document.Calc.BPP.value) / 1000, 2);
flash('RVideo');
updateRate('vidFromBPP');
}

function flash(fields)
{
var fieldsArray = fields.split(',');
for(var i=0; i<fieldsArray.length; i++) {
document.Calc.elements[fieldsArray[i]].setAttribute('class', 'flash');
}
window.setTimeout(function() {unFlash(fields);}, 500);
}

function unFlash(fields)
{
var fieldsArray = fields.split(',');
for(var i=0; i<fieldsArray.length; i++) {
document.Calc.elements[fieldsArray[i]].setAttribute('class', 'plain');
}
}

function showFlds(evt)
{
var fArray = evt.currentTarget.inFields.split(',');
for(var i=0; i<fArray.length; i++) {
document.Calc.elements[fArray[i]].setAttribute('class', 'in');
}
var outf = evt.currentTarget.outFields;
if(!outf)
return;
fArray = outf.split(',');
for(var i=0; i<fArray.length; i++) {
document.Calc.elements[fArray[i]].setAttribute('class', 'out');
}
}

function hideFlds(evt)
{
var f = evt.currentTarget.inFields;
if(evt.currentTarget.outFields)
f += ',' + evt.currentTarget.outFields;
unFlash(f);
}

function prepInput(id, ins, outs, onEvt, act)


{
var e = document.getElementById(id);
e.inFields = ins;
e.outFields = outs;
if(isTouch) {
e.removeEventListener("mouseover", showFlds);
e.removeEventListener("mouseout", hideFlds);
e.addEventListener("touchstart", showFlds, optionPassive);
e.addEventListener("touchend", hideFlds, optionPassive);
}
else {
e.removeEventListener("touchstart", showFlds);
e.removeEventListener("touchend", hideFlds);
e.addEventListener("mouseover", showFlds);
e.addEventListener("mouseout", hideFlds);
}
e.addEventListener(onEvt, function(evt) {
if(isTouch) {
showFlds(evt);
window.setTimeout(function() {unFlash(ins);}, 500);
}
act();
});
}

function setupInputs()
{
prepInput("tsa2vid", 'HH,MM,SS,ROver,ATrack,RAudio,bytes',
'RVideo,RTotal,BPP', 'click', function() {updateRate('time2vid');});
prepInput("tsv2aud", 'HH,MM,SS,ROver,ATrack,RVideo,bytes', 'RAudio,RTotal',
'click', function() {updateRate('time2aud');});
prepInput("tsva2o", 'HH,MM,SS,RVideo,ATrack,RAudio,bytes', 'ROver,RTotal',
'click', function() {updateRate('time2ovh');});
prepInput("bs2t", 'bytes,RTotal', 'TB,HH,MM,SS', 'click', getTime);
var sFlds = 'bytes,kB,MB,GB,bits,KiB,MiB,GiB';
prepInput("tb2s", 'HH,MM,SS,RTotal', sFlds, 'click', function()
{getSize('total');});
prepInput("v2s", 'HH,MM,SS,RVideo', sFlds, 'click', function()
{getSize('video');});
prepInput("a2s", 'HH,MM,SS,ATrack,RAudio', sFlds, 'click', function()
{getSize('audio');});
prepInput("AR", 'Width', 'Height,BPP', 'change', ratioChanged);
prepInput("BPP", 'Width,Height,FPS', 'RVideo,RTotal', 'change', bppChanged);
sFlds = 'RVideo,RTotal,BPP';
prepInput("rRaw", 'Width,Height,FPS', sFlds, 'click', function()
{guessRate('raw');});
prepInput("rMP4", 'Width,Height,FPS', sFlds, 'click', function()
{guessRate('mp4');});
prepInput("r264", 'Width,Height,FPS', sFlds, 'click', function()
{guessRate('h264');});
prepInput("r264h", 'Width,Height,FPS', sFlds, 'click', function()
{guessRate('h264+');});
prepInput("r265", 'Width,Height,FPS', sFlds, 'click', function()
{guessRate('h265');});
document.getElementById('F_UI').value = "Force "+(isTouch?"desktop UI":"touch
UI");
document.getElementById('F_UI').addEventListener('click', toggleUI);
}

function toggleUI()
{
isTouch = !isTouch;
setupInputs();
}

function initCalc()
{
if('ontouchstart' in window || navigator.maxTouchPoints > 0)
isTouch = true;
setupInputs();
updateCalc('bytes');
updateHMS('s');
updateRate('time2vid');
// hack: ensure selecting value always triggers onChange
var reset = ["AR", "FPS", "WH", "sz"];
for(var i = 0; i < reset.length; i++) {
document.getElementById(reset[i] + "_pre").selectedIndex = -1;
}
}

if(document.readyState !== 'loading') {


initCalc();
} else { // DO NOT wait for ads or other stuff
document.addEventListener("DOMContentLoaded", initCalc);
}
// -->
</SCRIPT><!--/HTMLTW--><NOSCRIPT><DIV style="font-weight: bold; color: #900">In
order to work, the calculator requires JavaScript, which your browser doesn't
support or it has been turned off.</DIV></NOSCRIPT>

<H1 style="margin-bottom: .25em">Video Bitrate Calculator</H1>


</DIV></DIV>

<FORM name="Calc" action="javascript:return false" onSubmit="return false;">


<TABLE style="border: 0; border-spacing: 0; margin: 0 auto">
<TR class="set0"><TD colspan=4 class="title"><EM>Calculate bitrates from total file
size and duration</EM></TD></TR>
<TR class="set0">
<TD class="Label"><LABEL for="TB">Seconds:</LABEL></TD><TD><INPUT type="text"
name="secs" value="7200" size=8 onChange="updateHMS('s')" id="TB"></TD>
<TD class="Label"><LABEL for="HH">HH:</LABEL><LABEL for="MM">MM:</LABEL><LABEL
for="SS">SS:</LABEL></TD><TD><INPUT type="text" name="HH" value="02" size=2
onChange="updateHMS('H')" id="HH">:<INPUT type="text" name="MM" value="00" size=2
onChange="updateHMS('M')" id="MM">:<INPUT type="text" name="SS" value="00" size=2
onChange="updateHMS('S')" id="SS"></TD>
</TR>
<TR class="set0">
<TD class="Label"><LABEL for="RTotal">Total bitrate:</LABEL></TD><TD><INPUT
type="text" name="RTotal" value="?" size=8 onChange="updateRate('total')"
id="RTotal">kbps</TD>
<TD colspan=2></TD>
</TR>
<TR class="set0">
<TD class="Label"><LABEL for="RVideo">Video bitrate:</LABEL></TD><TD><INPUT
type="text" name="RVideo" value="?" size=8 onChange="updateRate('video')"
id="RVideo">kbps</TD>
<TD class="Label"><LABEL for="RAudio">Audio bitrate:</LABEL></TD><TD><INPUT
type="text" name="RAudio" value="128" size=8 onChange="updateRate('audio')"
id="RAudio" title="per audio track">kbps <SELECT id="AR_pre" title="Common audio
bitrates" aria-label="Common audio bitrates" class="drop" onChange="arPreset()">
<OPTION value="128">128 (oldskool bad MP3s, decent stereo AAC)</OPTION>
<OPTION value="160">160</OPTION>
<OPTION value="192">192 (typical AC3 stereo or decent MP3)</OPTION>
<OPTION value="384">384 (typical for AC3 on DVDs)</OPTION>
<OPTION value="448">448 (maximum for AC3 on DVDs)</OPTION>
<OPTION value="640">640 (typical for AC3 on BluRay)</OPTION>
<OPTION value="755">755 (half-rate DTS: AVOID, it is bad)</OPTION>
<OPTION value="1509">1509 (true DTS: this is the good one)</OPTION>
</SELECT></TD>
</TR>
<TR class="set0">
<TD class="Label"><LABEL for="ROver">Overhead:</LABEL></TD><TD><INPUT type="text"
name="ROver" value="2" size=8 onChange="updateRate('over')" id="ROver">kbps</TD>
<TD class="Label"><LABEL for="ATrack">Audio tracks:</LABEL></TD><TD><INPUT
type="text" name="ATrack" value="1" size=3 onChange="updateRate('audio')"
id="ATrack"> <INPUT type="button" class="sml" value="+" onClick="moreATracks()">
<INPUT type="button" class="sml" value="–" onClick="fewerATracks()"></TD>
</TR>
<TR class="set0">
<TD class="Label Action">Compute bitrates:</TD><TD colspan=3><INPUT type="button"
value="Video from time,size,audio" title="Calculate video bitrate"
id="tsa2vid"><INPUT type="button" value="Audio from time,size,video"
title="Calculate audio bitrate" id="tsv2aud"></TD>
</TR>
<TR class="set0">
<TD></TD><TD colspan=3><INPUT type="button" value="Overhead from
time,size,video,audio" title="Calculate overhead bitrate" id="tsva2o"></TD>
</TR>
<TR class="set0">
<TD class="Label Action bottom">Get time from:</TD><TD colspan=3
class="bottom"><INPUT type="button" value="Bitrate &amp; file size" id="bs2t"></TD>
</TR>

<TR class="set1"><TD colspan=4 class="title"><EM>Calculate total file size from


bitrates and duration</EM></TD></TR>
<TR class="set1">
<TD class="Label"><LABEL for="bytes">Bytes:</LABEL></TD><TD><INPUT type="text"
name="bytes" value="4700000000" size=16 onChange="updateCalc('bytes')" id="bytes">
<SELECT id="sz_pre" title="Classic media sizes" aria-label="Common media sizes"
class="drop" onChange="szPreset()">
<OPTION value="1474560">1440KiB (HD floppy)</OPTION>
<OPTION value="681574400">650MiB (CD-R)</OPTION>
<OPTION value="736100352">702MiB (CD-R)</OPTION>
<OPTION value="2147483647">2GiB-1 (file limit on some systems)</OPTION>
<OPTION value="4294967295">4GiB-1 (FAT32 file limit)</OPTION>
<OPTION value="4700000000">4.7GB (DVD-R single layer)</OPTION>
<OPTION value="8530000000">8.5GB (DVD-R dual layer)</OPTION>
<OPTION value="25000000000">25GB (BD)</OPTION>
<OPTION value="50000000000">50GB (dual layer BD)</OPTION>
</SELECT></TD>
<TD class="Label"><LABEL for="bits">bits:</LABEL></TD><TD><INPUT type="text"
name="bits" value="?" size=16 onChange="updateCalc('bits')" id="bits"></TD>
</TR>
<TR class="set1">
<TD class="Label"><LABEL for="kB">kiloBytes (kB):</LABEL></TD><TD><INPUT
type="text" name="kB" value="?" size=16 onChange="updateCalc('kB')" id="kB"></TD>
<TD class="Label"><LABEL for="KiB">kibiBytes (KiB):</LABEL></TD><TD><INPUT
type="text" name="KiB" value="?" size=16 onChange="updateCalc('KiB')"
id="KiB"></TD>
</TR>
<TR class="set1">
<TD class="Label"><LABEL for="MB">megaBytes (MB):</LABEL></TD><TD><INPUT
type="text" name="MB" value="?" size=16 onChange="updateCalc('MB')" id="MB"></TD>
<TD class="Label"><LABEL for="MiB">mebiBytes (MiB):</LABEL></TD><TD><INPUT
type="text" name="MiB" value="?" size=16 onChange="updateCalc('MiB')"
id="MiB"></TD>
</TR>
<TR class="set1">
<TD class="Label"><LABEL for="GB">gigaBytes (GB):</LABEL></TD><TD><INPUT
type="text" name="GB" value="?" size=16 onChange="updateCalc('GB')" id="GB"></TD>
<TD class="Label"><LABEL for="GiB">gibiBytes (GiB):</LABEL></TD><TD><INPUT
type="text" name="GiB" value="?" size=16 onChange="updateCalc('GiB')"
id="GiB"></TD>
</TR>
<TR class="set1">
<TD class="Label Action bottom">Get file size from:</TD><TD colspan=3
class="bottom"><INPUT type="button" value="Time &amp; bitrate" id="tb2s"> <INPUT
type="button" value="Video size only" id="v2s"> <INPUT type="button" value="Audio
size only" id="a2s"></TD>
</TR>

<TR class="set2"><TD colspan=4 class="title"><EM>Suggest a good quality video


bitrate from frame dimensions, codec, and content type</EM></TD></TR>
<TR class="set2">
<TD class="Label"><LABEL for="Width">Dimensions (W&times;H):</LABEL></TD><TD><INPUT
type="text" name="Width" title="pixels" aria-label="Width in pixels" value="1280"
size=5 id="Width" onChange="frameChanged()">&times;<INPUT type="text" name="Height"
title="pixels" aria-label="Height in pixels" value="720" size=5 id="Height"
onChange="frameChanged()">px <SELECT id="WH_pre" title="Common frame sizes" aria-
label="Common frame sizes" class="drop" onChange="whPreset()">
<OPTION value="1280x720">720p 16:9</OPTION>
<OPTION value="1280x692">720p 1.85:1</OPTION>
<OPTION value="1280x536">720p 2.39:1</OPTION>
<OPTION value="1920x1080">1080p 16:9</OPTION>
<OPTION value="1920x1038">1080p 1.85:1</OPTION>
<OPTION value="1920x800">1080p 2.39:1</OPTION>
<OPTION value="3840x2160">UHD 16:9</OPTION>
<OPTION value="3840x2076">UHD 1.85:1</OPTION>
<OPTION value="3840x1608">UHD 2.39:1</OPTION>
</SELECT></TD>
<TD class="Label"><LABEL for="FPS">Frame rate:</LABEL></TD><TD><INPUT type="text"
name="FPS" value="23.976" size=6 id="FPS" onChange="getBPP()">FPS <SELECT
id="FPS_pre" title="Common frame rates" aria-label="Common frame rates"
class="drop" onChange="fpsPreset()">
<OPTION value="23.976">23.976 (NTSC film)</OPTION>
<OPTION value="24">24 (film)</OPTION>
<OPTION value="25">25 (PAL)</OPTION>
<OPTION value="29.97">29.97 (NTSC)</OPTION>
<OPTION value="30">30</OPTION>
<OPTION value="48">48 (for hobbits)</OPTION>
<OPTION value="50">50 (PAL high)</OPTION>
<OPTION value="59.94">59.94 (NTSC high)</OPTION>
<OPTION value="60">60</OPTION>
</SELECT></TD>
</TR>
<TR class="set2">
<TD class="Label"><LABEL for="AR"><SPAN style="font-weight: bold">Aspect
ratio:</SPAN></LABEL></TD><TD><INPUT type="text" name="AR" title="Value may also be
entered as w:h ratio" value="1.78" size=8 id="AR"></TD>
<TD class="Label"><LABEL for="BPP">Bits/pixel:</LABEL></TD><TD><INPUT type="text"
name="BPP" value="?" size=8 id="BPP"></TD>
</TR>
<TR class="set2">
<TD class="Label">Video content:</TD><TD colspan=3><LABEL title="Very clean noise-
free images"><INPUT type="checkbox" name="cgi">(Mostly) CGI</LABEL> <LABEL
title="Large areas that look uniform, rarely change, or are blurry"><INPUT
type="checkbox" name="dark">Dark scenes/Still images</LABEL> <LABEL title="Noise-
like image content like foliage"><INPUT type="checkbox" name="noise">Noisy
image/Trees/Bushes</LABEL></TD>
</TR>
<TR class="set2">
<TD class="Label Action bottom">Suggest bitrate for:</TD><TD colspan=3
class="bottom"><INPUT type="button" value="Raw" title="Uncompressed"
id="rRaw"><INPUT type="button" value="MP4" title="DivX, Xvid, etc."
id="rMP4"><INPUT type="button" value="H.264 baseline" id="r264"><INPUT
type="button" value="H.264 high" id="r264h"><INPUT type="button" value="H.265 main"
id="r265"></TD>
</TR>
</TABLE>
<DIV class="center"><INPUT type="button" value="UI" id="F_UI" class="sml"></DIV>
</FORM>

<DIV class="mRoot">
<DIV class="article">
<!--HTMLTW includeFile="infoAd-inArt.emb"--><DIV class="adBox"><script async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4744639122259360"
data-ad-slot="2576862267"></ins></DIV>
<!--needs cookiemgr--><!--/HTMLTW-->

<P class="center">
&#9670; Other calculators: <STRONG><A href="bytecalc.html">File sizes</A> — <A
href="timecalc.html">Time</A></STRONG> &#9670;
</P>

<H2 id="about">About</H2>
<P>
This calculator is intended to make bitrate calculations for encoding movies
easier. Fields used as inputs for a button or edit field are <SPAN
class="in">highlighted in green</SPAN>, and output fields <SPAN class="out">in pale
yellow</SPAN>. When pushing a button or having edited a field, fields updated by
this action will flash <SPAN class="flash">bright yellow</SPAN>.<br>
Highlighting behaviour differs between desktop and touch browsers due to
differences between a cursor- or touch-driven UI. If you prefer either or the
other, or if touch UI detection should fail, the button below the calculator allows
to override it.
</P>

<H2 id="use">Usage</H2>
<P>
The classic use case is to determine the required video bitrate to fill a fixed-
size medium like a CD-R or DVD+R, given a fixed audio bitrate and movie duration.
To do this, enter the duration, audio bitrate and target size, and press the
<EM>“Video from time,size,audio”</EM> button. You can do the same for audio. Total
audio bitrate is the number of audio tracks times the given audio bitrate. You can
use this to either represent multiple tracks (for instance languages), or multiple
discrete surround channels.
</P>
<P>
Another useful scenario is to determine whether a video file can fit in a fixed-
size medium like a DVD-R at acceptable quality. Or likewise, if you want to avoid
wasting download time on a file that just seems too small to possibly offer good
quality. In these cases, do the same as above to calculate the actual video bitrate
and write down or memorise this number. Then enter the film's image dimensions and
frame rate in the lower part of the calculator. Push the appropriate ‘Suggest
bitrate’ button (see instructions <A href="#suggest">below</A>). If the suggested
video bitrate is much higher than the actual one (about double or more), video
quality will probably be unacceptably bad. Just to give an example: with H.264
there is <EM>no</EM> way to fit a normal two-hour film on a single CD-R at anything
higher than DVD resolution without making it look or sound awful, so please do not
try it.
</P>
<P>
Mind that sizes are given in two ‘flavours.’ If you don't know the difference
between a <EM>MB</EM> and a <EM>MiB</EM>, check out my <A
href="bytecalc.html">other page that explains it</A>. Unfortunately a lot of
software still uses the ‘MB’ symbol while they actually mean MiB. In case of doubt,
assume KiB, MiB and GiB values: if the software does use kB, MB, and GB, your file
will be slightly too small, which is not as bad as too large.
</P>
<P>
<EM>Overhead</EM> is what is left of the file after removing actual video and audio
data. This is heavily dependent on the container format, codecs and parameters, and
includes any extra streams like subtitles. This calculator assumes overhead is
proportional to the length of the video, which is a simplification. In reality
there will also be a one-time overhead for the file itself and metadata. In case of
doubt and if the file must fit within a certain size, it's better to use a
conservatively high overhead estimate.
</P>

<H3 id="suggest">Bitrate suggestion</H3>


<P>
The <EM>‘Suggest bitrate’</EM> buttons try to give an OK <EM>average</EM> video
bitrate estimate for a movie, based on given dimensions, frame rate, and the video
codec. (If you don't know what a codec is, I have <A
href="mediaformats.html">another page that explains this</A>.) Most likely you
should use either the “H.264 high” button because practically everything nowadays
supports the ‘high’ H.264 profile, or the “H.265” button if you are encoding with
that codec. The other buttons are legacy: the “MP4” button represents encoding with
the old MPEG-4 based Xvid or DivX which only makes sense if the target is some old
constrained playback device. The “H.264 baseline” button represents encoding with
H.264 without advanced options like trellis, CABAC, RD, etc., which also would only
be appropriate in limited situations.<br>
For giggles, the “Raw” button shows bitrate for raw (uncompressed) video—try it and
you'll see why codecs were invented.
</P>
<P>
Beware that this is not exact science. It is wet-finger guesswork because except
for raw video, the actual required bitrate depends heavily on video contents. The
calculation assumes you're using double-pass encoding and a ‘typical’ frame rate
(around 25fps). A few checkboxes are provided to allow somewhat tuning the guess:
check the ‘CGI’ box if the film consists purely or mostly of smooth computer-
generated images (like Toy Story, Ice Age, …); check the ‘Dark’ box for films that
have many dark shots with large parts of the image often almost pure black or out-
of-focus (e.g., Dark City). Check the ‘Noisy’ button if the image is noticeably
noisy throughout, has a lot of fast movement, and/or contains a lot of footage of
trees, bushes or other cluttered things. For a movie like Avatar, you should check
this: even though it is mostly CGI, the images are very detailed and there is a lot
of action.
</P>
<P>
I tuned this estimator by encoding various 1080p24 video fragments at a quality
where I couldn't see any image degradation in the result without rigorously
comparing to the source material. The estimates deliver in my opinion a “good
enough” quality on average if the goal is to stay close to the source material.<br>
The main purpose of this tool is to check whether the bitrate you're going to use
is reasonable. If you encode a film with an actual video bitrate more than twice
what this estimate gives, you're probably wasting disk space unless you are adamant
on preserving film grain. If your bitrate is considerably lower than this estimate,
the quality of the encoding will probably be bad. How bad, depends on both the
codec and the content of the video. The less detail, movement, and noise in the
image, the easier it is to encode. For instance computer animations with very clean
images and generally static backgrounds (like the Toy Story series) can fit in a
surprisingly low bitrate without obvious quality loss. As for the codec: H.264 and
similar modern codecs are very capable at gracefully degrading the image, therefore
even if you go far below what this calculator suggests, it may still look OK on its
own. Compared to the original or a higher bitrate encoding however, it will look
obviously washed-out if bitrate is too low.
</P>
<P>
Bitrate requirements also tend to become less strict for higher-resolution video.
This calculator does not take this fact into account, therefore you may consider
the estimate the more conservative the larger your video frame size is. The same
goes for higher frame rates.
</P>

<H2 id="hint">Hints</H2>

<H3>Avoid relying on bitrate altogether</H3>


<P>
If you are encoding a film and it doesn't really matter how large the resulting
file is yet you don't want to waste disk space, consider using <EM>quality-based
encoding,</EM> which in most cases makes a lot more sense than using a fixed
bitrate. A fixed bitrate only makes sense for streaming or storage on a fixed-size
medium. I explain this in more detail in <A href="videotips.html">my article with
video encoding tips</A>.
</P>
<P>
If you're planning to encode multiple movies that must fit within a specific size,
e.g., three movies in 4.7GB, do not just encode each movie to be 4.7/3 = 1.56GB.
That does not make sense unless they are all the same length, frame rate, and frame
size. To get a sensible idea of what the relative sizes of the movies should be,
use the ‘Suggest bitrate’ feature to determine their ‘ideal’ sizes and then try to
divide the total available size in chunks that have the same proportions. For
instance if the calculator says that film <VAR>A</VAR> should be 3 GB, <VAR>B</VAR>
2 GB and <VAR>C</VAR> 1.5 GB, and you want to squeeze all three on a single 4.7 GB
DVD-R, you should try to make them respectively 2.17 GB, 1.45 GB and 1.08 GB.
</P>
<P>
Also do not try to steal bitrate from the audio stream in order to get marginally
more bits for video. The audio stream is typically much smaller anyway so there is
not much to gain, and worse audio is much more annoying than slightly worse video.
If you really are short on bits, consider reducing the number of audio channels
(5.1 to stereo, or stereo to mono), instead of trying to squeeze too many audio
channels in too low a bitrate.
</P>

<H3>Get true bitrates with mediainfo</H3>


<P>
<A href="https://mediaarea.net/en/MediaInfo">Mediainfo</A> normally only shows
bitrates if they are stored in the file's metadata. If the bitrate numbers are not
in there, they will be missing from mediainfo's output no matter what you try,
unless you run it in a special mode that forces a full analysis of the file. By
adding the <CODE>--ParseSpeed=1</CODE> option, it will parse the entire file and
recompute bitrates. This is of course way slower but you will obtain the actual
values. The following example (for bash-like shells) prints true average bitrates
for both video and audio.
</P>
<P class="code">
mediainfo --ParseSpeed=1 --Inform=$'Video;Video: %BitRate/String%\\n\nAudio;Audio:
%BitRate/String%' yourfile.mkv
</P>

<H3>Short note about DTS</H3>


<P>
If you are confused about DTS bitrates: the classic DTS audio stream has an actual
bitrate of 1509 kbps (sometimes also 1509.75) but when sending it over a cable, it
is encapsulated in a transmission stream of 1536 kbps, the exact rate of
uncompressed stereo PCM audio. (Similar for the to-be-avoided half-bitrate variant:
754.5 and 768 kbps respectively.) Obviously when using such track in an efficient
media file, only the true rate will be used.
</P>

<DIV class="copy">©2010-2024 Alexander Thomas</DIV>

<DIV class="license center"><A rel="license"


href="https://creativecommons.org/licenses/by/4.0"><IMG alt="Creative Commons
Licence" style="border-width:0" src="../imags/cc-by-88x31.svg" width=88
height=31></A><br>This work is licensed under a <A rel="license"
href="https://creativecommons.org/licenses/by/4.0">Creative Commons Attribution 4.0
International License</A>.</DIV>

</DIV><!--article-->

<!-- Begin LexStat3 code -->


<SCRIPT async src="/lexstat3.js"></SCRIPT>
<DIV id="lexstat" data-id="videocalc" data-w=1 data-h=1><NOSCRIPT><IMG src="/cgi-
bin/lexstat.gif?id=videocalc" width=1 height=1 alt=""></NOSCRIPT></DIV>
<!-- End LexStat3 code -->

<SCRIPT async src="../bookmark2.js"></SCRIPT><DIV id="lexbmark"></DIV>

<!--HTMLTW includeFile="infoAds.emb"--><DIV class="adBox">


<script async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- InfoAds -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-4744639122259360"
data-ad-slot="5605158675"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<SCRIPT async src="../cookiemgr_v2.js"></SCRIPT>
</DIV><!--/HTMLTW-->

</DIV><!--mRoot-->

<DIV id="footMargin"></DIV>
</DIV><!--wrapper-->

<!--HTMLTW includeFile="nav-info-footer.emb" leaf="Video Bitrate Calculator"--><DIV


id="footer" class="navbar2">
<OL class="nav">
<LI class="nav0"><A href="../"><SPAN>Dr. Lex' Site</SPAN></A></LI><LI
class="nav1"><A href="./"><SPAN>Educative</SPAN></A></LI><LI
class="nav2"><SPAN>Video Bitrate Calculator</SPAN></LI>
</OL>
</DIV><!--/HTMLTW-->

</BODY>
</HTML>

You might also like