Extract A Single Image From A Video Using FFMPEG

Update: Still using this 8 years later, but in the form of a quick script, which is useful if you are doing it more than once

Dead handy, this:

ffmpeg -ss 0.5 -i inputfile.mp4 -t 1 -s 480x300 -f image2 imagefile.jpg

The various options:

  • -vframes 1: limit to 1 frame extracted
  • -ss 0.5: point of movie to extract from (ie seek to 0.5 seconds; you can also use HH:MM:SS.ZZZZ sexagesimal format)
  • -s 480x300: frame size of image to output (image resized to fit dimensions)
  • -f image2: forces format

I use this to generate preview stills for jwplayer to use. Dead handy!

Edit: Thanks to DieBagger who pointed out it is much faster to place the seek argument before the input file, and Matthias his point about the seek time.

Spanish Adventure Update: Banks Aren’t Useless After All

Well, not completely useless. A follow up to my post from a few months ago.

So, by now I have decided to go to Barcelona. I will be entering medical school next September, so don’t worry, I haven’t given that up! I don’t have any particular job lined up, but I have heard from various people that teaching English is the way to go. Importantly I have a very useful contact out there who has been most helpful in answering my many questions about accommodation, learning Spanish, the city, and a million other things. Don’t worry; they will be suitably rewarded.

Anyway, I figured it would be useful to have a bank account set up out there. I’m not really a pick up and go type person (I’m trying), and I figure that paying a bank to spend my own money (overseas fees FTL) is a form of ridiculousness I don’t want to be involved in. So, I went and asked my bank about their subsidiary over cashing a couple cheques, and the helpful chap actually went and phoned the Spanish team, who very promptly sent me an information pack and application form!

I must confess at this stage I dallied a bit, partly because the form was all Greek to me (well, Greek would have been an improvement, let’s say, oh, Finnish*) and partly because having it filled in would mean I actually have to leave.

So anyway eventually I got my rear in gear and went back to the branch and had some help from the lovely John (I think… might have been Dave. Sorry, whichever you are) who was as helpful as helpful can be.

The next day I went back with a couple questions I missed. Sadly, on this occasion I got someone somewhat less helpful. She said there was uncertainty as they didn’t really get many people in to do the Spanish stuff, only yesterday John/Dave had said the exact opposite. He was in close contact by email with their contact on the Spanish end, he even serendipitously got an email with her phone number which he used to clarify a couple of my questions. Confusing.

Then I had to convince the person dealing with me to certify a copy of my passport. Never mind this is something the same bank said I needed to do to as a prerequisite for opening my new account. Part of the problem was I wanted to take it away with me, as I was intending to send my documents next day delivery due to an impending Royal Mail strike. More on that later. Anyway I finally got out of the bank an hour later after going through the rigmarole of the international monetary transfer. Did you know the FBI can get information on your transfer (and you) pretty much just by asking nicely? Or any other organisation, bound or not bound by Data Protection Laws. What fun. At least the person doing the transfer was quite pleasant, although she did question my being at university for 9 years – purely from a financial point of view, right enough.

Anyway, after all that, the bit that restored / boosted my confidence (apart from JohnDave and his helpfulness) was that I put a handwritten note in with my application saying essentially: “THERE’S A STRIKE ON, PLEASE BE CLEVER AND NOTIFY ME BY SOME MEANS OTHER THAN POST”. The next day, they phoned me and did just that. The system works. In this specific circumstance. For me, anyway. Kinda.

So now all I have to do is sort flights and accommodation. After that, I’ll probably do something even more fun, like self immolation.

How Not To Run a Poll

There is a very good writeup by Paul Lamere of Music Machinery of how Anonymous subverted a major poll by Time. AKA “moot wins, Time Inc. loses“.

A number of things strike me:

  • Despite how obvious it is, Time deny that the poll was manipulated, stating they have safeguards in place, etc, etc. I guess humble “we fucked up” pie is hard to eat
  • For an influential (ie well-funded) publication they sure have no idea how to protect a poll
  • Anonymous are (as ever) a force not to be trifled with. Sure, they probably won’t topple regimes or enact social change any time soon, but if you draw their ire or attention, you’ll have a hell of a storm to weather.
  • reCAPTCHA wasn’t subvertable, even in the hands of these determined people. This is a Good Thing.

There’s not much else besides these scantly-150 words to say. The writeup is most detailed, although it would have been interesting if Paul had elaborated on how they determined Time’s ranking algorithm to eliminate the need for 46 000 votes. Well worth the read though.

Installing Debian on QEMU

Since I decommissioned my home server in favour of an NSLU2 (a NAS), I’ve found myself without a Linux machine to much about with or develop on while on the go (well, whenever I can’t use my laptop). So instead I’ll be using a virtual machine by running QEMU from my USB drive. Since my old server ran Debian, and since I haven’t checked it out in a while other than using it’s offspring Ubuntu.

Note: I would recommend getting this set up running on a folder on your hard drive, then copying it to your USB drive if you intend to do that. It will probably be faster, and it will save you trouble if your disk image isn’t large enough.

To get a QEMU binary for Windows, you can download from here, although this is no longer outdated and uses the 0.9.0 release. Unzip it wherever.

Open up a command prompt. cd to the QEMU directory. Create two disk images by running:

qemu-img create -f qcow2 debian.img 1024M .

qemu-img create -f qcow2 home.img 1024M .

This creates two 1024Mb sized qcow images for you to work with – one for your system and applications, and one for your home directory(ies). Obviously you can change the name and size to suit. My USB drive is 4Gb – if you have something smaller like 2Gb, use 768M for debian.img and 512M for home.img. If you have a 1Gb drive, you could try smaller sizes, but you’d probably have more luck trying something like DSL (Damn Small Linux) or puppylinux. I originally tried this with a cumulative 512M for the root and swap partitions, and it wasn’t large enough.

Grab a Debian CD image. I would recommend one of the netinst images. I’m using the Lenny Beta 2 image (here, or the .torrent), but you can use a stable image, or one of the weekly / daily snapshots. Put the image in the same directory as QEMU.

Create a file debian.bat, with the command:

qemu.exe -net user,vlan=1 -net nic,model=rtl8139,vlan=1 -L . -m 128 -hda debian.img -hdb home.img -cdrom debian-LennyBeta2-i386-netinst.iso -boot d -soundhw all -localtime

You can change the -m option for more or less virtual RAM, you can leave out the model=rtl8139 to use the default ne2k driver (I just like Realteks, even virtual ones ;-)), and obviously change the -cdrom option if you use a different image. You can also use Kqemu, but I’m not going to go into that.

Additionally, you can use the command -M isapc (ISA network card), but for that you will have to remove the model=rtl8139; and before using the installer, press [TAB] and add noacpi nolacpi to the installer startup options, otherwise QEMU will crash.

Debian can then be installed as normal. I didn’t install anything that depends on X as I don’t want a graphical system, thought QEMU should handle it fine if you do. I used the partition manager to create a swap partition of about 128 megs. Mount your second ‘hard drive’ (home.img) under “/home”. if you don’t do this now you can do it later by editing /etc/fstab.

(My second disk image / hard drive is mounted as:

/dev/hdb1 	 /home   	 ext3   	 errors=remount-ro   	 0   	 1

)

Depending on the CPU of your host machine, whether or not you are using Kqemu, and the speed of your internet connection it will take anywhere from 10 minutes to two hours to install.

Once installed you can apt-get install build-essential, or apt-get install nethack, or apt-get install python, or whatever floats your boat. Or, if you’re like me, you can faff about trying to enlarge your partitions because they aren’t big enough.

Visualising The YouTube Pakistan Outage

There is a good post by bluesky74656 detailing how you you can get a pretty cool representation of the BGP routing mess that took out YouTube for anywhere up to 2/3 for the world. I’ve reproduced the post here:

Head over to this site. It visualizes the BGP routes between different AS’s. Click ‘Start BGPlay’. The prefix in which YouTube lives is 208.65.153.0/24. Set the start time for about 24 Feb 2008 10:00, and the end time for about 25 Feb 2008 03:00 (times are UTC). Start the simulation.

You’ll see a bunch of ASNs. Two have red circles around them. You can get their name by clicking on the number. On the left is YouTube, and on the right is Pakistan Telcom. Click play and watch what happens.

For those too lazy to actually watch this: All the routes destined for YouTube head towards Pakistan Telcom instead. Then, midway through, you see PCCW get wise and shut down those routes, and everyone slowly starts finding the actual YouTube. It’s pretty neat to watch.

Soup Crimp

Soup, Soup-a-tasty
Soup, soup-a-spicy

Carrot and coriander; chili chowder!
Crouton, crouton – crunchy friends in a liquid broth

I am gaspachio – oh! – I am a summersoup – mm!

Miso, miso – fighting in the Dojo
Miso, miso – oriental prince in the land of soup!

Plain Crimp:

On YouTube

The Scene (from “Fountain of Youth”):

Also on YouTube

Firefox Beta 3

As a PortableApps Firefox user, I downloaded Beta 3 of Firefox 3. It’s pretty slick looking, and there’s a whole host of new features. I don’t like the lack of ‘go’ or ‘->’ at the end of the address bar which was useful for refreshing a page without re-POSTing, and the new location of thehome button will take some getting used to, but it looks pretty good so far!

Check it out and report back any issues to the developers.