1 #include "funcprotos.h"
6 printf("usage: dechunk [-f framerate] <input movie> <output prefix>\n");
7 printf(" Movies containing rgb frames are written as ppm images.\n");
12 int main(int argc
, char *argv
[])
19 char string
[1024], *prefix
= 0, *input
= 0;
21 int bytes
= 0, old_bytes
= 0;
22 float output_rate
= 0;
34 for(i
= 1, j
= 0; i
< argc
; i
++)
36 if(!strcmp(argv
[i
], "-f"))
40 output_rate
= atof(argv
[++i
]);
59 if(!prefix
|| !input
) usage();
61 if(!(file
= quicktime_open(input
, 1, 0)))
63 printf("Open failed\n");
67 if(!quicktime_video_tracks(file
))
69 printf("No video tracks.\n");
73 if(quicktime_match_32(quicktime_video_compressor(file
, 0), QUICKTIME_RAW
))
75 printf("Converting to ppm.\n");
79 length
= quicktime_video_length(file
, 0);
80 input_rate
= quicktime_frame_rate(file
, 0);
81 if(!output_rate
) output_rate
= input_rate
;
82 new_length
= output_rate
/ input_rate
* length
;
83 width
= quicktime_video_width(file
, 0);
84 height
= quicktime_video_height(file
, 0);
86 for(i
= 0; i
< new_length
; i
++)
89 sprintf(string
, "%s%06d", prefix
, i
);
90 if(!(output
= fopen(string
, "wb")))
92 perror("Open failed");
97 input_frame
= (int64_t)(input_rate
/ output_rate
* i
);
98 bytes
= quicktime_frame_size(file
, input_frame
, 0);
102 if(bytes
> old_bytes
) { free(data
); data
= 0; }
108 data
= malloc(bytes
);
111 quicktime_set_video_position(file
, input_frame
, 0);
112 quicktime_read_data(file
, data
, bytes
);
115 fprintf(output
, "P6\n%d %d\n%d\n", width
, height
, 0xff);
118 if(!fwrite(data
, bytes
, 1, output
))
120 perror("write failed");
125 quicktime_close(file
);