JMF 捕获音频、视频数据为混合后保存为QuickTime格式噪声大于音频输入原因
public class CaptureAudio {
/**
* Writing captured audio to a file with a DataSink.
* @throws CannotRealizeException
*/
public static void main(String[] args) throws CannotRealizeException {
Format[] formats = new Format[2];
formats[0] = new AudioFormat(AudioFormat.IMA4);
formats[1] = new VideoFormat(VideoFormat.CINEPAK);
DataSink filewriter = null;
Processor p = null;
StateHelper sh = null;
ProcessorModel pm = null;
//查询CaptureDeviceManager,来定位你需要使用的媒体采集设备。
//CaptureDeviceManager是可在JMF中使用的全部捕获设备的注册中心
//可以通过调用CaptureDeviceManager的getDeviceList方法获取可用的捕获设备列表
//CaptureDeviceInfo di = CaptureDeviceManager.getDevice("JavaSound audio capture");
//CaptureDeviceInfo di = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
try {
//获得MediaLocator,并由此创建一个Processor。
//可以用MediaLocator直接构建一个Player或者Processor
pm = new ProcessorModel( formats, new
FileTypeDescriptor(FileTypeDescriptor.QUICKTIME)) ;
p = Manager.createRealizedProcessor(pm);
sh = new StateHelper(p);
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
} catch (NoProcessorException e) {
e.printStackTrace();
System.exit(-1);
}
//Configure the processor.Once a Processor is Configured, you
//can set its output format and TrackControl options.
if (!sh.configure(10000)){
System.out.println("configure wrong!");
System.exit(-1);
}
// realize the processor.在这种状态下Player对象已经确定了它需要哪些资源,
//并且也知道需要播放的多媒体的类型。
if (!sh.realize(10000)){
System.out.println("realize wrong!");
System.exit(-1);
}
// get the output of the processor
//4以Processor的输出为参数,创建数据源
DataSource source = p.getDataOutput();
//定义存储该媒体的文件。
//5建立一个保存文件位置的MediaLocator
MediaLocator dest = new MediaLocator(new java.lang.String(
"file:///E:/Documents and Settings/foo.qt"));
捕获音频、视频数据为混合后保存为QuickTime格式噪声很大甚至快完全盖住输入音频了。
这是部分代码。。。问题请各位大虾一定帮帮忙!谢谢.小弟是穷人,分少,大家不要介意啊!