summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmpeg3/mpeg3toc.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3toc.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c b/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c
new file mode 100644
index 0000000..84b31cb
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c
@@ -0,0 +1,81 @@
1#include "libmpeg3.h"
2#include "mpeg3protos.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <sys/stat.h>
8#include <stdlib.h>
9
10int main(int argc, char *argv[])
11{
12 int i;
13 /*FILE *output; */
14 char new_path[1024], *ext;
15 struct stat st;
16 long size;
17 int timecode_search = 0;
18
19 if(argc < 2)
20 {
21 fprintf(stderr, "Create a table of contents for a DVD.\n"
22 "Usage: mpeg3toc [-t] <filename>...\n"
23 "-t Perform timecode search.\n"
24 "\n"
25 "The filenames should be absolute paths unless you plan\n"
26 "to always run your movie player from the same directory\n"
27 "as the filename. Alternatively you can edit the toc by\n"
28 "hand.\n"
29 "The timecode search allows XMovie to play the Matrix.\n"
30 "Example: mpeg3toc /cd2/video_ts/vts_01_*.vob > titanic.toc\n");
31 exit(1);
32 }
33
34 for(i = 1; i < argc; i++)
35 {
36 if(!strcmp(argv[i], "-t"))
37 {
38 timecode_search = 1;
39 }
40 else
41 {
42/* Get just name */
43 ext = strrchr(argv[i], '/');
44 if(ext)
45 {
46 ext++;
47 strcpy(new_path, ext);
48 }
49 else
50 strcpy(new_path, argv[i]);
51
52
53/* Replace suffix */
54 ext = strrchr(new_path, '.');
55 if(ext)
56 {
57 sprintf(ext, ".toc");
58 }
59 else
60 strcat(new_path, ".toc");
61
62 /* fprintf(stderr, "Creating %s\n", new_path); */
63
64 stat(argv[i], &st);
65 size = (long)st.st_size;
66
67 if(!size)
68 {
69 fprintf(stderr, "%s is 0 length. Skipping\n", new_path);
70 }
71 else
72 {
73/* Just want the first title's streams */
74 if(mpeg3_generate_toc(stdout, argv[i], timecode_search, i == argc - 1))
75 {
76 fprintf(stderr, "Skipping %s\n", argv[i]);
77 }
78 }
79 }
80 }
81}