views:

212

answers:

3

I want to export the audio-media of a MOV-File with the QuickTime-API and save it to an WAV-File (or something equivalent). How can I do that? I use Windows XP.

A: 

ffmpeg is easily capable of this and can be compiled under the LGPL if needed for commercial software. If you need more customizable hooks you can use libavcodec and libavformat from the same project.

cobbal
i said i need it with Quicktime-API
Berschi
+1  A: 

Sorry if I am stating the obvious, but you should be able to achieve this the same way as described here:

http://stackoverflow.com/questions/1859415/export-every-frame-as-image-from-a-movie-file-quicktime-api/1940361#1940361

Or do you need to do this in a non-interactive way?

Edit

To export the audio media of a Movie file to WAVE non-interactively using a Movie Exporter, use the following code:

"include "QuickTimeComponents.h"
...
// aquire Movie
...
ComponentDescription  desc;
MovieExportComponent  exporter;
char  filename[255];
FSSpec  fsspec;
int flags;

// first we have to find a Movie Exporter capable of eporting the format we want
desc.componentType          = MovieExportType;
desc.componentSubType       = kQTFileTypeWave; // 'WAVE'
desc.componentManufacturer  = SoundMediaType;
desc.componentFlags         = 0;
desc.componentFlagsMask     = 0;

// and create an instance of it
exporter = OpenComponent( FindNextComponent( 0, &desc ) );

// then set up a FSSpec for our output file
sprintf( outfilename, "C:/test.wav" );
c2pstr( outfilename );
FSMakeFSSpec( 0, 0L, (ConstStr255Param)outfilename, &fsspec );
// if you do error handling take care to ignore fnfErr being returned 
// by FSMakeFSSpec - we're about to create a new file after all

// then finally initiate the conversion
flags= createMovieFileDeleteCurFile | movieToFileOnlyExport;
ConvertMovieToFile( movie, 0, &fsspec, kQTFileTypeWave, 'TVOD', 0, 0, flags, exporter );

CloseComponent( exporter );

...
// Clean up
...
Bjoern
a non-interactive way would be better, yes.
Berschi
i tried this way, and QuickTime also creates a WAV-File, but it has only 84kb size... so you can say there is no data in it... why?
Berschi
if you check the return value of ConvertMovieToFile() - does it return a value != noErr? The return value might give hint on what goes wrong in this case...
Bjoern
return value == noErr; do I have to iterate over every frame (or: does ConvertMovieToFile() just export the sound of 1 frame?)? or should your code export the complete WAV?
Berschi
It should export the complete audio. It worked fine when I tested it yesterday. How may files have you tried?Furthermore, I used the code from my answer linked above to aquire the Movie of the QuickTime file. Did you use something different? If, so this might be the reason the code behaves differently...
Bjoern
that was the problem, I used a AVI-file, not a MOV-file. Thank you so much! :-)
Berschi
A: 

with mplayer mplayer.exe -ao pcm:file=output.wav -vo null -vc dummy input.mov

i said i need it with Quicktime-API
Berschi