Transcoding MTS/M2TS AVCHD Video Into AVI Files with Free Software

dscn1233.JPGThis holiday season, I was an extremely lucky recipient of a Sony HDR-SR5 video camera with a whopping 40GB hard drive inside.

When I opened it, the first question in my head was not atypical of a Linux users’ train of thought:

“Is it compatible with Linux?”

The answer was a tiny bit more complicated than I imagined, and immersed me into the otherwise unknown world of video transcoding, which is something millions of people do every day but probably never think about it. The best example is on YouTube, where it happens behind the scenes in the Google computing cloud, and everything “just works.”

I’ve read a few things about the format the camera uses, called AVCHD. Even in Windows (or OSX for that matter) many people have headaches with the AVCHD format, so I figure that Linux users are probably going to be having a helluva time trying to get it to work.

The files the camera generates are compressed at an incredible 15:1 ratio. I’ve seen it mentioned that a Standard Definition compressed clip of is actually larger in file size than an HD clip in AVCHD format.

The compression is where a majority of the AVCHD format complaints come originate from, since there is not much out there in terms of being able to edit video stored in the format without uncompressing it first. It takes some rather respectable computing horsepower to actually convert the files into an uncompressed format that can be played with in a video editing software package. Using the method detailed here, it takes about 5-6 minutes to uncompress and transcode a minute of video, on an Intel Core2Duo running at 3.2GHz with 4GB of RAM and a 10,000RPM hard drive – OUCH!

When plugging in the Sony HDR-SR5, it functions as a USB Mass Storage Device. Copying files from the camera to the computer is a simple drag n’ drop affair. This would be a familiar process to anyone who has used a digital camera and imports pictures to their computer.

It would certainly be faster to playback the videos in real-time and capture them using the component outputs from the camera… but that wouldn’t be a challenge. I’ve never actually installed the software that came with the Sony Handycam, so I’m not sure what I’m missing out on, but it doesn’t seem like all that much, to be honest. I wouldn’t be surprised if it was the typical Sony software suite that is about as useless as the media it is distributed on.

Let’s get down to the meaty bits, shall we?

The first thing I searched for was “AVCHD Linux” and found a post over at AVS Forum. On a side note, my Google-Fu is really spot on lately.

That post is a gold mine. It literally contains everything we need to transcode the video into formats of our choosing that are usable in non-linear video editing programs such as Avidemux or Cinelerra.

m2tstoavi is the best information I have found (so far!) to uncompress the AVCHD video files on my camcorder and convert them into a .AVI file in Linux.

Installation is very simple, all it requires in Ubuntu is a quick apt-get install:

sudo apt-get install mplayer ffmpeg x264 faad2 faac a52dec mencoder faad libfaad2-0 libfaad2-dev subversion csh

Then edit the install script as noted in the README to grab the newest version of ldecod. Everything else is completely automated – nice job Axel!

I did need to modify the settings a tiny bit to actually get audio synchronized as well as fix a possible issue with the script itself. I had problems until I commented out the echo ffmpeg yadda yadda part. When modified, it runs the following commands:

xporthdmv -hn $file 1 1 1 && mv bits0001.mpa $audiofile
ldecod -i bits0001.mpv -o $videofifo &
ffmpeg -r 29.97 -s 1440x1080 -i $videofifo -i $audiofile -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k

I’m using the m2tstoavi.fifo script that uses named pipes (denoted above with dollar signs) to stream the output of one command into another. It is efficient with disk space and does not fill up the drive as the regular m2tstoavi script does, not sure why the fifo version is not the default. Ah well, nothing is perfect.

Once installed, I just run this command to convert every MTS video in the current directory to .AVI files:

./m2tstoavi.fifo *

It turns this proprietary format mess:


Into precious memories:


All in all, I’m glad I don’t need proprietary software for this conversion. I really wish it were faster – but here’s the point of this exercise:

I never used Windows software, so I don’t know what I’m missing. I’m happy with the solution I have, and if 20 people comment on this post and say they can edit HD video in realtime, good for them.

If they do, then I would have a better reason to upgrade to a quad-core CPU.

Here’s a (VERY unpolished!) video talking about the process in a little bit more detail, and showing the actual encoding process and the finished result. I’m not responsible for anybody tripping out at the end on my extremely crazily bad camera skills in the rendered video.

Oh yeah, and for those of you who were wondering, I also received quite possibly one of the best books I’ve read in a long time… it’s all about how cool Eric S. Raymond is ninjas are.


Games Linux Video

How To: Run World Of Warcraft (WoW) in Linux Using Wine


World Of Warcraft is one of the most successful games in history, with 9.3 million subscribers and counting. Believe it or not, the beta test of World of Warcraft actually had a Linux client. It’s true! When the game shipped, support for Linux was dropped and the game never shipped with a Linux client.

What a shame! The good news is, there’s been some positive collaboration between members of the Linux developer community who work on and contribute code to projects like Wine, Cedega and CrossOver. Because of this, installation and configuration of World of Warcraft is a snap for those of you who are interested in getting rid of your Windows partitions lying around if WoW is your game of choice.

We have 8 steps to complete to play the game:
1. Configure 3D drivers with Envy.
2. Install WINE and fonts.
3. Configure WINE.
4. Download (or install from media) the actual game.
5. Edit
6. Create a Registry key
7. Install a Linux specific AddOn
8. Launch the game!

1. First, we need to check to see if we have correct and working video card drivers that will work with the game. Open a terminal and type in this command:
glxinfo | grep rendering

It should return with something like this:
direct rendering: Yes

If it says “no” then we have to install the right drivers.

If you have an ATI or nVidia card, the quickest way is to use Envy. Head on over to the website and snatch a copy of the script. Scroll about halfway down and you’ll see the link that ends in .deb – that’s what you want if you’re running Ubuntu or Debian.

Open up the Envy .deb file once it’s done downloading, and we should be prompted with an installer program, just hit the install button and follow the prompts. After it’s installed, we will need to start up the script by going into the Application Menu, then System Tools, then select Envy.


Select “Install the NVIDIA driver” (or ATI driver) and press Apply. This process takes about 5 minutes to complete, so go make a sandwich and reboot your computer when it prompts you to do so.

Don’t worry if it seems like it’s not making progress – just be patient. After rebooting, run the glxinfo | grep rendering command again, and this time it should respond “yes” this time.

2. Then, we are going to install two items before we can actually start installing the game.
a. WINE allows us to run Microsoft Windows executable files
b. To make things look pretty, we need to download two different font packs.

In Ubuntu 7.10, the following command will install all three items in short order. You can open a run dialog box by pressing Alt+F2 simultanously (or open a terminal), then paste in the following:

sudo apt-get install wine msttcorefonts ttf-xfree86-nonfree

Type in the password for your user account, and follow the prompts. After that command completes, we’re just about done preparing the system and can install the game *almost* as easily as in Windows.

3. Configuring Wine
By running the winecfg command, we can choose which sound driver to use (OSS or ALSA), and also switch compatibility modes – just like XP and Vista have done for quite some time, WINE allows us to switch between different operating systems to allow for better compatibility with various programs.

Some users have reported that switching WINE to use NT 4.0 compatibility, issues with patches or installations have been resolved. If you run into problems, you may want to try here first. I left it on Windows XP mode the entire time and had no problems, but your mileage may vary.

4. We need to download and/or install the game from media.

I personally have an old account that has been sitting dormant for approximately a year, and I’ve thrown away my installation media. The easiest way to install WoW and TBC is using the original CDs, but if you don’t have them, or have a pretty fat internet pipe, Blizzard helpfully provides online downloads via BitTorrent, so that’s the method I’ll document here today.

Since I’m showing how to install via download, here’s the two links you need. The first one is to download the original WoW game installation files, and the second link requires you to login to verify that you actually have The Burning Crusade expansion enabled on your account before you can get the BT download program for TBC from Blizzard.

Both of these files utilize BitTorrent technology to allow users to download the entire game, except for the latest patch. These files are updated pretty often, so you usually don’t need to install more than one patch after you’ve got the game installed.

To run them, just open them up just like you would on a Windows computer. They should automatically open up in WINE, and after you select a download destination, you’ll have a pretty familiar window staring you right in the mullet.



NOTE: Your internet bandwidth is going to be sucked up completely by the download client. If you need to browse the web or anything in the meantime while you download over 4GB of data, select the View menu in the download program and select preferences, then uncheck download from peers.

When these are done downloading and installing, we can go and get a few tweaks setup so that everything will run smoothly once the game is downloaded.

5. We need to setup the file inside your WoW folder, by default it is located in the ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/ directory. If it doesn’t exist, login to the game once, and just exit right out. The game will create a default one for you.

We need to append a few items to this file to use the OpenGL rendering engine (instead of DirectX or Software rendering) and make sure we have everything setup to run properly under WINE.

You can run this command to edit the file:
gedit ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/wtf/

Then paste these lines at the end:

SET gxApi "opengl"
SET ffxDeath "0"
SET ffxGlow "0"
SET SoundOutputSystem "1"
SET SoundBufferSize "150"

6. Next, we create a registry key and value.
The following instructions to modify the registry are taken directly from the Ubuntu wiki page and is licensed under CC-BY-SA.

a. Find this key HKEY_CURRENT_USER\Software\Wine\
b. Highlight the wine folder in the left hand pane by clicking left on it. The icon should change to an open folder
c. Right-click on the wine folder and select [NEW] then [KEY]
d. Replace the text New Key #1 with OpenGL
e. Right-click in the right hand pane and select [NEW] then [String Value]
f. Replace New Value #1 with DisabledExtensions (Notice it's case sensitive!)
g. Then double click anywhere on the line, a dialog box will open.
h. In the value field type GL_ARB_vertex_buffer_object

It should look like this:

7. Now we can install a Linux-specific AddOn for the game so that the graphics options are able to be modified in-game without crashing. Download this file and unzip it.

Copy the entire extracted ApplyToForehead-4 folder into the following location:
~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Interface/AddOns/

If the Interface or AddOns folder do not exist, go ahead and create them.

8. We can launch the game from the desktop shortcut, or create one pointing to the wow.exe file within the WoW folder.

You should end up with the launch executing flawlessly:

Now just hit the Play button and enjoy the most addicting game since slot machines. On the character selection screen, make sure to enable out of date AddOns so that ApplyToForehead is loaded properly.

That’s it! If you have problems with running the game, please leave a comment and I’ll attempt to answer it, or look for support channels via the following wikis:

Anything else:

And for your enjoyment, here’s a video. 🙂


Hauppauge WinTV-HVR-950 – Does It Work In Linux?

Black Friday was good to me. I visited about a dozen different stores and ended up getting better deals than I had originally expected. I tend to be one of those so-called “bad customers” who leverage price matching guarantees to their fullest potential. I ended up scoring a HDTV for under a grand less than I would have paid for it the day prior, and since they had to order it, no HDTV love for two weeks.

Enter the Hauppauge WinTV-HVR-950 USB HDTV Tuner to the rescue.


iPhone Auto-Correct Capitalizes ‘Linux’ not ‘microsoft’

Coincidence? I think not. 🙂

linux-iphone.JPG microsoft-iphone.JPG


20 Awesome Devices That Run Linux (But Weren’t Designed To)

LINUXA common attitude among people who believe in free software is to stick it to “the man.”  For some people, that translates into spending a ton of free time porting Linux to devices that were never designed for it. 

This is one of the things that always amazes me when I read about the latest high-tech devices that been modified to run Linux.  Some of these implementations may be incomplete, and I’m not sure why someone would take a brand new device and risk bricking it…

Ok, I lied – I nearly bricked my iPhone last night in the process of updating to the latest firmware version… about a month after a working hack was available.  Something about being the first person to try out the latest hack on a $400 dollar device just doesn’t seem appealing to me.

Here’s a short list of devices that make unlikely with Linux.  Enjoy!

  1. AppleTV:
  2. Browser:
  3. Gmail:
  4. GameCube:
  5. Dreamcast:
  6. HTC Smartphones:
  7. iPod:
  8. Mainframes:
  9. Palm PDAs:
  10. PS2:
  11. Edit:  MSN TV2
  12. PSP:,1697,1906893,00.asp
  13. Edit: JuiceBox:
  14. Edit:  Mac Classic:
  15. Wii:
  16. Windows:
  17. Wireless Routers: 
  18. Xbox: 
  19. Xbox360:

Last but not least, a toaster:

I showed you mine, now you get to show me yours!  What would you like to see running Linux?

Edit… PS3, VirtualPC and USB drives were removed.

Here’s another for you all… Your Mom Can Run Linux:


Turn One Linux Computer Into 10 Workstations Easily With Desktop Multiplier

Library internet kiosks, school computer labs, or even developing countries would absolutely love a program called Desktop Multiplier.

What the hell is Desktop Multiplier? This proprietary software takes a single computer and turns it into multiple desktops, just add keyboards, mice, and monitors for each additional virtual workstation.  What does the software developer say about it?

“Desktop Multiplier is a set of standard Linux software packages that extend the X Window System to support up to 10 fully independent and concurrent workstations using a single computer box. This is accomplished by adding standard video cards, USB keyboards and mice to a single PC system and adding Userful software. Desktop Multiplier is compatible with all single and dual­headed video cards supported by X.Org/XFree86 […]”

Desktop Multiplier makes it easy to do things like adding keyboards, mice, etc – it all happens pretty easily, instead of being semi-difficult to configure 10 workstations’ inputs and outputs, it makes it easy… just press F1, F2, F3, etc while running the configuration program to assign a keyboard to a monitor.  If the mouse is connected via a keyboard USB hub, it automatically associates the mouse with that keyboard.  It’s pretty smart and makes setup a breeze.

Note:  The same effect is possible to setup by manually editing various configuration files, but this program makes it easy enough for someone with moderate intelligence and an installation manual.

I was able to succesfully install Userful onto Ubuntu Gutsy Gibbon 7.10 and requested a free two-workstation license and received it via email. I hooked up another set of USB inputs (which happened to be using Bluetooth, and setup my nVidia card with dual outputs to two different monitors.  Everything worked like a charm.

Here’s some screenshot of the main screen in action:


Saving on electricity costs when two or more people are sharing the same computer at the same time is a great way to put money in the bank.  Adding additional workstations is as inexpensive as a a new keyboard, mouse, video card and monitor – far less than the cost of an additional computer.

Let’s take a hypothetical situation of needing 10 kiosks in close physical proximity.  We’ll need 5 video cards with dual outputs, 10 keyboards, 10 mice, and 10 monitors.  We’ll go with an AMD 939 pin CPU and motherboard combination, and since a dual-core processor is only $10 more, it’s a safe bet to splurge a little bit.


Seems like a great way to procure multiple workstations (that just so happen to be pretty powerful) for a damn cheap price per seat.In all, including ten 17″ LCD monitors, the cost is less than $200 per seat.

Eat that, OLPC!

Linux Microsoft

How To: Run Microsoft Outlook “Natively” On Linux Using VirtualBox

There are hundreds of reasons why someone would want to run Microsoft Outlook in Linux, and this guide will show you how from beginning to end.

When I use the term “natively,” I mean fully integrated into the desktop enviroment, NOT an actual native binary Outlook client. Outlook itself runs in a Virtual Machine, but it acts like a pseudo-native application.


Unlike most emulators, VirtualBox allows you move freely between applications, without the constraints of a border around the VM which degrades the user experience. Here’s a picture for a good idea of what I’m talking about.

In the screenshot, there is Outlook 2007, Internet Explorer 7 (browsing Digg of course), and Windows Media Player 11 playing an internet stream, and the start menu sits at the bottom of the screen, while I have the Gnome Desktop menu up at the top.

I personally need Outlook for corporate email, and VirtualBox lets me utilize all of the other tools like IE (and toys, like iTunes) that can’t be experienced without emulation in Linux.

Using VirtualBox, I can seamlessly copy and paste a URL from Firefox in Linux to IE7 to test compatibility with IE. It’s pretty damn slick, and until we see a version of Linux coming straight from Redmond, it’s about as “native” as these proprietary applications will ever be.

Impressed? I certainly was, and to be honest, I’m very jaded when it comes to new technology. Let’s get down to it, shall we? These instructions are written with Ubuntu or Debian in mind, but may vary if using a distro that doesn’t utilize apt-get.

1. Download the VirtualBox binary for your distribution from their website and install it. Usually all you need to do is double click on it after downloading.

Note: Some distributions have VirtualBox within their repositories, but these can sometimes be out of date, and we want to be absolutely certain that we get version 1.5.2 or higher so that we can utilize ‘Seamless Mode’ which makes it so applications we run in the virtual machine show up just like normal windows in Gnome or KDE, instead of bound within a virtual machine window.

2. Add yourself to the vboxusers group.

As always, there are methods to accomplish these by using a GUI, but ultimately it’ll be faster and easier to work in the terminal. We’ll add ourselves to the vboxusers group to use the program, and we must logout and back in again for the group addition to take effect. Change wayne to your own username.

sudo adduser wayne vboxusers

3. Then we download utilities to setup a network bridge from the Linux system to the virtual machine.

sudo apt-get install bridge-utils

4. Now we have to edit the interfaces file to add the bridge interface.
sudo gedit /etc/network/interfaces/
I appended the last three lines (in bold) to this file to make it look like this:

auto lo
iface lo inet loopback
auto br0
iface br0 inet dhcp
bridge_ports eth0

5. Restart networking services to recognize the bridge we just added.

sudo /etc/init.d/networking restart

5a. These commands may be helpful needed if you get errors with the above steps.

sudo rmmod vboxdrv
sudo modprobe -k vboxdrv
sudo chmod 666 /dev/vboxdrv

6. Now we need to create a permanent host interface, so that if we reboot, networking will still be available to the virtual machine. Obviously change “wayne” to your own username:

sudo VBoxAddIF vbox0 wayne br0

7. I tried this twice, and both times at this point my internet connection was hosed. A quick reboot fixed the problem, and I’m not quite sure where to start as far as trying to find the culprit, so we’ll reboot here. If you can find a workaround for rebooting, please leave a comment and I’ll give credit where it’s due.

Barry comments:

The reboot thing seems to be related to setting group membership. I got away with logging out and back in.

8. Open up the VirtualBox program (Found in Applications | System Tools in Gnome), accept the EULA, and register to receive newletters. Click New, and follow the wizard.




Once finished with the wizard, you should have a screen that looks like this:


9. Configuring the Virtual Machine.

Click the settings button in the menu and we’ll go through and change a few settings to gain better performance and get everything set just right. general-advanced.pngIf you have a newer processor that supports virtualization, you will see a performance boost by enabling it in both the BIOS and in the Advanced tab, put a check next to “Enable VT-x/AMD-v”.

virtualbox-cddvdrom.pngTo get install Windows on the virtual machine, we will either need to insert the bootable disc into the CD/DVD-ROM drive, or make an ISO image of the media and point the VM at the image. This setting is found under CD/DVD-ROM on the left. Put a checkmark next to “Mount CD/DVD Drive” and configure this page according to what you need. I found that using an ISO image was easier to use.

If you want to hear the audio notification when email arrives or are using this guide for another purpose (like iTunes) click Audio on the left and put a checkmark in “Enable Audio,” then hit the dropdown and select OSS or ALSA.

The virtual machine isn’t hooked up to the network yet, and to accomplish that, we will use something called “Host Interface” which we setup earlier.

virtualbox-network.pngClick Network on the left, then make sure “Enable Network Adapter” is checked, then where it says “Attached to” select “Host Interface” from the dropdown menu. Type in vbox0 into the Interface Name box.

Press OK and we’re done configuring VirtualBox, and can startup our newly created system and start installing Windows.

Important Note: By default the keyboard and mouse get trapped when you click inside a running VM. Use the right CTRL key (other right) to escape from it. After the next step, this wont be needed.

install-guest-additions.png10. Once finished installing Windows, we’ll need to install drivers for the emulated graphics and networking cards in Windows. Click Devices, Install Guest Additions.

You’ll get a popup in the VM just as if you had put in a new CD. Run the setup and reboot when prompted, that takes care of the graphics drivers and tools to allow us to take advantage of Seamless Mode.

For Vista, there was an additional step needed – updating the device drivers for the emulated AMD PCNET ethernet device. I went into the Device Manager in Windows, right clicked on the Ethernet Controller, chose Update Driver Software and followed the prompts, when asks, I chose to install from a specific location and chose the D:\ drive, and everything worked like a charm.


11. Now that everything with our VM is up and running, prepare to be absolutely amazed at how well VirtualBox integrates the experience of running Windows applications in Linux.

To enable Seamless Mode, press CTRL+L. You’ll end up with something like this:

Now we’re all done. Install Outlook, iTunes, and all your other proprietary applications that do not run well under WINE. That’s not all folks. Did you think all I was going to say was super awesome enthusiastic positive remarks?

Nah. There are problems. Not the type of problems that make innotek’s VirtualBox unusable… No.. there are just some small issues that are minor annoyances.

First, the audio coming from the VM sometimes will take control of all audio coming from the sound server. I know this is how audio works in Linux, and there are workarounds. But do I really want to spend a couple of hours installing Pulseaudio or Jack to gain multiple streams of audio playing at once? Not really. Itwould be nice if VirtualBox would release the sound server when it is done playing something.

Secondly, sometimes there are some pretty massive and frankly, quite ugly video transitions that take place when the VM is using lots of CPU and you try to manipulate windows. Did you think the jarring blackout effect of Windows User Account Control in Vista was bad? This is worse. Far worse. The best fix for this I can find is using the same wallpaper for both machines. Fortunately this quick fix seems to minimize the effect. Also, disabling Compiz Fusion or Beryl will help cut down on the frequency and duration of these episodes, although they still exist. It’s hard to describe, but imagine Windows UAC and multiply it by 10.

Other than those two issues, there is only one more issue to discuss: video performance, or rather, lack thereof. Playing a video on YouTube or any other flash video site and trying to do anything else at the same time results in audio skipping. I realize the video and audio go through multiple layers of two different operating systems and emulation, but you would think it could be fixed. I’m sure it will be fixed eventually, but until that time comes it’s annoying.

These three problems (other documented problems exist, but I have yet to run into them) are probably why VirtualBox doesn’t cost an arm and a leg.

If you are still running a dual-booting system, I highly recommend you give VirtualBox a try – who knows… maybe you’ll be able to give up Windows. In the end, innotek’s VirtualBox is an innovative product that provides people who need proprietary applications to get work done the ability to run them without requiring a dual-boot setup.

If you’re a new visitor, feel free to subscribe to the RSS feed to keep up to date with the latest posts and comments on


Digg “Linux Nation” for Thursday October 25th 2007

Another Thursday, another Linux Nation. Roy Schestowitz from Digg suggested that my weekly round up is not really about Linux, that it’s almost all about Ubuntu. I can agree with that, with an explanation:

I don’t make the news, just talk about it.

What I can do to fix this? Talk about it differently to not alienate readers who don’t care to hear so much about Ubuntu – we already get enough on Digg, why compound the problem?

It may be time for a change in format. For this edition, as a trial, I’ll do a non-Ubuntu version. I’ll just write about the top 10 stories instead of 15, since there are only 11 stories this week that don’t mention Ubuntu in the title or description. Like it? Hate it? Got a comment? Use the comment form down below, or hit my picture on the right to contact me via email.

Top 10 Linux Stories of the Week:


Installing Second Life Takes Seconds In Linux

What a refreshing concept. Installing a software package from a third-party developer who doesn’t have anything sitting in a repository or pre-made installable package makes it stupid easy to install.


Intel PowerTOP – Not Just For Laptops

When I originally read about PowerTOP from Intel, I figured it was designed completely for laptops. I decided to install it on my desktop with a Core2Duo and see what happens… strangely enough, it worked!

Although there is less data available when using a desktop CPU, it is certainly VERY useful in determining what is using the most power.