<?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>Bluehorn's Blog &#187; How-To</title>
	<atom:link href="http://www.landschoff.net/blog/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.landschoff.net/blog</link>
	<description>Ramblings of Torsten Landschoff</description>
	<lastBuildDate>Thu, 08 Jul 2010 10:43:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to run a single unit test/unit test module with py.test</title>
		<link>http://www.landschoff.net/blog/2010/07/how-to-run-a-single-unit-testunit-test-module-with-py-test/</link>
		<comments>http://www.landschoff.net/blog/2010/07/how-to-run-a-single-unit-testunit-test-module-with-py-test/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:43:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[py.test]]></category>

		<guid isPermaLink="false">http://www.landschoff.net/blog/?p=203</guid>
		<description><![CDATA[Note to self: It is actually possible to select a single test module or a single test function in py.test.
But passing the file name as argument to a py.test invocation selects only the doctest from that file (wtf!?). Instead, you need to call it like this:
12$ py.test -k test_module &#160; &#160;# to run the tests [...]]]></description>
			<content:encoded><![CDATA[<p>Note to self: It is actually possible to select a single test module or a single test function in <a href="http://pytest.org/">py.test</a>.</p>
<p>But passing the file name as argument to a py.test invocation selects only the doctest from that file (wtf!?). Instead, you need to call it like this:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ py.test <span style="color: #660033;">-k</span> test_module &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># to run the tests from test_module.py</span><br />
$ py.test <span style="color: #660033;">-k</span> test_func &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># to run tests having the function name test_func</span></div></td></tr></tbody></table></div>
<p>This is documented in the section <a href="http://codespeak.net/py/dist/test/features.html#advanced-test-selection-and-running-modes">advanced test selection and running modes</a> of the py.test documentation, although I fail to see how this is advanced.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.landschoff.net/blog/2010/07/how-to-run-a-single-unit-testunit-test-module-with-py-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postprocessing conference videos</title>
		<link>http://www.landschoff.net/blog/2010/07/postprocessing-conference-videos/</link>
		<comments>http://www.landschoff.net/blog/2010/07/postprocessing-conference-videos/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 22:03:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[mlt]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.landschoff.net/blog/?p=167</guid>
		<description><![CDATA[I was planning to attend DebConf New York this year, but for a number of reasons I decided not to go. Fortunately, Ferdinand Thommes organized a MiniDebConf in Berlin at LinuxTag and I managed to attend. Thanks, Ferdinand!
There were a number of interesting Talks. I especially liked the talk of our DPL, and those about [...]]]></description>
			<content:encoded><![CDATA[<p>I was planning to attend <a href="http://debconf10.debconf.org/">DebConf New York</a> this year, but for a number of reasons I decided not to go. Fortunately, Ferdinand Thommes organized a <a href="http://www.minidebconf.de/2010/berlin/">MiniDebConf</a> in Berlin at <a href="http://www.linuxtag.org/">LinuxTag</a> and I managed to attend. Thanks, Ferdinand!</p>
<p>There were a number of interesting <a href="http://wiki.debconf.org/wiki/Miniconf-LT-Berlin/2010#Schedule">Talks</a>. I especially liked the talk of our DPL, and those about piuparts and git-buildpackage. In contrast to the other LinuxTag talks, we had a livestream of our talks and recorded (most) of them. The kudos for setting this up goes to Alexander Wirt, who spent quite a few hours to get it up and running.</p>
<p>I have to apologize for being late in bringing my Notebook, which was intended to do the theora encoding of the livestream. This was a misunderstanding on my part, I should have known that this is not going to be setup in the night before show time&#8230; So to compensate the extra hours he had to put in for me, I offered to do the post processing of the videos.</p>
<h2>Basic approach for post processing</h2>
<p>The main goal of post processing the videos was (of course) to compress them to a usable size from the original 143 GB. I also wanted to have a title on each video, and show the sponsors at the end of the video.</p>
<p>My basic idea to implement that consisted of the following steps:</p>
<ol>
<li>Create a title animation template.</li>
<li>Generate title animations from template for all talks.</li>
<li>Use a video editor to create a playlist of the parts title &#8211; talk &#8211; epilogue.</li>
<li>Run the video editor in batch mode to generate the combined video.</li>
<li>Encode the resulting video as ogg theora.</li>
</ol>
<p>As always with technology, it turned out that the original plan needed a few modifications.</p>
<h2>Title animations</h2>
<div style="float:right; border:1px dashed; padding:3px;"><video width="360 "height="288" src="http://www.landschoff.net/blog/uploads/2010/07/mdc2010_title_anim1.ogv" controls="controls"></video></div>
<p>Originally I wanted to use <a href="http://www.blender.org/">Blender</a> for the title animation, but I knew it is quite a complicated bit of software. So I looked for something simpler, and stumbled across an <a href="https://www.lwn.net/Articles/377939/">article</a> that pointed me towards <a href="http://www.synfig.org/">Synfig Studio</a> for 2D animation. This is also in Debian, so I gave it a try.</p>
<p>I was delighted that Synfig Studio has a command line renderer which is just called <tt>synfig</tt> and that the file format is XML, which would make it simple to batch-create the title animations. My title template can be found in <a href="http://landschoff.net/git/?p=mdc-video.git;a=summary">this git repository</a>.</p>
<h3>Batch creation of title animations</h3>
<p>I used a combination of <tt>make</tt> and a simple <a href="http://landschoff.net/git/?p=mdc-video.git;a=blob;f=doit.py;h=2601eac32d653056e6f516ce148bb8a7bda70dd5;hb=18026583d915c166b19fd26535cb49019d1158af">python script</a> to replace the author name and the title of the talk into the synfig XML file. The data for all talks is another XML file <tt>talks.xml</tt>. Basically, I used a simple <a href="http://www.w3.org/TR/xpath/">XPath</a> expression to find the relevant text node and change the data using the ElementTree API of <a href="http://codespeak.net/lxml/">lxml python module</a>.</p>
<p>The same could be done using <a href="http://www.w3.org/TR/xslt">XSLT</a> of course (for a constant replacement, see <a href="http://landschoff.net/git/?p=mdc-video.git;a=blob;f=test.xsl;h=ba2a20d545c5076ea1b78707ab5e585ffa219262;hb=18026583d915c166b19fd26535cb49019d1158af">this file</a>) but I found it easier to combine two XML files in python.</p>
<p>Note that I create PNG files with synfig and use <a href="http://www.ffmpeg.org/">ffmpeg</a> to generate a DV file from those. Originally, I had synfig create DV files directly but those turned out quite gray for some reason. I am now unable to reproduce this problem.</p>
<h2>Combining the title animation with the talk</h2>
<p>For joining the title animation with the talk, I originally went with <a href="http://www.openshotvideo.com/">OpenShot</a>, which somebody of the video team had running at the conference. My idea was to mix a single video manually and just replace the underlying data files for each talk. I expected that this would be easy using the <tt>openshot-render</tt> command, which renders the output video from the input clips and the <a href="http://landschoff.net/git/?p=mdc-video.git;a=blob;f=master/master.osp;h=f32c0c2dc5e8ca88c69eff88fd46f70318064beb;hb=18026583d915c166b19fd26535cb49019d1158af">OpenShot project file</a>. However, OpenShot stores the video lengths in the project file and will take those literally, so this did not work for talks of different play times&#8230;</p>
<p>I considered working with <a href="http://www.kinodv.org/">Kino</a> or <a href="http://kdenlive.org/">Kdenlive</a> but they did not look more appropriate for this use case. I noticed that OpenShot and Kdenlive both use the <a href="http://www.mltframework.org/">Media Lovin&#8217; Toolkit</a> under the hood, and OpenShot actually serializes the MLT configuration to <tt>$HOME/.openshot/sequence.xml</tt> when rendering. I first tried to read that XML file from python (using the mlt python bindings from the <tt>python-mlt2</tt> package) but did not find an API function to do that. So I just hard coded the <a href="http://landschoff.net/git/?p=mdc-video.git;a=blob;f=sequence.py;h=030ea9e2b2cfcb279d0baa19d03f09397583d644;hb=18026583d915c166b19fd26535cb49019d1158af">video sequence</a> in python.</p>
<p>I ran into a few gotchas on the way:</p>
<ul>
<li>it&#8217;s easy to segfault MLT from Python (something is wrong with the refcounting)</li>
<li>generating ogg theora using MLT from Python (which uses libavformat) resulted in a bad audio/video synchronisation of the output (more than 1 second for 1 hour of video)</li>
<li>generating dv from MLT and running <a href="http://v2v.cc/~j/ffmpeg2theora/">ffmpeg2theora</a> on the result is disk-bound on my quad core system &#8211; so use a pipe to ffmpeg2theora</li>
</ul>
<h2>Things to improve</h2>
<p>While the results look quite okay for me now, there is a lot of room for improvement.</p>
<ul>
<li>What bothers me the most is the unequal audio volume between talks. We should apply something like <a href="http://replaygain.hydrogenaudio.org/">replay gain</a> for normalization. I did not find an easy way to add this to the processing pipeline, otherwise it would have been included already.</li>
<li>Original recordings have different aspect ratios, so after combining them, there is a letterbox added. This is the case for <a href="http://meetings-archive.debian.net/pub/debian-meetings/2010/minidebconf-berlin/MDC2010_Brederlow_MultiArch.ogv">Goswin&#8217;s talk on Multiarch</a> for example. I&#8217;d rather have the title distorted or letter boxed, if I get around to it, I will fix it in the script.</li>
<li>Most of the recordings concentrate on showing the slides. As we did not keep the raw camera data, but recorded the <a href="http://dvswitch.alioth.debian.org/wiki/">DVswitch</a> output, we missed the opportunity to show the speaker more often in full screen. Looking at the same slide becomes quite boring after half a minute, so it would be better<br />
to show the speaker more often. That would require quite a bit of man power for post processing though, I have to admit that I did not watch all the hours of video.</li>
<li>We could cut a bit off the talk at start and end, when the speaker discusses where he is available for questions. It is not of interest anymore after the conference is over.</li>
</ul>
<h2>Availability</h2>
<ul>
<li>git repo (browsing): <a href="http://www.landschoff.net/git/?p=mdc-video.git;a=summary">http://www.landschoff.net/git/?p=mdc-video.git;a=summary</a></li>
<li>git repo (clone): <a href="git://landschoff.net/mdc-video">git://landschoff.net/mdc-video</a></li>
<li>Videos: <a href="http://meetings-archive.debian.net/pub/debian-meetings/2010/minidebconf-berlin/">http://meetings-archive.debian.net/pub/debian-meetings/2010/minidebconf-berlin/</a> (<strong>note:</strong> most of these are in german, apart from the DPL and the LXDE talk)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.landschoff.net/blog/2010/07/postprocessing-conference-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.landschoff.net/blog/uploads/2010/07/mdc2010_title_anim1.ogv" length="369157" type="video/ogg" />
<enclosure url="http://meetings-archive.debian.net/pub/debian-meetings/2010/minidebconf-berlin/MDC2010_Brederlow_MultiArch.ogv" length="426287215" type="video/ogg" />
		</item>
		<item>
		<title>trac served by lighttpd on Debian lenny</title>
		<link>http://www.landschoff.net/blog/2009/01/trac-hosted-on-debian-unstable-lighty/</link>
		<comments>http://www.landschoff.net/blog/2009/01/trac-hosted-on-debian-unstable-lighty/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 18:08:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.landschoff.net/blog/?p=19</guid>
		<description><![CDATA[Software installation
All required packages are installed by the following command:
apt-get install lighttpd trac subversion apache2-utils
We install lighttpd together with trac, as otherwise the trac package will pull in an installation of apache2, which is a bit more heavyweight than what I wanted.
Setting up the directory tree
Let&#8217;s set up a directory tree for trac:
for p in [...]]]></description>
			<content:encoded><![CDATA[<h2>Software installation</h2>
<p>All required packages are installed by the following command:</p>
<pre>apt-get install lighttpd trac subversion apache2-utils</pre>
<p>We install lighttpd together with trac, as otherwise the trac package will pull in an installation of apache2, which is a bit more heavyweight than what I wanted.</p>
<h2>Setting up the directory tree</h2>
<p>Let&#8217;s set up a directory tree for trac:</p>
<pre>for p in env svn auth; do mkdir -p /srv/trac/$p/demo; done</pre>
<p>One directory for the trac environment data, another for the subversion repository and the third for authentication data. Putting all environments into a single directory (<tt>/srv/trac/env</tt>) would allow to run a single trac server for all environments using the <var>TRAC_ENV_PARENT_DIR</var> configuration variable.</p>
<h2>Creating a trac environment</h2>
<p>The trac environment is created using
<pre>trac-admin /srv/trac/env/demo initenv</pre>
<p>The command will ask interactively for the following settings:</p>
<ul>
<li>Project name: Enter a name as you like (&#8220;Demo&#8221;). Note that you can change this later.</li>
<li>Database connection string: You can accept the default sqlite database.</li>
<li>Repository type: I used the default &#8220;svn&#8221; selection.</li>
<li>Path to repository: <tt>/srv/trac/svn/demo</tt></li>
</ul>
<p>From now on, we can access the (empty) trac instance by running <code>tracd --port 8000 /srv/trac/env/demo</code> and accessing the trac-integrated web server at port 8000 of the server. Hit Ctrl-C to kill the tracd after you don&#8217;t need it any longer.</p>
<h2>Creating an initial user</h2>
<p>By default, trac creates no users. Only anonymous access is allowed, which by default is read-only. Therefore, we have to create a user to add content. Let&#8217;s use digest authentication:</p>
<pre>htdigest -c /srv/trac/auth/demo/users "trac demo realm" admin
trac-admin /srv/trac/env/demo permission add admin TRAC_ADMIN</pre>
<p>You can now start tracd with authentication:</p>
<pre>tracd --port 8000 \
    --auth=demo,/srv/trac/auth/demo/users,"trac demo realm" \
    /srv/trac/env/demo</pre>
<h2>Configure lighttpd</h2>
<p>To use lighttpd to serve the trac environment, we first need to fix the permissions:</p>
<pre>chown -R www-data /srv/trac/env
chmod +x /usr/share/pyshared/trac/web/fcgi_frontend.py</pre>
<p>I think, the second command should not be required and filed <a href="http://bugs.debian.org/510441">Debian bug #510441</a> because of this.</p>
<p>Next, we need a configuration file. It delegates the trac path to a FastCGI handler and contains the location of the authentication data. Copy the <a href="http://landschoff.net/trac/stuff/browser/misc/50-trac-demo.conf?rev=4">configuration file</a> to <tt>/etc/lighttpd/conf-available/</tt> and enable the configuration:</p>
<pre>lighty-enable-mod auth trac-demo
/etc/init.d/lighttpd force-reload</pre>
<p>The trac instance should be available at <tt>http://HOSTNAME/trac</tt>. Have fun!</p>
<h2>Automatic setup</h2>
<p>For my own tests I wrote a <a href="http://landschoff.net/trac/stuff/browser/misc/setup-trac-demo?rev=4">script</a> which does most of this automatically. Use at your own risk!</p>
<p>BTW: All of this was tested against Debian lenny (not released at time of writing).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.landschoff.net/blog/2009/01/trac-hosted-on-debian-unstable-lighty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
