jmf-请问怎样从一个视频设备获取视频信息存入文件

firestar 2003-08-25 11:16:04
我想用jmf从一个usb摄像头获取视频信息存入文件,请问那位有例子多谢。
...全文
119 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
firestar 2003-09-07
  • 打赏
  • 举报
回复
我成功了但是文档当中的传递媒体流的程序实现不了我刚开始学习jmf不知道怎么改动
错误在于 Processor 的p.configure()执行以后不能够被正确配置,下一句程序说没有配置好所以不能够执行。
public void dosend()
{
Processor p=null;
// First find a capture device that will capture linear audio
// data at 8bit 8Khz

AudioFormat format= new AudioFormat(AudioFormat.LINEAR,
8000,
8,
1);

Vector devices= CaptureDeviceManager.getDeviceList( format);
CaptureDeviceInfo di= null;
if (devices.size() > 0) {
di = (CaptureDeviceInfo) devices.elementAt(0);
System.out.print(di.getName());
}
else {
// exit if we could not find the relevant capturedevice.
System.exit(-1);
}

// Create a processor for this capturedevice & exit if we
// cannot create it
try {

p=Manager.createProcessor(di.getLocator());

} catch (IOException e) {
System.exit(-1);
} catch (NoProcessorException e) {
System.exit(-1);
}

// configure the processor
try{

p.configure();
// p.realize();
}
catch(Exception eee)
{
System.out.print(eee);
}

System.out.print(p.getState());
System.out.print(p.Configuring);
// System.out.print(p.getContentDescriptor().toString());
// block until it has been configured

// test.setContentDescriptor(
// new ContentDescriptor( ContentDescriptor.RAW));
System.exit(-1);
/*TrackControl track[] = p.getTrackControls();

boolean encodingOk = false;

// Go through the tracks and try to program one of them to
// output gsm data.

for (int i = 0; i < track.length; i++) {
if (!encodingOk && track[i] instanceof FormatControl) {


if (((FormatControl)track[i]).
setFormat( new AudioFormat(AudioFormat.GSM_RTP,
8000,
8,
1)) == null) {

track[i].setEnabled(false);
}
else {
encodingOk = true;
}
} else {
// we could not set this track to gsm, so disable it
track[i].setEnabled(false);
}
}

// At this point, we have determined where we can send out
// gsm data or not.
// realize the processor
if (encodingOk) {
p.realize();
// block until realized.
// get the output datasource of the processor and exit
// if we fail
DataSource ds = null;

try {
ds = p.getDataOutput();
} catch (NotRealizedError e) {
System.exit(-1);
}

// hand this datasource to manager for creating an RTP
// datasink our RTP datasimnk will multicast the audio
try {
String url= "rtp://224.144.251.104:49150/audio/1";

MediaLocator m = new MediaLocator(url);

DataSink d = Manager.createDataSink(ds, m);

d.open();
d.start();
} catch (Exception e) {
System.exit(-1);
}
}

*/

}


aliaoz 2003-09-03
  • 打赏
  • 举报
回复
你下载一份jmf的api文档,上面有很清楚的例子。

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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