8 int main(int argc, char *argv[])
15 printf("Usage: mpeg3peek <table of contents> <frame number>\n");
16 printf(" mpeg3peek <table of contents> <sample number>\n");
17 printf("Print the byte offset of a given frame or sample.\n");
18 printf("If the file has no video, the sample number is located.\n");
19 printf("Requires table of contents.\n");
20 printf("Example: mpeg3peek heroine.toc 123\n");
24 sscanf(argv[2], "%jx", &frame_number);
25 if(frame_number < 0) frame_number = 0;
27 file = mpeg3_open(argv[1], &error);
29 if(!mpeg3_total_vstreams(file)) {
30 if(!mpeg3_total_astreams(file)) {
31 printf("Need a video stream.\n");
35 if(!file->atrack[0]->total_sample_offsets) {
36 printf("Zero length track. Did you load a table of contents?\n");
40 int64_t chunk_number = frame_number / zmpeg3_t::AUDIO_CHUNKSIZE;
41 if(chunk_number >= file->atrack[0]->total_sample_offsets)
42 chunk_number = file->atrack[0]->total_sample_offsets - 1;
43 printf("sample=%jx offset=0x%jx\n",
45 file->atrack[0]->sample_offsets[chunk_number]);
49 if(!file->vtrack[0]->total_frame_offsets) {
50 printf("Zero length track. Did you load a table of contents?\n");
54 if(frame_number >= file->vtrack[0]->total_frame_offsets)
55 frame_number = file->vtrack[0]->total_frame_offsets - 1;
56 printf("frame=%jx offset=0x%jx\n",
58 file->vtrack[0]->frame_offsets[frame_number]);