Friday, January 23, 2009

Encoding video sizes

Video compression usually works on square blocks of pixels. These can have sizes of 8x8 or 16x16 or other powers of 2. H264 (AVC) for example, uses macroblocks of 16x16.

So when compressing video, it helps if the frame size is such that both width and height are evenly divisible by 16 or at least by 8. This is why videos encoded for the web or for portable video players are often not exactly in a 16/9 aspect ratio. The PSP's screen, for example, is 480 x 272 even though true 16/9 would require 480 x 270. But 270 is not divisible by 16 whereas 272 is. Youtube uses 640x360, which is true 16/9 and divisible by 8. If you use other sizes, FFmpeg will print a message like

width or height not divisible by 16 (480x270), compression will suffer.

So what are the sizes which are both the right aspect ratio and nicely divisible by 16 or by 8? This little Perl script will let us know:

#!/usr/bin/perl

my $aspect_width  = 16;
my $aspect_height = 9;
my $max_height = 1200;
my @dividers = (16, 8);

for my $divider (@dividers) {

print "$aspect_width/$aspect_height with both ",
     "width and height divisible by $divider :\n\n";

# try sizes up to Full HD
for my $i (1..$max_height/$aspect_height) {
   my $h = $aspect_height * $i;
   unless ($h % $divider) {
       my $w = $aspect_width * $i;
       printf "$aspect_width/$aspect_height divisible by %2d : %4d x %4d\n",
              $divider, $w, $h;
   }
}

print "\n";
}

For 16/9, this gives, among others, numbers like

16/9 divisible by 16 :  256 x  144
16/9 divisible by 16 :  512 x  288
16/9 divisible by 16 :  768 x  432
16/9 divisible by 16 : 1024 x  576
16/9 divisible by 16 : 1280 x  720

For sizes divisible by 8, you obviously have all of the above, plus (among others):

16/9 divisible by  8 :  384 x  216
16/9 divisible by  8 :  640 x  360
16/9 divisible by  8 :  896 x  504
16/9 divisible by  8 : 1920 x 1080
16/9 divisible by  8 : 2048 x 1152

Labels: , , , , ,

Sunday, January 11, 2009

try windows 7 beta

So we can try this Windows 7 beta now, which is said to be better than Vista, and which we'll have to get used to anyway. Here a few tips which I may need when I find a machine to try it on, and which may help you too.

The official download seems to only work with IE 7, but if you get the direct link it does work normally. So with wget, that would be:

For the 32 bit version:
wget -c http://download.microsoft.com/download/6/3/3/633118BD-6C3D-45A4-B985-F0FDFFE1B021/EN/7000.0.081212-1400_client_en-us_Ultimate-GB1CULFRE_EN_DVD.ISO
And for the 64 bit version:
wget -c http://download.microsoft.com/download/6/3/3/633118BD-6C3D-45A4-B985-F0FDFFE1B021/EN/7000.0.081212-1400_client_en-us_Ultimate-GB1CULXFRE_EN_DVD.ISO

To have the beta working until August, you need a key. Apparently, there are only a few keys used:

7XRCQ-RPY28-YY9P8-R6HD8-84GH3
RFFTV-J6K7W-MHBQJ-XYMMJ-Q8DCH
482XP-6J9WR-4JXT3-VBPP6-FQF4M
D9RHV-JG8XC-C77H2-3YF6D-RYRJ9
JYDV8-H8VXG-74RPT-6BJPB-X42V4

4HJRK-X6Q28-HWRFY-WDYHJ-K8HDH
QXV7B-K78W2-QGPR6-9FWH9-KGMM7
6JKV2-QPB8H-RQ893-FW7TM-PBJ73
GG4MQ-MGK72-HVXFW-KHCRF-KW6KY
TQ32R-WFBDM-GFHD2-QGVMH-3P9GC

Possibly also useful:

Labels: , , , , ,