Below is a C program which will decode and display the length of each film given as a command line argument.
Code: Select all
#include <stdio.h>
#include <assert.h>
int main(int argc, char *argv[])
{
FILE *fp;
int a, b, c, d;
int length;
int i;
for (i = 1; i < argc; i++) {
fp = fopen(argv[i], "r");
assert(fp != NULL);
fseek(fp, 0x48, SEEK_SET);
a = fgetc(fp); assert(a != EOF);
b = fgetc(fp); assert(b != EOF);
c = fgetc(fp); assert(c != EOF);
d = fgetc(fp); assert(d != EOF);
length = a<<24 | b<<16 | c<<8 | d;
if (length == 0)
printf("partial film %s\n", argv[i]);
else {
length -= 10*30;
printf("%d:%02d:%02d.%02d -- %s\n",
length/30/60/60,
length/30/60%60,
length/30%60,
(length*10+1)/3%100,
argv[i]);
}
fclose(fp);
}
}
Code: Select all
> filmlength recordings/Netgame-\ Mar*
0:24:41.60 -- recordings/Netgame- Mar 01 05.07.55 2006
0:22:20.80 -- recordings/Netgame- Mar 10 02.25.40 2006
1:12:30.93 -- recordings/Netgame- Mar 21 06.40.00 2006
Films that are incomplete because Myth crashed during the game have no timing information and are displayed as "partial film".
Running the program on zipped films or other kind of files will return non-sensical information. No attempt is made to detect that a file is not a film.[/color]