<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Helyar.net &#187; aac</title>
	<atom:link href="http://www.helyar.net/tag/aac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.helyar.net</link>
	<description>From the desktop of George Helyar</description>
	<lastBuildDate>Thu, 26 Jan 2012 16:11:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to set target file sizes in ffmpeg</title>
		<link>http://www.helyar.net/2009/how-to-set-target-file-sizes-in-ffmpeg/</link>
		<comments>http://www.helyar.net/2009/how-to-set-target-file-sizes-in-ffmpeg/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 21:29:39 +0000</pubDate>
		<dc:creator>George Helyar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aac]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[x264]]></category>

		<guid isPermaLink="false">http://www.helyar.net/?p=240</guid>
		<description><![CDATA[This script is now available as an ongoing project that can be downloaded. Please see the Video Encoding Project. This post describes the methods and mathematics behind the script. After much searching, I found almost nothing regarding how to target a specific file size with ffmpeg, such as 700MiB to fit on a CD. Almost [...]]]></description>
			<content:encoded><![CDATA[<p>This script is now available as an ongoing project that can be downloaded. Please see the <a href="http://www.helyar.net/enc">Video Encoding Project</a>. This post describes the methods and mathematics behind the script.<br />
<hr />
<p>After much searching, I found almost nothing regarding how to target a specific file size with ffmpeg, such as 700MiB to fit on a CD. Almost everything I found suggested to use a negative bitrate for mencoder, such as -700000. However, this did not work for me at all (even by copying and pasting verbatim). Because of this, I set about doing it manually with some mathematics.</p>
<p>What I am going to do here assumes a single audio stream, a single video stream and nothing else in the output file at all (i.e. no subtitles, no alternate languages, no director&#8217;s commentaries, etc).</p>
<p>When encoding media, audio uses a constant bit rate. This means that you can calculate how much space it will take if you know which bit rate you are using and how long the stream is in seconds. This also means that to know how big the video stream should be, we can calculate how big the audio stream will be and subtract it from the target file size. For example, if the target file size is 350MiB and the audio will take up 30MiB, we know the video should aim to be 320MiB (ignoring overheads in the multiplexing, container headers, etc). We can use the same calculations in reverse to work out an average or constant bit rate from a file size and a length in seconds.</p>
<p>In this example, I will be using <a href="http://www.amazon.co.uk/Dads-Army-Complete-Collection-DVD/dp/B000VA3J7K">Dad&#8217;s Army</a> Series 6 Episode 1 &#8211; The Deadly Attachment. I have already ripped this from the DVD with <a href="http://www.slysoft.com/en/anydvd.html">SlySoft AnyDVD</a> and PgcDemux on Windows. Automating PgcDemux rips is worth a whole entry in itself. Note that I have bought this legally and I do not intend to sell or share it. I just want a copy that I can store on my network and play from any computer. Storing 14 DVD images on hard drives takes quite a lot of space, which is where encoding comes in handy. In fact, some of my box sets contain over 60 DVDs (roughly 270GiB).</p>
<p>&#8212;&#8212;&#8212;-<br />
To install ffmpeg on Debian, it is best to get it from the Debian Multimedia repository. Add</p>
<pre>deb http://www.debian-multimedia.org lenny main
deb-src http://www.debian-multimedia.org lenny main</pre>
<p>to your /etc/apt/sources.list and then run</p>
<pre># apt-get update
# apt-get install debian-multimedia-keyring
# apt-get update
# apt-get install ffmpeg</pre>
<p>&#8212;&#8212;&#8212;-</p>
<p>The first thing we need to do to put this into practice is to get the length of the stream. If you supply the file to ffmpeg without telling it to do anything, it will give you an error. However, this error already contains all of the information we need:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;color: black;">$ <span style="color: #c20cb9; font-weight: bold;color: blue;">ffmpeg</span> <span style="color: #660033;">-i</span> da_6_01.VOB
FFmpeg version SVN-r13582, Copyright <span style="color: #7a0874; font-weight: bold;color: black;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;color: black;">&#41;</span> <span style="color: #000000;color: maroon;">2000</span>-<span style="color: #000000;color: maroon;">2008</span> Fabrice Bellard, et al.
  configuration: <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;color: black;">/</span>usr ...
  built on May  <span style="color: #000000;color: maroon;">3</span> <span style="color: #000000;color: maroon;">2009</span> <span style="color: #000000;color: maroon;">12</span>:07:<span style="color: #000000;color: maroon;">18</span>, <span style="color: #c20cb9; font-weight: bold;color: blue;">gcc</span>: 4.3.2
Input <span style="color: #666666; font-style: italic;">#0, mpeg, from 'da_6_01.VOB':</span>
  Duration: 00:<span style="color: #000000;color: maroon;">29</span>:<span style="color: #000000;color: maroon;">23.90</span>, start: <span style="color: #000000;color: maroon;">0.287267</span>, bitrate: <span style="color: #000000;color: maroon;">5987</span> kb<span style="color: #000000; font-weight: bold;color: black;">/</span>s
    Stream <span style="color: #666666; font-style: italic;">#0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 9800 kb/s, 25.00 tb(r)</span>
    Stream <span style="color: #666666; font-style: italic;">#0.1[0x80]: Audio: ac3, 48000 Hz, stereo, 192 kb/s</span>
Must supply at least one output <span style="color: #c20cb9; font-weight: bold;color: blue;">file</span></pre></div></div>

<p>We can see that the duration is 00:29:23.90.</p>
<p>As this is an error, we need to redirect stderr to stdout. This can be done with 2>&#038;1. We then need the line that contains the &#8220;Duration&#8221;, which we can get with grep. We can cut this line up to take the time out.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;color: black;">$ <span style="color: #c20cb9; font-weight: bold;color: blue;">ffmpeg</span> <span style="color: #660033;">-i</span> da_6_01.VOB <span style="color: #000000;color: maroon;">2</span><span style="color: #000000; font-weight: bold;color: black;">&gt;&amp;</span><span style="color: #000000;color: maroon;">1</span> <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">grep</span> Duration <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">' '</span> <span style="color: #660033;">-f</span> <span style="color: #000000;color: maroon;">4</span> <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'.'</span> <span style="color: #660033;">-f</span> <span style="color: #000000;color: maroon;">1</span>
00:<span style="color: #000000;color: maroon;">29</span>:<span style="color: #000000;color: maroon;">23</span></pre></div></div>

<p>This can be converted into seconds with the formula <code>s' = (h * 60 + m) * 60 + s</code>.</p>
<p>I used a python script to do this and to perform the necessary calculations mentioned earlier. Note that most of this python script is just for the convenience of getopts and that, if needed, it can be cut down significantly at the cost of flexibility. If you always want the same output size and audio bitrate, this script can be simplified to just a couple of lines.</p>
<p>calc_bitrate.py:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: black;"><span style="color: #808080; font-style: italic;color: green;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">from</span> <span style="color: #dc143c;color: blue;">getopt</span> <span style="color: #ff7700;font-weight:bold;color: blue;">import</span> <span style="color: #dc143c;color: blue;">getopt</span>, GetoptError
<span style="color: #ff7700;font-weight:bold;color: blue;">from</span> <span style="color: #dc143c;color: blue;">sys</span> <span style="color: #ff7700;font-weight:bold;color: blue;">import</span> argv, exit
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">def</span> secs<span style="color: black;color: black;">&#40;</span>h, m, s<span style="color: black;color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;color: blue;">return</span> <span style="color: black;color: black;">&#40;</span>h <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">60</span> + m<span style="color: black;color: black;">&#41;</span> <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">60</span> + s
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">def</span> calc_video_bitrate<span style="color: black;color: black;">&#40;</span>target_size, abr, <span style="color: #dc143c;color: blue;">time</span><span style="color: black;color: black;">&#41;</span>:
  target_bytes = target_size <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">1024</span> <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">1024</span>
  audio_bytes = <span style="color: black;color: black;">&#40;</span><span style="color: black;color: black;">&#40;</span>abr <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">1000</span><span style="color: black;color: black;">&#41;</span> / <span style="color: #ff4500;color: maroon;">8</span><span style="color: black;color: black;">&#41;</span> <span style="color: #66cc66;color: black;">*</span> <span style="color: #dc143c;color: blue;">time</span>
  <span style="color: #ff7700;font-weight:bold;color: blue;">return</span> <span style="color: black;color: black;">&#40;</span>target_bytes - audio_bytes<span style="color: black;color: black;">&#41;</span> / <span style="color: #dc143c;color: blue;">time</span> <span style="color: #66cc66;color: black;">*</span> <span style="color: #ff4500;color: maroon;">8</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">try</span>:
  opts, args = <span style="color: #dc143c;color: blue;">getopt</span><span style="color: black;color: black;">&#40;</span>argv<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">1</span>:<span style="color: black;color: black;">&#93;</span>, <span style="color: #483d8b;color: maroon;">&quot;s:a:t:&quot;</span>, <span style="color: black;color: black;">&#91;</span><span style="color: #483d8b;color: maroon;">&quot;size=&quot;</span>, <span style="color: #483d8b;color: maroon;">&quot;abr=&quot;</span>, <span style="color: #483d8b;color: maroon;">&quot;time=&quot;</span><span style="color: black;color: black;">&#93;</span><span style="color: black;color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;color: blue;">except</span> GetoptError, err:
  <span style="color: #ff7700;font-weight:bold;color: blue;">print</span> <span style="color: #008000;color: blue;">str</span><span style="color: black;color: black;">&#40;</span>err<span style="color: black;color: black;">&#41;</span>
  exit<span style="color: black;color: black;">&#40;</span><span style="color: #ff4500;color: maroon;">2</span><span style="color: black;color: black;">&#41;</span>
&nbsp;
target_size = <span style="color: #ff4500;color: maroon;">350</span> <span style="color: #808080; font-style: italic;color: green;">#MiB</span>
abr = <span style="color: #ff4500;color: maroon;">128</span> <span style="color: #808080; font-style: italic;color: green;">#kbps</span>
<span style="color: #dc143c;color: blue;">time</span> = <span style="color: #ff4500;color: maroon;">0</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">for</span> o, a <span style="color: #ff7700;font-weight:bold;color: blue;">in</span> opts:
  <span style="color: #ff7700;font-weight:bold;color: blue;">if</span> o <span style="color: #ff7700;font-weight:bold;color: blue;">in</span> <span style="color: black;color: black;">&#40;</span><span style="color: #483d8b;color: maroon;">&quot;-s&quot;</span>, <span style="color: #483d8b;color: maroon;">&quot;--size&quot;</span><span style="color: black;color: black;">&#41;</span>:
    target_size = <span style="color: #008000;color: blue;">int</span><span style="color: black;color: black;">&#40;</span>a<span style="color: black;color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;color: blue;">elif</span> o <span style="color: #ff7700;font-weight:bold;color: blue;">in</span> <span style="color: black;color: black;">&#40;</span><span style="color: #483d8b;color: maroon;">&quot;-a&quot;</span>, <span style="color: #483d8b;color: maroon;">&quot;--abr&quot;</span><span style="color: black;color: black;">&#41;</span>:
    abr = <span style="color: #008000;color: blue;">int</span><span style="color: black;color: black;">&#40;</span>a<span style="color: black;color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">if</span> <span style="color: #008000;color: blue;">len</span><span style="color: black;color: black;">&#40;</span>args<span style="color: black;color: black;">&#41;</span> <span style="color: #66cc66;color: black;">&lt;</span> <span style="color: #ff4500;color: maroon;">1</span>:
  <span style="color: #ff7700;font-weight:bold;color: blue;">print</span> <span style="color: #483d8b;color: maroon;">&quot;Usage: &quot;</span> + argv<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">0</span><span style="color: black;color: black;">&#93;</span> + <span style="color: #483d8b;color: maroon;">&quot; [-s &lt;size (M)&gt;] [-a &lt;audio bit rate (k)&gt;] [[hh:]mm:]ss&quot;</span>
  exit<span style="color: black;color: black;">&#40;</span><span style="color: #ff4500;color: maroon;">2</span><span style="color: black;color: black;">&#41;</span>
&nbsp;
time_part = args<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">0</span><span style="color: black;color: black;">&#93;</span>.<span style="color: black;color: black;">split</span><span style="color: black;color: black;">&#40;</span><span style="color: #483d8b;color: maroon;">&quot;:&quot;</span><span style="color: black;color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;color: blue;">if</span> <span style="color: #008000;color: blue;">len</span><span style="color: black;color: black;">&#40;</span>time_part<span style="color: black;color: black;">&#41;</span> <span style="color: #66cc66;color: black;">&lt;</span> <span style="color: #ff4500;color: maroon;">2</span>: time_part = <span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">0</span><span style="color: black;color: black;">&#93;</span> + time_part
<span style="color: #ff7700;font-weight:bold;color: blue;">if</span> <span style="color: #008000;color: blue;">len</span><span style="color: black;color: black;">&#40;</span>time_part<span style="color: black;color: black;">&#41;</span> <span style="color: #66cc66;color: black;">&lt;</span> <span style="color: #ff4500;color: maroon;">3</span>: time_part = <span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">0</span><span style="color: black;color: black;">&#93;</span> + time_part
<span style="color: #dc143c;color: blue;">time</span> = secs<span style="color: black;color: black;">&#40;</span><span style="color: #008000;color: blue;">int</span><span style="color: black;color: black;">&#40;</span>time_part<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">0</span><span style="color: black;color: black;">&#93;</span><span style="color: black;color: black;">&#41;</span>, <span style="color: #008000;color: blue;">int</span><span style="color: black;color: black;">&#40;</span>time_part<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">1</span><span style="color: black;color: black;">&#93;</span><span style="color: black;color: black;">&#41;</span>, <span style="color: #008000;color: blue;">int</span><span style="color: black;color: black;">&#40;</span>time_part<span style="color: black;color: black;">&#91;</span><span style="color: #ff4500;color: maroon;">2</span><span style="color: black;color: black;">&#93;</span><span style="color: black;color: black;">&#41;</span><span style="color: black;color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: blue;">print</span> <span style="color: #483d8b;color: maroon;">&quot;%d&quot;</span> <span style="color: #66cc66;color: black;">%</span> calc_video_bitrate<span style="color: black;color: black;">&#40;</span>target_size, abr, <span style="color: #dc143c;color: blue;">time</span><span style="color: black;color: black;">&#41;</span></pre></div></div>

<p>A typical usage for this would be <code>./calc_python.py -s 350 -a 128 29:23</code>.</p>
<p>We can then use a combination of these inside a shell script easily. I&#8217;m using bash syntax just to nest the commands into a single line but for compatibility with other shells, backticks (`) can be used and this is what I normally prefer. This script loops through all of the .VOB files in the directory and gives their target video bitrate for a 350MiB output and 128kbps audio.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;color: black;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;color: blue;">for</span> vob <span style="color: #000000; font-weight: bold;color: blue;">in</span> <span style="color: #000000; font-weight: bold;color: black;">*</span>.VOB
<span style="color: #000000; font-weight: bold;color: blue;">do</span>
  <span style="color: #007800;">BR</span>=$<span style="color: #7a0874; font-weight: bold;color: black;">&#40;</span>.<span style="color: #000000; font-weight: bold;color: black;">/</span>calc_bitrate.py <span style="color: #660033;">-s</span> <span style="color: #000000;color: maroon;">350</span> <span style="color: #660033;">-a</span> <span style="color: #000000;color: maroon;">128</span> $<span style="color: #7a0874; font-weight: bold;color: black;">&#40;</span><span style="color: #c20cb9; font-weight: bold;color: blue;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #007800;color: black;">$vob</span> <span style="color: #000000;color: maroon;">2</span><span style="color: #000000; font-weight: bold;color: black;">&gt;&amp;</span><span style="color: #000000;color: maroon;">1</span> <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">grep</span> Duration <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">' '</span> <span style="color: #660033;">-f</span> <span style="color: #000000;color: maroon;">4</span> <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'.'</span> <span style="color: #660033;">-f</span> <span style="color: #000000;color: maroon;">1</span><span style="color: #7a0874; font-weight: bold;color: black;">&#41;</span><span style="color: #7a0874; font-weight: bold;color: black;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;color: blue;">echo</span> <span style="color: #007800;color: black;">$vob</span> <span style="color: #007800;color: black;">$BR</span>
<span style="color: #000000; font-weight: bold;color: blue;">done</span></pre></div></div>

<p>I use this in 2-pass VBR mode with the libx264 video encoder and libfaac audio encoder in an mp4 container just by replacing the &#8220;echo&#8221; line of the above script with the following 2 lines:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;color: black;"><span style="color: #c20cb9; font-weight: bold;color: blue;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #007800;color: black;">$vob</span> <span style="color: #660033;">-an</span> <span style="color: #660033;">-pass</span> <span style="color: #000000;color: maroon;">1</span> <span style="color: #660033;">-vcodec</span> libx264 <span style="color: #660033;">-vpre</span> fastfirstpass <span style="color: #660033;">-b</span> <span style="color: #007800;color: black;">$BR</span> <span style="color: #660033;">-bt</span> <span style="color: #007800;color: black;">$BR</span> <span style="color: #660033;">-deinterlace</span> <span style="color: #660033;">-threads</span> <span style="color: #000000;color: maroon;">0</span> <span style="color: #660033;">-y</span> pass1.mp4
<span style="color: #c20cb9; font-weight: bold;color: blue;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #007800;color: black;">$vob</span> <span style="color: #660033;">-acodec</span> libfaac <span style="color: #660033;">-ab</span> 128k <span style="color: #660033;">-ac</span> <span style="color: #000000;color: maroon;">2</span> <span style="color: #660033;">-pass</span> <span style="color: #000000;color: maroon;">2</span> <span style="color: #660033;">-vcodec</span> libx264 <span style="color: #660033;">-vpre</span> hq <span style="color: #660033;">-b</span> <span style="color: #007800;color: black;">$BR</span> <span style="color: #660033;">-bt</span> <span style="color: #007800;color: black;">$BR</span> <span style="color: #660033;">-deinterlace</span> <span style="color: #660033;">-threads</span> <span style="color: #000000;color: maroon;">0</span> <span style="color: #660033;">-y</span> <span style="color: #000000; font-weight: bold;color: black;">`</span><span style="color: #7a0874; font-weight: bold;color: blue;">echo</span> <span style="color: #007800;color: black;">$vob</span> <span style="color: #000000; font-weight: bold;color: black;">|</span> <span style="color: #c20cb9; font-weight: bold;color: blue;">sed</span> <span style="color: #ff0000;">'s/VOB/mp4/'</span><span style="color: #000000; font-weight: bold;color: black;">`</span></pre></div></div>

<p>I have 2 versions of this script, one with &#8220;-deinterlace&#8221; and one without. PAL video (576i &#8211; used in Europe), such as Dad&#8217;s Army needs deinterlacing. NTSC video (480 &#8211; used in North America) usually does not.</p>
<p>For ripping DVDs to H.264 and maintaining the quality, I wouldn&#8217;t use a bitrate lower than 1000k or an audio bitrate lower than 128k stereo. This means that for getting media onto a CD, you probably want no smaller than 350MiB for 30 to 40 minutes or 700MiB for 1 hour or more, depending on your resolution. Also note that I only intend to play these in computers and fitting them onto CDs is just a convenience &#8211; standalone DVD players will not be able to play H.264 or AAC (Blu-ray and HDDVD players may be able to &#8211; mp4 containers and reading CDs would be more of an issue).</p>
<h3>Update:</h3>
<p>I have successfully tested this in a LG BD370 Blu-ray player.</p>
<p>I have not tried actually burning these onto CDs yet so if 2 won&#8217;t fit on a 700MiB CD, even with overburn (because of overheads that were ignored, as stated earlier) then the simplest solution is to just target a smaller file size with something like &#8220;-s 348&#8243;.</p>
<h2>The result</h2>
<p>Dad&#8217;s Army episodes are not all of the same length. Some are several minutes longer than others. The following shows how no matter the size of the input file, they all produce the same size output file:
<pre>$ ll da_5_*.VOB
-r--r--r-- 1 mythtv mythtv 1364660224 2009-06-04 00:01 da_5_01.VOB
-r--r--r-- 1 mythtv mythtv 1360699392 2009-06-04 00:01 da_5_02.VOB
-r--r--r-- 1 mythtv mythtv  956084224 2009-06-04 00:02 da_5_03.VOB
-r--r--r-- 1 mythtv mythtv 1355888640 2009-06-04 00:02 da_5_04.VOB
-r--r--r-- 1 mythtv mythtv 1114351616 2009-06-03 23:59 da_5_05.VOB
-r--r--r-- 1 mythtv mythtv 1034289152 2009-06-04 00:00 da_5_06.VOB
-r--r--r-- 1 mythtv mythtv 1045202944 2009-06-04 00:00 da_5_07.VOB
-r--r--r-- 1 mythtv mythtv 1345318912 2009-06-04 00:00 da_5_08.VOB
-r--r--r-- 1 mythtv mythtv 1391529984 2009-06-04 00:02 da_5_09.VOB
-r--r--r-- 1 mythtv mythtv 1342748672 2009-06-04 00:03 da_5_10.VOB
-r--r--r-- 1 mythtv mythtv 1158017024 2009-06-04 00:03 da_5_11.VOB
-r--r--r-- 1 mythtv mythtv 1157097472 2009-06-04 00:03 da_5_12.VOB
-r--r--r-- 1 mythtv mythtv 1180098560 2009-06-04 00:04 da_5_13.VOB
$ ll -h da_5_*.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 06:18 da_5_01.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 06:55 da_5_02.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 07:30 da_5_03.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 08:08 da_5_04.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 08:44 da_5_05.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 09:21 da_5_06.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 09:58 da_5_07.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 10:36 da_5_08.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 11:15 da_5_09.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 11:54 da_5_10.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 12:29 da_5_11.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 13:05 da_5_12.mp4
-rw-r--r-- 1 mythtv mythtv 352M 2009-06-17 13:41 da_5_13.mp4</pre>
<h2>Update:</h2>
<p>A pure python replacement script is available <a href="http://www.helyar.net/2009/ffmpeg-target-file-sizes-again/">here</a> that simplifies use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.helyar.net/2009/how-to-set-target-file-sizes-in-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

