silent ssh-keygen

categories: oneliner

I sometimes have to tell friends to connect to me via ssh to get some files or similar things but they mostly did not yet generate a private/public keypair for themselves.

So for me to remember the command to generate that in the standard place without requiring any user input that would just confuse them here is the command:

ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
View Comments

download from loombo

categories: oneliner

I currently use http://watchseries.eu to check out some series I later might watch in full in better quality. It provides links to several offerings from video streaming web services of a whole lot of series. One of them is megaupload and a howto download from there will follow but this article is about a quick one-liner to download from "loombo.com" which has the advantage that in contrast to megavideo there is no daily limit imposed. The sleep 6 is important as the webserver seems to use that delay to make sure a human is clicking a button after that timeout and not a machine as doing it. The id variable comes from the url of the loombo video you want.

id=0ioy51cxit1b; wget `curl --silent --data "op=download2&id=$id&rand=\`curl \
--silent http://loombo.com/$id | sed -ne 's/<input type=\"hidden\" \
name=\"rand\" value=\"\(\w\+\)\">/\1/p'; sleep 6\`" http://loombo.com/$id | \
sed -ne "s/s1.addVariable('file','\(\S\+\)');/\1/p"`
View Comments

download apple trailer

categories: code

It is easy to find out why one can not just download the movie trailers at apple.com and how to fix it but I automated it even further using this small script which gives me the direct commands for downloading the 1080p content, which is the reason I use apple trailer in the first place instead of youtube. I also recently discovered that some trailer pages already have the h prepended to the download urls so this is also taken care of by the following small script:

import urllib2, re, sys

if len(sys.argv) != 2:
print "supply apple trailer url"
exit()

f = urllib2.urlopen(sys.argv[1]+'/includes/playlists/web.inc')
urls = re.findall('http://trailers.apple.com/movies/[^"\']+1080p.mov', f.read())

for url in urls:
print "wget -U quicktime "+re.sub("(?<!h)1080p.mov$", "h1080p.mov", url)
View Comments

mplayer config

categories: config

There are dozens of vim configs but not many for mplayer but the defaults dont work that well on some media so here is how I like my mplayer:

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
stop-xscreensaver=1
vo=xv
ontop=yes
lavdopts=fast=1:threads=2:skiploopfilter=all
autosync=30
framedrop=yes
cache=102400
cache-min=20
cache-seek-min=20
softvol=1
softvol-max=1000
idx=1
ass=yes
embeddedfonts=yes
vfm=libmpeg2 # to selecgt mpeg12 over ffmpeg2
#ao=alsa:device=hw=0.3
#af=pan=2:1:0:0:1:1:0:0:1:0.5:0.5:1:1

Line 1 to 3 are self explanatory. Lines 4 to 6 add some options that slightly improve playback performance. Line 7 to 9 add some ridiculously high caches for playback performance as well.

The softvol entries of lines 10, 11 are sometimes necessary when audio is very silent and you have to make it louder than 100%.

Line 12 rebuilds the index for broken files automatically to be able to seek in files that are either broken or not yet fully downloaded.

Lines 13,14 add support for styled subtitles which are more and more used to subtitle anime and those subtitles are incredible.

Line 15 will probably be removed once an ffmpeg2 bug in decoding mpeg1/2 content is fixed. On some content it creates horrible artifacts and it took me some time to find out that the decoder is broken and i have to force usage of the mpeg12 decoder.

The last two lines are commented out as i only use them seldomly cases and they would otherwise hinder playback. They select my hdmi audio device for output (in cases where my laptop is connected to a hdmi device) and make 5.1 sound play back correctly, mixing it down to stereo.

View Comments

keene fm transmitter

categories: code

tl;dr: it works! software to be downloaded here

Half a year ago I purchased a usb fm transmitter from Keene Retail Ltd and funnily enough the audio part was immediately working with linux as it just showed up as an usb audio device linux was having drivers for.

[433346.713773] usbcore: registered new interface driver snd-usb-audio
[433346.731642] generic-usb 0003:046D:0A0E.0001: hiddev0,hidraw0: USB HID
v1.10i Device [HOLTEK B-LINK USB Audio ] on usb-0000:00:1d.0-1.2/input2
[433346.731662] usbcore: registered new interface driver usbhid
[433346.731664] usbhid: USB HID core driver

But of course there was a proprietary usb control protocol to set frequency, TX, preemphasis, volume and so on. So I started using the horrible windows only control software and captured the usb messages it sent to the stick using usbsnoop. Doing that was a horrible experience since the program was constantly making my computer freeze or disable the usb entirely so that i had to switch off the whole machine and reboot - no idea what was causing this and also no incentive to find out why. In the end I managed to capture enough data to basically understand the protocol that was used. But as with every good proprietary protocol you reverse engineer there are still things that are ambiguous or dont make sense or are redundant or where you see how the protocol developed from a less capable state. I had that all and I still dont fully understand the design goals but in the end (and what counts) I was able to assemble a samll C program that could control the FM transmitter as the windows client could.

Something out of the ordinary was, when I tried to contact the guys from Keene and ask them whether they would want to help me with writing a client that would work for their hardware on linux. It took some months but in the end I got this awesome message:

Dear Johannes,

I'm sorry this has taken a while but please find attached the source code for this unit.

If you are successful in producing linux drivers and software I would be happy to add your program as a download from our site, or link to your site should you prefer.

Good luck!

Kind regards,

Alan Quinby Director Keene Electronics Ltd

And attached I found a rar archive with a number of *.asm, *.LST, *.inc, and *.OBJ files and some files named HT82A821R with endings like *.bin, *.CV, *.DBG, *.dsw, *.MAK, *.MAP, *.OPT, *.OTP, *.PRJ and *.TSK. The first bunch of files was just assembler text and some C in between but I couldnt figure out how they belonged all together nor what toolchain those are belonging to. I also wonder why one would do any project in pure assembler instead of just using C? If anybody has a clue about what those files could mean dont hesitate to tell but since reverse engineering already gave me results I didnt feel brave enough to further dig into those piles of assembler. Nevertheless it was still great of them to just send the code around - something you only see seldomly! So kudos to Keene here.

Now the results of my reverse engineering can be found here and you can just compile and run keenectl.c with your stick inserted. You also have to run at as root and you musnt forget to rmmod the usbhid module beforehand but the program will tell you that as well once an error occurs. To set all values to default just run:

./keenectl - - - - - - -

The arguments correspond to TX (0-23), preemphasis (50us or 75us), channels (mono or stereo), frequency (floats from 76.0-108.0), PA (30 to 120), enable or disable and mute or unmute. If one of the arguments is - the default value is set. A command explicitly specifying the defaults would hence look like:

./keenectl 0 50us stereo 90.0f 120 enable unmute

To send all parameters, two 8 byte usb control messages are dispatched.

When you are done, you can play the music for example using mplayer:

mplayer -ao alsa:device=hw=1.0 YourMusic.wav

Have fun!

View Comments
« Older Entries