【问题标题】:How to export audio-media from a MOV-file with QuickTime-API?如何使用 QuickTime-API 从 MOV 文件中导出音频媒体?
【发布时间】:2010-02-15 09:51:20
【问题描述】:

我想使用 QuickTime-API 导出 MOV 文件的音频媒体并将其保存到 WAV 文件(或其他类似文件)。我怎样才能做到这一点?我使用的是 Windows XP。

【问题讨论】:

  • 您愿意使用 Quicktime-for-Java api 吗?

标签: audio export quicktime


【解决方案1】:

对不起,如果我说的是显而易见的,但您应该能够以与此处所述相同的方式实现这一点:

Export every frame as image from a Movie-File (QuickTime-API)

或者您需要以非交互方式执行此操作吗?

编辑

要使用电影导出器以非交互方式将电影文件的音频媒体导出到 WAVE,请使用以下代码:

"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
...

【讨论】:

  • 非交互方式会更好,是的。
  • 我试过这个方法,QuickTime也创建了一个WAV-File,但是它只有84kb大小……所以你可以说里面没有数据……为什么?
  • 如果您检查 ConvertMovieToFile() 的返回值 - 它是否返回一个值!= noErr?返回值可能会提示在这种情况下出了什么问题...
  • 返回值 == noErr;我是否必须遍历每一帧(或者:ConvertMovieToFile() 是否只导出 1 帧的声音?)?还是您的代码应该导出完整的 WAV?
  • 它应该导出完整的音频。昨天测试的时候效果很好。您尝试过哪些文件?此外,我使用上面链接的答案中的代码来获取 QuickTime 文件的电影。你用了不同的东西吗?如果,那么这可能是代码行为不同的原因......
【解决方案2】:

ffmpeg 很容易做到这一点,如果商业软件需要,可以在 LGPL 下编译。如果您需要更多可定制的钩子,您可以使用同一项目中的 libavcodec 和 libavformat。

【讨论】:

  • 我说我需要 Quicktime-API
【解决方案3】:

带播放器

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

【讨论】:

  • 我说我需要 Quicktime-API
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多