Technology

HandBrake your DVDs for iPad

No Comments »Written on December 31st, 2010 by
Categories: Python, Technology, Travel
HandBrake your DVDs for iPad

Who loves HandBrake? Can I get a “woohoo”?

For anyone who doesn’t know, HandBrake is a freebie app for Windows, Mac and Linux which rips DVDs to iGadget-compatible files with striking ease.

I’ve been jetting about a fair bit recently, and with the big Eurotrip on the horizon, it’s been all about gearing up for long plane trips. That means my beloved trusty iPad and a few choice movies.

I hate pirating movies. I have around 2,000 legit DVDs and BluRays, so downloading them again using torrents seems both tiresome and pointless. Enter HandBrake – just simmer for 30 mins on my beasty Mac Pro and serve warm to iPad.

At least that’s the theory. Even though the HandBrake Apple Universal profile uses AVC level 3.1, it marks its output files as 4.1, which iPad seems to arbitrarily reject for roughly 1 in 3 files.

Not to worry – it’s literally a case of changing one bit in the m4v file (that’s right – changing a 0 to a 1) and HandBrake output magically becomes iPad compatible. If you’re a glutton for punishment, you can use a hex editor and hunt around, or you can use this nifty Python script I cobbled together one bright Sunday morning.

#!/usr/bin/python

import sys
import os

if len(sys.argv) < 2:
	sys.exit("Target file not specified")

f = open(sys.argv[1],"r+b")
f.seek(0,os.SEEK_END)

marker = "avcC"+chr(1)
mlen = len(marker)

sys.stdout.write("Searching");

found = 0
while found==0:
	if(f.tell()%50000==0):
		sys.stdout.write(".")
		sys.stdout.flush()
	f.seek(-mlen-1,os.SEEK_CUR)
	s=f.read(mlen)
	if s==marker:
		found=1
	elif f.tell()==mlen:
		f.close()
		sys.exit("\nCould not find file marker")

f.seek(2,os.SEEK_CUR)
f.write(chr(0x1F))
print "\nFile successfully patched"

f.close()

If you’re not familiar with Python, don’t worry; just copy the code above into a new text file, call it ipadfix.py or similar, and run it from a command line with your file-to-be-fixed as the only parameter. If you’re on Windows, you’ll need to download and install Python. If not, make sure you enable execute permission on the script (chmod +x ipadfix.py), or it won’t run.

This solution is based on research I found posted in the Apple Support Forum.

I’ve only tested this solution on Mac – I have no idea if it works on other platforms, or if it’s even needed. It’s also the first Python script I ever wrote, so yes, it could be a little more efficient. OK, a lot more efficient! Hey, it gets the job done :)

A bit of ADSL common sense

No Comments »Written on December 30th, 2010 by
Categories: Technology
A bit of ADSL common sense

I remember when 14400 baud modems came out. They said they’d pushed the technology right to the limits of the poor, pitiful copper wires that supported the connections. Then they found a way to double it to 28k, and eventually settled on an absolute never-to-be-beaten maximum of 56.6k.

15 years later, those same half-century-old copper wires are supporting 50x more PLUS full phone/fax capability and you have to wonder, if the leading edge is the bleeding edge, how can pushing so much through so little be so easy?

The short answer is, it’s not. Your little $120 all-in-one modem/router/wireless access point has an enormous job to do, not the least of which is modulating and demodulating the ADSL signal as usable PPP encapsulated binary.

Hard work for electronics means heat. Heat in cheap, poorly made electronic components means dry solder joints and reduced IC reliability, amongst other things. No wonder we go through a router every couple of years.

What’s the solution?

Well, avoid cheap hardware, for one thing. But since this ridiculous consumer-driven economy forces even traditionally reliable vendors like Linksys to manufacture plastic garbage, we can reduce the load on our hardware so it can run a little bit cooler, and focus on just a few tasks at once, rather than trying to do everything.

Having been through a tiresome array of Belkin, D-Link and Linksys modem/routers, with each one gradually dying a slow death from having to work too hard, I decided to take a fresh approach. I got myself a DrayTek Vigor 120, which is a simple $50 ADSL2+ modem, and connected it to an Apple Time Capsule, which also functions as a network router and wireless access point.

Just the ticket: the charmingly simple DrayTek Vigor 120

The Vigor 120, like not many ADSL2+ modems, supports PPPoE bridging, which means the ONLY thing the modem has to do is modulate and demodulate the ADSL signal – the Time Capsule takes care of the PPPoE negotiation. And because it’s an Apple product, it’s clever enough to simply renegotiate the connection in the event of a dropout, rather than rebooting or hanging the way most other routers do. And let’s face it – no one’s ADSL connection is perfect, so good dropout handing is important.

The other neat thing about using the Time Capsule to handle PPP is if you’re on a Mac, you get a discreet notification in your notification area whenever there’s a dropout, so you don’t start worrying whenever your browser freezes up.

A lot of ADSL users have separate modems and routers, but for some reason, most modems have built in router functionality as well, which means those poor sods end up with a double NAT, rather than an effective modem configuration. Many of the same modems support bridge mode but don’t enable it by default, so if you’re in the same situation, you may do well to spend some time poking about your modem’s config interface.