/* $Header: /home/ken/src/mq/RCS/mq.c,v 1.8 2001/11/07 01:31:31 ken Exp $ make a quicktime movie using libquicktime By Kenneth Berland 44100/30 1470 */ #include #include #include #include #include #include #include #include #include #include #include void usage(char**); void usage(char** args) { fprintf(stdout,"%s: By Kenneth Berland 2001\n",args[0]); fprintf(stdout," -i input file name\n"); fprintf(stdout," these are ppm files of the format\n"); fprintf(stdout," foo.0001.ppm\n"); fprintf(stdout," -s start frame\n"); fprintf(stdout," -e end frame\n"); fprintf(stdout," [-s step]\n"); fprintf(stdout," [-o output filename]\n"); fprintf(stdout," [-q quality] 0-100,200\n"); fprintf(stdout," 0-100 jpeg/m-jpeg compression\n"); fprintf(stdout," use 200 for uncompresed\n"); fprintf(stdout," [-m] use m-jpeg instead of jpeg\n"); fprintf(stdout," [-f fps] frame rate \n"); fprintf(stdout," [-a audiofile]\n"); fprintf(stdout," similar to a file made with:\n"); fprintf(stdout," sox ~/db.wav -r44100 -c2 -s -w ~/foo.raw\n"); fprintf(stdout," ONLY 30fps!!:\n"); fprintf(stdout," in other words:\n"); fprintf(stdout," raw (no header) 44.1khz, 2 channels, 16bit, signed samples\n"); fprintf(stdout," [-v] Be verbose\n"); } int main(int argc, char *argv[],char *env[]) { unsigned char** buffer; quicktime_t *file; int w=320; int h=240; int ix,iy; int frame; FILE* ppm; pixval max; pixel** ppmbuf; char filename[255]; char inpuname[255]; char outfname[255]; char audfname[255]; char comp[255]; int c; int fps=30,start=1,end=1,step=1,quality=50; int VERBOSE=0; int audiofile=0; int16_t **audbuf; int16_t* audbuf0; int16_t* audbuf1; void* auddata; struct stat aud_info; int audlen; inpuname[0]=0; audfname[0]=0; sprintf(outfname,"out.mov"); sprintf(comp,"jpeg"); /*Process my args */ while ((c = getopt(argc, argv, "hi:s:e:q:o:t:vf:ma:")) != EOF){ switch (c) { case 'h': usage(argv); exit(0); break; case 'i': sprintf( inpuname,"%s",optarg); break; case 'o': sprintf( outfname,"%s",optarg); break; case 'a': sprintf( audfname,"%s",optarg); break; case 'm': sprintf( comp,"mjpa"); break; case 's': start = atoi(optarg); break; case 'e': end = atoi(optarg); break; case 't': step = atoi(optarg); break; case 'f': fps = atoi(optarg); break; case 'q': quality = atoi(optarg); break; case 'v': VERBOSE=1; break; } } if (audfname[0]!=0) fps = 30; if ( inpuname[0]==0 ){ fprintf(stdout,"You must specify and input filename via -i\n"); fprintf(stdout,"exit.\n"); exit(-1); } /* Find out the size of the pictures I'm going to get */ sprintf(filename,"%s.%05d.ppm",inpuname,start); if ( (ppm = fopen(filename, "r"))==NULL){ perror(filename); fprintf(stderr,"exiting.\n"); exit(-1); } ppmbuf = ppm_readppm( ppm, &w, &h, &max ); ppm_freearray(ppmbuf,h); if (VERBOSE) fprintf(stdout,"Making movie %d X %d pixels, quality %d, FPS %d\n",w,h,quality,fps); /* Allocate the buffers */ buffer = malloc (sizeof(int) * h); for(iy=0;iy