JMF 捕获音频、视频数据为混合后保存为QuickTime格式噪声大于音频输入原因

denghanlin 2009-04-13 04:45:17
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格式噪声很大甚至快完全盖住输入音频了。
这是部分代码。。。问题请各位大虾一定帮帮忙!谢谢.小弟是穷人,分少,大家不要介意啊!
...全文
308 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
记录在案 2009-06-12
  • 打赏
  • 举报
回复
兄台有没有做过DirectShow下捕捉视频采集卡的视频进行去隔行呢?请教下,发个算法学习下。zqn155@163.com

1,451

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 图象工具使用
社区管理员
  • 图象工具使用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧