- vstream -> StartStreaming();
- astream -> StartStreaming();
-
- printf("%f samples/frame\n", samplesperframe);
- printf("%d samplerate\n", samplerate);
- samplefix = 44100/samplerate;
-
- if(!samplefix) {
- printf("samplerate too high!\n");
- return 0;
- }
- printf("%d mp3 samples per movie sample\n", samplefix);
-
- file = open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC, 0644);
-
- memset(&swf, 0, sizeof(swf));
- swf.frameRate = (int)(fps*256);
- swf.fileVersion = 4;
- swf.fileSize = 476549;//0x0fffffff;
- swf.frameCount = lastframe - firstframe;
- r.xmin = 0;
- r.ymin = 0;
- r.xmax = width*20;
- r.ymax = height*20;
- swf.movieSize = r;
-
- swf_WriteHeader(file, &swf);
-
- tag = swf_InsertTag(NULL, ST_SETBACKGROUNDCOLOR);
- swf_SetU8(tag,0); //black
- swf_SetU8(tag,0);
- swf_SetU8(tag,0);
- swf_WriteTag(file, tag);
- swf_DeleteTag(tag);
-
- tag = swf_InsertTag(NULL, ST_SOUNDSTREAMHEAD2);
- swf_SetSoundStreamHead(tag, 1152);
- swf_WriteTag(file, tag);
- swf_DeleteTag(tag);
-
- int frame = 0;
- initdisplay(file);
-
- int mp3_block_size = 1152;
-
- int bufsize = mp3_block_size;
- if(mp3_block_size < (int)(samplesperframe+1))
- bufsize = (int)(samplesperframe + 1);
- unsigned char*buffer = (unsigned char*)malloc(bufsize);
- short*block = (short*)malloc(bufsize*2*samplefix);
-
- unsigned samples_read, bytes_read;
-
- double movie_sound_pos = 0;
- int mp3_sound_pos = 0;
-
- WAVEFORMATEX wave;
- astream->GetAudioFormatInfo(&wave,0);
-
- printf("nChannels:%d\n", wave.nChannels);
- printf("nSamplesPerSec:%d\n", wave.nChannels);
- printf("nAvgBytesPerSec:%d\n", wave.nAvgBytesPerSec);
- printf("nBlockAlign:%d\n", wave.nBlockAlign);
- printf("wBitsPerSample:%d\n", wave.wBitsPerSample);
- printf("cbSize:%d\n", wave.cbSize);
-
- while(1) {
- if(vstream->ReadFrame()<0) {
- printf("\n");
- break;