Idea: Experimenting with movie hashing/fingerprinting

MEDIA FINGERPRINTING
Neal Krawetz wrote an interesting article on image fingerprinting, or how to search for images that are similar. He proposes an algorithm to do image fingerprinting and reproduce the functionality of TinEye, a service that allows to give one image and get back all the web pages where that picture, or a slightly modified version of it, is included. By resizing the image to 8×8 pixels, creating a B/W version, and then a binary (only black or white pixels, no grey levels), he reduces a picture to a hash that is 8 x 8 = 64 bits. This can then be compared to a database of hashes of millions of other pictures found on the web (by calculating the “Hamming distance” – read the article for details).
On the other hand, something similar can be done on segments of audio. Youtube has been doing it for years (using technology from Audible Magic) and recently the Echo Next has released Echo Print, a music fingerprint and identification service that does the same thing for free.

VIDEO FINGERPRINTING
Since I work (and play) a lot with video, I was thinking about how to extend the ideas Neal proposes to video. Video material consists of audio (which I will ignore for now) and a sequence of images (typically between 24 and 30 per second). I’ve taken a video clip from Youtube as inspiration, but I won’t tell you yet which one, let’s discover it while I create the fingerprint of 1 of the frames, using the method described by Neal:

first we reduce the frame to a small format, e.g. 16×8 pixels
then we desaturate: make the picture grayscale
then we normalize it: we maximize the contrast, the darkest pixel become the new black, the lightest becomes the new white
we calculate the average darkness and any pixel that is darker we make black, and the others become white -this is what is proposed in the article. Total size of fingerprint: 16 pix * 8 pix * 1 bit = 96 bits = 16 bytes
I found the details in the above fingerprint too coarse, so I used 4 color levels instead of 2. Total size of fingerprint = 16 pix * 8 pix * 2 bits = 32 bytes

Continue reading Idea: Experimenting with movie hashing/fingerprinting

Focal length for the common man: “portrait distance”

I remember that before I started photography on a serious level, I had some understanding of shutter speed, but none of aperture and focal length. Even when I read what they meant, I still couldn’t ‘picture’ it, had no feeling for the numbers. Let’s leave ‘aperture’ for another time and just concentrate for now on the concept of “focal length”

First of all, the focal length of a lens is not the same as the actual physical length of the lens. Yes, 200mm and 300mm lenses (telephoto lenses) tend to be longer, but they’re not exactly 200mm and 300mm long. For instance, the Sigma 55-200mm F4-5.6 DC HSM is 85mm (3.3″) long,  while the 70-200mm F2.8 II EX DG lens is 184mm (7.2″). Same maximal focal length, but more than twice as long.

So what is focal length? I could explain that it is “the distance from the center of the lens to the principal foci (or focal points) of the lens“, but that wouldn’t make it more comprehensible, would it? Well, I read through the theory, with tangens of the viewing angle and stuff, and I think I understand it (I’m an engineer, I actually like trigoniometry). A 200mm lens gives a viewing angle of 12° on the diagonal. Still not clear? That’s when I thought: let’s invent something more tangible: the “portrait distance“. Say you need a surface of about 72cm x 48cm (28″ x 18″) to make a portrait of a person (not just a headshot, but with some torso on it too). See some examples below:

Vriendschap foto's voor Erfgoeddag Sandy @ Chaff Brussels Tango Festival - Day 1 ¿Que? Fado & Tango - Dirk

Well, the distance between the camera and the person you’re making the portrait of, will be +- 20 times the focal length.

Continue reading Focal length for the common man: “portrait distance”

My quest for “Let’s get lost” – Chet Baker by Bruce Weber

Let's Get lost - movie poster
Let’s Get Lost (1988) is a American documentary film about the turbulent life and career of jazz trumpeter Chet Baker written and directed by Bruce Weber.

I saw Let’s Get Lost in Leuven, I guess around 1990. Chet Baker has been a weak spot for me ever since, because I now knew how much suffering was hiding behind that vulnerable voice. I tried to find a DVD of it but apart from a VHS tape (I don’t have a player) I couldn’t find anything. Then the other day I found the whole movie, split in 13 parts, on Youtube:

Continue reading My quest for “Let’s get lost” – Chet Baker by Bruce Weber

Apple trailers: when 720p isn’t always 720p

One of the best places to look for high-quality movie trailers is Apple Trailers. They have lots of bandwidth and a large selection (altough they don’t have e.g. the new Indiana Jones 4 trailers, which are exclusively on Yahoo HD trailers).

Apple typically offers its HD trailers in 3 formats: 480p, 720p and 1080p. The “p” stands for “progressive” i.e. not interlaced, every frame is a full picture instead of only the odd or even lines. The 480 in “480p” stands for the number of lines in the image. 480p is roughly equivalent with DVD quality, 720p is “HD Ready” and 1080p is “Full HD”.

But let me give a concrete example of the resolution of 3 trailers:
resolutions of Apple Trailers
Continue reading Apple trailers: when 720p isn’t always 720p

Screenshots of a DVD with ‘ffmpeg’

I’ve been playing around a lot with video conversion lately and one of the tools I use often is the Swiss armyknife for video manipulation ‘ffmpeg‘. It does format conversion (MPEG1/2/4, Quicktime, AVI …) , rescaling, recompressing, frame rate conversion … almost everything. It exists for all flavours of Linux/Unix, and also for Windows.

To give you an example: this is a script I wrote to extract screenshots of DVD files, straight from the disk.

1) the naive version
ffmpeg -i [input file] -r .05 -y [output name]%%03d.png
This does indeed extract a PNG image every 20 seconds (framerate = 0.05), but it does not take into account that the DVD image material is stored anamorphically. What you get is this:
V4Vendetta_1_720.012
Natalie Portman looks really thin, but that’s because the image dimensions (720×576 pixels – PAL standard) are for 5:4 aspect ratio, and whereas the actual image should be 16:9. So let’s make the image wider while keeping it the same height.

2) Rescale to 16:9
ffmpeg -i [input file] -r .05 -s 1024x576 -y [output name]%%03d.png
The result looks better:
V4Vendetta_1_1024.012

As you see, there are still black borders on the top and bottom. This is because a feature film is made in ‘scope’ format, with an aspect ratio of 2.39 instead of 1.78 (the decimal equivalent of 16/9). So, while the full width of the image is used, only 428 pixels of the height are actually in use. Let’s crop those black borders off.

3) Crop black borders away
ffmpeg -i [input file] -r .05 -croptop 74 -cropbottom 74 -s 1024x428 -y [output name]%%03d.png

V for Vendetta: cropped

4) old 4:3 movies
The older movies used a 4:3 aspect ratio, so when you extract them as 16:9 they look like a weight feel on them:
MammaRoma_1024
In those cases, you can use the ‘naive’ version above, which will give you:
MammaRoma_720

Here also, the actual 4:3 image is ‘letterboxed’ to the 5:4 DVD image.

Continue reading Screenshots of a DVD with ‘ffmpeg’

Buying an HD-Ready TV

I get the question a lot, so I thought I might write a post about it as a ready-made answer to the next few.

“I’m gonna buy a new (LCD) TV, should I go for HD Ready or for Full HD?”

Nothing even remotely like HD

1. What’s the difference?

Full HD is (at least) a 1920 x 1080 pixels (also called 1080i or 1080p, depending on whether the signal is interlaced/not as good or progressive/better) resolution. An HD Ready TV will typically only have a 1366 x 768 (WXGA) resolution, but it will still accept 1920×1080 input (that’s why it is ‘ready’).

2. What’s your budget?

You will have a hard time finding a TV that is “Full HD” under the 1000€ mark (Pixmania now has 1 Hitachi of 975€). If you want to spend more like 600€, that solves a lot of difficult choices!

Continue reading Buying an HD-Ready TV

What is HD-JPEG?

While reading the specs of the PackardBell Store & Play, I fall upon “Foto formaten: JPEG, HD JPEG” As I am working with several aspects of HD (High Definition) video all the time, I am of course intrigued. There is a standard for HD JPEG? Wow, tell me more!

HD JPEG = HD Photo = JPEG XR (my guess)

Well, it’s not that easy, actually. When you do a search for “HD JPEG” on Google, all you see is promo talk. Vendors like Philips and Panasonic use it as a feature on their devices, but there is no official definition of what it stands for. What I think happened is:

  • Microsoft developed a standard “HD Photo” (formerly Windows Media Photo) that corrects some of the disadvantages of JPEG:
    • It can store color information at 32 bit per color instead of 8 or 12. (In current JPEG, “24-bit colour” means: 3 x 8 bits for R, G and B.)
    • All encoding steps of the algorithm are lossless (except for quantisation). So it has a true lossless mode (all coefficients = 1). JPEG does not have this (at least, not implemented).
    • All kinds of tech mumbo-jumbo reasons (read the Wikipedia article)
    • “HD Photo offers image quality comparable to JPEG-2000 with computational and memory performance more closely comparable to JPEG”
  • The JPEG committee announced that they would (consider to) adopt HD-Photo as a standard, with as a working name JPEG XR. Provided that, of course, …

    One important aspect regarding the standardization of HD Photo is Microsoft’s commitment to make its patents that are required to implement the specification available without charge. Microsoft’s royalty free commitment will help the JPEG committee foster widespread adoption of the specification and help ensure that it can be implemented by the widest possible audience. The JPEG committee hopes and encourages all participants in its meetings to consider this royalty free approach when offering patented technology as a candidate for standardization.

  • The hardware vendors didn’t like the “JPEG XR” name (it doesn’t really show clearly that it’s an upgrade from JPEG), so they combined it with an acronym that consumers know and associate with “better” and “more expensive”, so was born “HD JPEG”.
  • in short: Technically, it does not exist. Practically, it sells flat screens.

Competition Continue reading What is HD-JPEG?

id3.exe – ideal tool for tagging and renaming MP3 files

I want to mention a little tool that helped me out twice in the last week, and that I find very little info about online. It’s a Windows command-line MP3 file tagger and renamer called id3.exe. Since I forgot where I downloaded it from and Google doesn’t give me a clue either: here’s where you can download id3.exe.

ID3.exe can do several things, of which I will just cite the things I actually used:

  • it can obviously set ID3 tags in MP3 files (that is, ID3v1 and v2). The first time it adds ID3v2 tags which are stored in the beginning of the file (necessary when you need the info right when you start reading the file, like with streaming), the whole file has to be rewritten, but subsequent modifications are really fast.
    id3.exe -1 -2 -g [genre] -c "[Copyright notice]" -l "[Album name]" "%OUTPUT%"
  • set the ID3 tags of one file to those of another. I needed this when I transcoded MP3 files to a lower bitrate with LAME. LAME does not copy the existing ID3 tags to the new file. So I used ID3.exe to just copy those from the source file.
    id3.exe -D %INPUT% -1 -2 "%OUTPUT%"
  • Rename the file according to the MP3 tags. I had a big collection of MP3 files called “01 Track01” without any MP3 tags. I first set the ID3 tags based upon the folder structure (the folder name was the Album name), and then renamed them to “[Artist name] – [Album name] – [Track N°].mp3”.
    id3.exe -2 -f "%%a - %%l - %%t.rbs" "%OUTPUT%"
  • Id3 can also deduct album names, artist, song titles and track number from the complete filename + path.

Continue reading id3.exe – ideal tool for tagging and renaming MP3 files

New beta YouTube layout

This is what a YouTube clip page looks like now:
YouTube layout: now

And this is what YouTube is developing as a new ‘beta’ version:
Youtube layout: beta

  • they got rid of the large banner (” Use Quicklists!”) which was basically a waste of space.
  • all clip info is now under the video instead of to the right. All info on and action on a video are now in one place. I like it.
  • Youtube likes you to check out other videos. Most newly freed space is dedicated to thumbnails of other (‘related’/’promoted’) clips: you now see 13 of them on the frist page instead of 5.