bashley
28th December 2005, 11:18
I find the xml emphasis of recent versions of dvdauthor cumbersome
when most of my applications involve a simple initial menu. I put
together these utilities to facilitate generation of a dvd having
several titles and a front menu.
The process generates the mydvd directory at your current location in
your system. The resulting DVD menu has numbered titles and you select
the title by entering the corresponding number on your player remote
control. Prior to this I had always used up/down arrows on the remote
to navigate the menu. These arrows still work, but I have not provided
the necessary highlight to inform you of your menu location.
First is the script that drives the process:
___________________________________________________________________________________________
#!/bin/bash
if [ ! $BACKGROUND ] ;then
BACK=/root/sbin/dvd/background.jpg
else
BACK=$BACKGROUND
fi
SILENT=/root/silence.mp2
rm -rf mydvd
genxml $@
rm -f menu.mpg
jpegtopnm $BACK | ppmtoy4m -n 1 -F 30000:1001 -A 10:11 -I t -L | mpeg2enc -f 8 -n p -o menu.m2v
mplex -f 8 -o /dev/stdout menu.m2v $SILENT | spumux -v 2 sputext.xml > menu.mpg
dvdauthor -x dvdmenu.xml
rm menu.m2v menu.mpg sputext.xml dvdmenu.xml
___________________________________________________________________________________________
This script looks for the environment variable BACKGROUND which is a 720x480 jpg background
to the front menu. Modify the BACK=... line to set your own default background. SILENT points
to a null audio file.
The script calls genxml to create two xml files, sputext.xml which drives spumux to
overlay the menu on the background, and dvdmenu.xml to drive the authoring process.
The script requires jpegtopnm, ppmtoy4m, mpeg2enc, mplex, along with dvdauthor and
spumux which are part of the same package.
Sources of the necessary components are:
jpegtopnm:netpbm [netpbm-10.20]
ppmtoy4m:mjpegtools [mjpegtools-1.6.2]
mpeg2enc: also from mjpegtools
mplex: also from mjpegtools
dvdauthor/spumux: I use version 6.10.
genxml is the executable formed from genxml.c:
___________________________________________________________________________________________
/*
program to generate xml files for dvdauthor
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termio.h>
#include <sys/wait.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
#define MAXTITLES 20
#define MAXLEN 128
FILE *ofd;
int titleargs[MAXTITLES+1];
char title[MAXLEN];
main(argc,argv)
int argc;
char *argv[];
{
char *ptr;
int i,j,k,k1,numtitles=0;
for(j=1;j<argc && numtitles<MAXTITLES;++j){
if(strcmp(argv[j],"-T")==0){
titleargs[numtitles]=j+1;
++numtitles;
}
}
titleargs[numtitles]=argc+1;
if((ofd=fopen("titles.srt","w"))==NULL){
printf("Cannot create titles.srt\n");
exit(1);
}
fprintf(ofd,"1\n");
fprintf(ofd,"00:00:00,000 --> 00:10:00,000\n");
for(j=0;j<numtitles;++j){
strncpy(title,argv[titleargs[j]],MAXLEN);
ptr=title-1;
while(*++ptr) if(*ptr=='_') *ptr=' ';
fprintf(ofd,"%d: %s\n",j+1,title);
}
fclose(ofd);
if((ofd=fopen("dvdmenu.xml","w"))==NULL){
printf("Cannot create dvdmenu.xml\n");
exit(2);
}
fprintf(ofd,"<dvdauthor dest=\"./mydvd/\">\n<vmgm>\n<menus>\n<video format=\"ntsc\"></video>\n<pgc entry=\"title\">\n<vob file=\"menu.mpg\"></vob>\n");
for(j=0;j<numtitles;++j) fprintf(ofd,"<button>jump title %d;</button>\n",j+1);
fprintf(ofd,"<button>exit;</button>\n</pgc>\n</menus>\n</vmgm>\n\n");
for(j=0;j<numtitles;++j){
fprintf(ofd,"<titleset>\n<titles>\n<pgc>\n");
k=titleargs[j]+1;
k1=titleargs[j+1]-1;
for(i=k;i<k1;++i) fprintf(ofd,"<vob file=\"%s\"></vob>\n",argv[i]);
fprintf(ofd,"<post>call vmgm menu;</post>\n</pgc>\n</titles>\n</titleset>\n\n");
}
fprintf(ofd,"\n</dvdauthor>\n");
fclose(ofd);
//for(j=1;j<argc;++j) printf("%d %s\n",j,argv[j]);
exit(0);
}
___________________________________________________________________________________________
when most of my applications involve a simple initial menu. I put
together these utilities to facilitate generation of a dvd having
several titles and a front menu.
The process generates the mydvd directory at your current location in
your system. The resulting DVD menu has numbered titles and you select
the title by entering the corresponding number on your player remote
control. Prior to this I had always used up/down arrows on the remote
to navigate the menu. These arrows still work, but I have not provided
the necessary highlight to inform you of your menu location.
First is the script that drives the process:
___________________________________________________________________________________________
#!/bin/bash
if [ ! $BACKGROUND ] ;then
BACK=/root/sbin/dvd/background.jpg
else
BACK=$BACKGROUND
fi
SILENT=/root/silence.mp2
rm -rf mydvd
genxml $@
rm -f menu.mpg
jpegtopnm $BACK | ppmtoy4m -n 1 -F 30000:1001 -A 10:11 -I t -L | mpeg2enc -f 8 -n p -o menu.m2v
mplex -f 8 -o /dev/stdout menu.m2v $SILENT | spumux -v 2 sputext.xml > menu.mpg
dvdauthor -x dvdmenu.xml
rm menu.m2v menu.mpg sputext.xml dvdmenu.xml
___________________________________________________________________________________________
This script looks for the environment variable BACKGROUND which is a 720x480 jpg background
to the front menu. Modify the BACK=... line to set your own default background. SILENT points
to a null audio file.
The script calls genxml to create two xml files, sputext.xml which drives spumux to
overlay the menu on the background, and dvdmenu.xml to drive the authoring process.
The script requires jpegtopnm, ppmtoy4m, mpeg2enc, mplex, along with dvdauthor and
spumux which are part of the same package.
Sources of the necessary components are:
jpegtopnm:netpbm [netpbm-10.20]
ppmtoy4m:mjpegtools [mjpegtools-1.6.2]
mpeg2enc: also from mjpegtools
mplex: also from mjpegtools
dvdauthor/spumux: I use version 6.10.
genxml is the executable formed from genxml.c:
___________________________________________________________________________________________
/*
program to generate xml files for dvdauthor
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termio.h>
#include <sys/wait.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
#define MAXTITLES 20
#define MAXLEN 128
FILE *ofd;
int titleargs[MAXTITLES+1];
char title[MAXLEN];
main(argc,argv)
int argc;
char *argv[];
{
char *ptr;
int i,j,k,k1,numtitles=0;
for(j=1;j<argc && numtitles<MAXTITLES;++j){
if(strcmp(argv[j],"-T")==0){
titleargs[numtitles]=j+1;
++numtitles;
}
}
titleargs[numtitles]=argc+1;
if((ofd=fopen("titles.srt","w"))==NULL){
printf("Cannot create titles.srt\n");
exit(1);
}
fprintf(ofd,"1\n");
fprintf(ofd,"00:00:00,000 --> 00:10:00,000\n");
for(j=0;j<numtitles;++j){
strncpy(title,argv[titleargs[j]],MAXLEN);
ptr=title-1;
while(*++ptr) if(*ptr=='_') *ptr=' ';
fprintf(ofd,"%d: %s\n",j+1,title);
}
fclose(ofd);
if((ofd=fopen("dvdmenu.xml","w"))==NULL){
printf("Cannot create dvdmenu.xml\n");
exit(2);
}
fprintf(ofd,"<dvdauthor dest=\"./mydvd/\">\n<vmgm>\n<menus>\n<video format=\"ntsc\"></video>\n<pgc entry=\"title\">\n<vob file=\"menu.mpg\"></vob>\n");
for(j=0;j<numtitles;++j) fprintf(ofd,"<button>jump title %d;</button>\n",j+1);
fprintf(ofd,"<button>exit;</button>\n</pgc>\n</menus>\n</vmgm>\n\n");
for(j=0;j<numtitles;++j){
fprintf(ofd,"<titleset>\n<titles>\n<pgc>\n");
k=titleargs[j]+1;
k1=titleargs[j+1]-1;
for(i=k;i<k1;++i) fprintf(ofd,"<vob file=\"%s\"></vob>\n",argv[i]);
fprintf(ofd,"<post>call vmgm menu;</post>\n</pgc>\n</titles>\n</titleset>\n\n");
}
fprintf(ofd,"\n</dvdauthor>\n");
fclose(ofd);
//for(j=1;j<argc;++j) printf("%d %s\n",j,argv[j]);
exit(0);
}
___________________________________________________________________________________________