AVCHD and Free software

I recently bought a new camera (Canon Legria HFS10). Really neat little device but, how do you use it with your Free software operating system? Well, the camera records in a new standard set my Sony and Panasonic called AVCHD or Advanced Video Codec High Definition.

What this is is a directory structure, container format and codec specification. AVCHD uses MPEG4 (or H.264 if you will) to encode video and AAC to encode audio both of these codecs are well supported in FFMpeg but the container format (called MTS) is a bit more problematic as some information appears to be missing from it. Luckily it is still possible to copy the data over and do something useful with it!

My camera records in 1080i50 default (that is 50 fields or 25 frames per second) and my computer is just not fast enough to decode that realtime, let alone edit it. This is why I resize the video to 720p and encode it as lossless motion jpeg with uncompressed PCM audio to trade CPU usage for disk bandwidth and space. The command looks something like this:

mencoder -of lavf -demuxer lavf -vf yadif,scale=1280:720,harddup -oac pcm -ofps 25 -ovc lavc -lavcopts vcodec=ljpeg /media/CANON/avchd/bdmv/stream/00000.mts -o 00000.mkv

This command will use libavformat’s demuxer and muxer code instread of mplayer’s own to be able to properly read the mts file and write the mkv file. I use MKV because the AVI container has given me many problems with editing video, seeking also seems to be much faster with MKV containers. This command will also deinterlace the 1080i50 video to end up with a 720p25 video. This is the format in which I edit my videos.

Please note that if you use the NTSC model the camera will record in 60i instead of 50i and the ‘ofps’ parameter should be set to 30 NOT 25.

If you do not need deinterlacing remove the ‘yadif’ from the -vf (video filter) same goes for scale.

And some still frames from some of the videos I’ve shot (and get with the above command line) (click for full resolution image)

Still frame from the HFS10 1

Still fram from the HSF10 2

Still frame of the HSF10 3

Identi.ca Updates for 2009-07-10

  • Helped !bolderbast with his n00b problems ;) #

Identi.ca Updates for 2009-06-23

  • Happy 18th birthday Sonic!!! #

Identi.ca Updates for 2009-05-15

  • Someone’s trying to screw me over on ebay… Bidding on their own auction… #

Identi.ca Updates for 2009-05-14

  • Batman: Returns for Atari Lynx… Awesome game :) #

Identi.ca Updates for 2009-05-13

  • Goddamn registars… #
  • @bryanlas and @chrislas not sure if this was the intention, but now I really want to see the startrek movie. Didn’t want to before :) #
  • WTF… The DVI switch I bought won’t work with my PS3. Only timing info makes it no data… Apparently DVI != DVI :-/ #
  • W00t, my Sega collection of consoles is almost complete! Just waiting for them to arrive now :) #
  • AS GOOD AS JAMES. In your FACE California games. Took me the better part of 10 years, but still :P #

Identi.ca Updates for 2009-05-12

  • RabbitMQ FTW! #
  • And before I forget : Happy NTSC saturn day! #
  • RabbitMQ can work with SSL using stunnel. Don’t forget to set the sslVersion to ‘all’ #
  • If anyone needs ifolder 3.7.2 for ubuntu 9.04 or debian (sid) http://www.tmm.cx/ifolder #
  • Whoohoo My ‘new’ Atari Lynx just arrived. High time for some on-the-go retro gaming :) #
  • Gwibber is pretty neat. #
  • @chrislas: I think you guys are being way to negative about Fringe, I’m actually enjoying it. The characters are interesting :) #
  • @chrislas: It’s not X-files :) . On it’s own it’s quite enjoyable. Love the father/son thing #
  • Amazing it’s been 13 years and I still suck at California games BMX #
  • @reverendted So you ARE on identi.ca! :) #
  • @jonobacon sounds… stressful *Drumroll* #
  • @forteller pretty much, but you’ll get some extra applications through the previously installed xubuntu-desktop package. #
  • @fta What’s with the ia32libs? #
  • @fta ah, I just found it a bit odd, haven’t tried to build it myself yet :) just wondering, thanks for the reply #
  • @haris Never looked at it that way… .isa.co.cc anyone? :) #
  • @heavensrevenge EGLIBC is optimized for embedded systems. Works with -Os and uses less mem. It’s not statically linked into each binary. #

Yay for python-fu!

Ever needed to batch-resize some pictures and convert just didn’t cut it? Imagemagick apparently tries to ‘optimize’ images, so this means that a 32bit bitmap file will always end up in 24bit format later.

Well, as it turns out The Gimp is very scriptable! By creating the following file and calling it ‘resize.py’ you can now make your dream come true! ;

SCALE = 0.5
DIR = "/path/to/images"

from gimpfu import *
import gimp
import os

for root, dirs, files in os.walk(DIR):
  for file in [f for f in files if f.endswith(".bmp")]:
    try:
      fullname = os.path.join(root, file)
      print “processing”, fullname
      img = pdb.gimp_file_load(fullname, fullname)
      pdb.gimp_image_scale(img, img.width*SCALE, img.height*SCALE)
      layer = img.layers[0]
      pdb.gimp_file_save(img, layer, fullname, fullname)
      pdb.gimp_image_delete(img)
      print fullname, “done”
    except:
      print fullname, “Failed!”
pdb.gimp_quit(True)

It’s not the prettiest code ever written, but it does the job. Run it like so:

gimp-console -i -n –batch-interpreter=’python-fu-eval’ -b - < resize.py

I hope this will be useful to someone else some time

New PC!

After being more than mildly frustrated with my employer’s ‘Test Lab’ I decided I wanted my own test lab… In one box, and under 2000 euros. Here’s the result:

The finished system!

The specs of the machine are as follows:

  • ASUS KFN32-D SLI Motherboard
  • 2x AMD Opteron(tm) Processor 2352
  • 8×2 GB ECC memory
  • 2x 750GB Harddrives
  • Asus EAH4870 DK 1G

The build was relatively easy, once I got the part-list together properly which was less of an easy task. None of that hardware turned out to be very ‘readily available’ sadly, but in the end it all turned out quite nicely. The 8 core machine gives a lot of oomph when I need it (especially when testing out customer setups at home with KVM virtual machines) and 16Gb of memory is extremely nice to have.

Some placement issues with the motherboard did make me curse the entire bloodline of the designer at Asus though. Marvels such as this :

Someone\'s going to pay for this

or This… What’s that Molex connector even DOING there?

What\'s that molex connector even DOING there?

And this GREAT place to put an onboard audio connect

That wasn\'t frustrating at all!

somewhat detracted from an otherwise wonderful project. For the full build-process pictures see this gallery

Don’t try this at home!

I’ve just hired another server for TMM enterprises inc ;) (if you are in need of cheap open source game server hosting, apply below!) ok, shameless plug, forgive me.

Anyway, this new server is equipped with CentOS and no way of changing it to a .deb based distro on purchase, which is highly inconvenient for me, since ALL my other systems are .deb based. Who can live without apt-get, seriously?

There was this tool called ‘debtakeover’ but this hasn’t been maintained since 2004, so I decided to do a little experimentation. The result can be read on my wiki at the following address: http://wiki.tmm.cx/index.php/Installing_Debian_on_a_system_from_another_distro

I hope this will be useful for anyone else, but don’t forget: TRY THIS IN A VM FIRST!