onsdag 22 juli 2009

Create DVD from avi on FreeBSD

Create DVD from avi
A simple step thru list for converting an avi file to a playable DVD.

Fmpeg video converter to set aspect ratio, pal dvd television standard etc:

ffmpeg -i in.avi -y -target pal-dvd -sameq -aspect 16:9 out.mpg


Create the dvd:

dvdauthor --title -o dvd -f out.mpg


Creates the table of contents file instead of a titleset:

dvdauthor -o dvd -T


Create iso:

mkisofs -dvd-video -o dvd.iso dvd/


Burn the dvd:

growisofs -dvd-video -Z /dev/cd0=imagefile.iso

DVD burning in FreeBSD

Enable atapicam:
If you bought a cheap IDE DVD recorder you need to enable atapicam before you can burn DVD with FreeBSD, so it can be accessed through the SCSI subsystem. You could either compile a new kernel to support or simply add the following line to your loader.config.
Add:
atapicam_load="YES"

to: /boot/load.config

Compile makeisofs:
cd /usr/ports/sysutils/cdrtools/
make install clean


Compile growisofs:
cd /usr/ports/sysutils/dvd+rw-tools/
make install clean


Burn the DVD:
cd growisofs -dvd-compat -Z /dev/cd0=dvd.iso

måndag 23 mars 2009

UIAutomation

Using FitNesse for integration test can be great, but sometimes you want to test the front end WPF components and not just the presenter.
Referencing the .NET 3.0 UIAutomation assemblies allows you to programatically control you WPF application. The only trouble I had was that the builtin FindFirst() method was really slow and unpredictable so after switching to the TreeWalker everything went fast and smooth.
private static AutomationElement Find(AutomationElement element, string name, int maxDepth)
{
if (maxDepth == 0)
{
return null;
}
TreeWalker walker = TreeWalker.RawViewWalker;
AutomationElement current = walker.GetFirstChild(element);
while (current != null)
{
if ((string)current.GetCurrentPropertyValue(AutomationElement.NameProperty) == name || (string)current.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty) == name)
{
return current;
}
current = walker.GetNextSibling(current);
}
current = walker.GetFirstChild(element);
while (current != null)
{
AutomationElement found = Find(current, name, maxDepth - 1);
if (found != null)
{
return found;
}
current = walker.GetNextSibling(current);
}
return null;
}


Now you can for instance set the value of a textbox by using:

public static void SetTextBoxValue(AutomationElement mainWindow, string id, string value)
{
AutomationElement textBox = FindElement(mainWindow, id);

ValuePattern valuePattern = (ValuePattern)textBox.GetCurrentPattern(ValuePattern.Pattern);
valuePattern.SetValue(value);
}