Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / libmpeg3 / mpeg3peek.c
blob25382a15886e980aaef8819fb2c43c58a0fd51a3
1 #include "libmpeg3.h"
2 #include <stdlib.h>
7 int main(int argc, char *argv[])
9 mpeg3_t *file;
10 if(argc < 3)
12 printf("Usage: mpeg3peek <table of contents> <frame number>\n");
13 printf("Print the byte offset of a given frame.\n");
14 printf("Only works for video. Requires table of contents.\n");
15 printf("Example: mpeg3peek heroine.toc 123\n");
16 exit(1);
19 int error = 0;
20 file = mpeg3_open(argv[1], &error);
21 if(file)
23 if(!mpeg3_total_vstreams(file))
25 printf("Need a video stream.\n");
26 exit(1);
29 if(!file->vtrack[0]->total_frame_offsets)
31 printf("Zero length track. Did you load a table of contents?\n");
32 exit(1);
35 int frame_number = atoi(argv[2]);
36 if(frame_number < 0) frame_number = 0;
37 if(frame_number > file->vtrack[0]->total_frame_offsets)
38 frame_number = file->vtrack[0]->total_frame_offsets - 1;
39 printf("frame=%d offset=0x%llx\n",
40 frame_number,
41 file->vtrack[0]->frame_offsets[frame_number]);