- 浏览: 127877 次
- 性别:
- 来自: 北京
最新评论
-
C_J:
有必要这么鸡冻咩?
编写自己的ClassLoader知识点 -
jason61719:
你这不是说了等于没说吗……就解析个loadClass(),谁不 ...
编写自己的ClassLoader知识点 -
jiming:
tedeyang 写道很好的改进,不过话说回来,mybatis ...
开源,从关注产品社区做起(ibatis3.x的最近一个issue展示) -
C_J:
独爱Java 写道好像实际用处并不是很大,只是多了解了有这个东 ...
Java内存模型笔记 -
独爱Java:
好像实际用处并不是很大,只是多了解了有这个东西而已。。。
Java内存模型笔记
1、简介
The JavaTM Media Framework (JMF) is an application programming interface (API) for incorporating media data such as audio and video into
Java applications and applets. It is specifically designed to take advantage of Java platform features.
这个框架是SUN公司出的,最新更新至2003年,用JMF来处理图像和音频设备并直接应用到JAVA应用程序中,虽然年代有点久远,但却还是可以用的。
The JMF 2.1.1 Reference Implementation supports SunVideo / SunVideoPlus capture devices on Solaris. On Windows, most capture devices
that have VFW drivers are supported. On Linux, devices that have a Video4Linux driver are expected to work, but not extensively tested.
今天小试了下,自己的laptop也有个摄像头,录制了一段视频到本地,第一次玩这个东西:)
2、模型
JMF的模型如下:
基本上是摄像头数据、文件数据、网络媒体流通过process输出到设备、文件或网络中。
Design Goals for JMF:
1、Be easy to program
2、Support capturing media data
3、Enable the development of media streaming and conferencing applications in Java
4、Enable advanced developers and technology providers to implement custom solutions based on the existing API and easily integrate new features with the existing framework
5、Provide access to raw media data
6、Enable the development of custom, downloadable demultiplexers, codecs, effects processors, multiplexers, and renderers (JMF plug-ins)
Design Goals for RTP:(RTP是JMF数据流在网络上的传输协议)
1、Enable the development of media streaming and conferencing applications in Java
2、Support media data reception and transmission using RTP and RTCP
3、Support custom packetizer and depacketizer plug-ins through the JMF 2.0 plug-in architecture.
4、Be easy to program
3、媒体数据展现
Streaming Media
媒体流,可以存储为多种文件格式或通过HTTP,RTP等协议传输在网络上。
Media Presentation
Most time-based media is audio or video data that can be presented through output devices such as speakers and monitors. Such devices are the
most common destination for media data output. Media streams can also be sent to other destinations--for example, saved to a file or transmitted
across the network. An output destination for media data is sometimes referred to as a data sink.
Media Data Storage and Transmission
A DataSink is used to read media data from a DataSource and render the media to some destination--generally a destination other
than a presentation device. A particular DataSink might write data to a file, write data across the network, or function as an RTP broadcaster.
DataSink用来做数据存储和传输。
开始presenting time-based media
Presenting Time-Based Media
To present time-based media such as audio or video with JMF, you use a Player. Playback can be controlled programmatically, or you can display a control-panel component that enables the user to control playback interactively. If you have several media streams that you want to play,
you need to use a separate Player for each one. to play them in sync, you can use one of the Player objects to control the operation of the others.
基本上是说播放实时多媒体需要用到Player,且每个单独的媒体需要单独的Player。
代码如下:
// create processor ProcessorModel processorModel = new ProcessorModel(mixedDataSource, outputFormat, outputType); // 创建model,类似JTable控件的 JModel,The ProcessorModel defines the input and output requirements for the Processor Processor processor = null; try { processor = Manager.createRealizedProcessor(processorModel);// 创建model,类似JTable控件的 JModel } catch (IOException e) { Stdout.logAndAbortException(e); } catch (NoProcessorException e) { Stdout.logAndAbortException(e); } catch (CannotRealizeException e) { Stdout.logAndAbortException(e); }
创建processor后,可以装进不同的compont里来present。
For example, you can call getControls to determine if a Player supports the CachingControl interface.
Control[] controls = player.getControls(); for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof CachingControl) { cachingControl = (CachingControl) controls[i]; } }
JMF提供了很多“播放器”,当然也提供了基本的控制,比如播放、停止以及播放信息等等。
控制产生事件。
Responding to Media Events
ControllerListener is an asynchronous interface for handling events generated by Controller objects.
for example:
if (event instanceof EventType){ ... } else if (event instanceof OtherEventType){ ... } if (event instanceof EventType){ ... } else if (event instanceof OtherEventType){ ... }
JMF提供ControllerAdapter:
player.addControllerListener(new ControllerAdapter() { public void endOfMedia(EndOfMediaEvent e) { Controller controller = e.getSource(); controller.stop(); controller.setMediaTime(new Time(0)); controller.deallocate(); } })
ControllerAdapter automatically dispatches the event to the appropriate event method, filtering out the events that you're not
interested in.自动为您分发事件并过滤不需要的事件。
There is a movie in Applet...展现到applet
import java.applet.*; import java.awt.*; import java.net.*; import javax.media.*; public class PlayerApplet extends Applet implements ControllerListener { Player player = null; public void init() { setLayout(new BorderLayout()); String mediaFile = getParameter("FILE"); try { URL mediaURL = new URL(getDocumentBase(), mediaFile); player = Manager.createPlayer(mediaURL); player.addControllerListener(this); } catch (Exception e) { System.err.println("Got exception "+e); } } public void start() { player.start(); } public void stop() { player.stop(); player.deallocate(); } public void destroy() { player.close(); } public synchronized void controllerUpdate(ControllerEvent event) { if (event instanceof RealizeCompleteEvent) { Component comp; if ((comp = player.getVisualComponent()) != null) add ("Center", comp); if ((comp = player.getControlPanelComponent()) != null) add ("South", comp); validate(); } } }
Presenting RTP Media Streams
Creating a Player for RTP session.
String url= "rtp://224.144.251.104:49150/audio/1"; MediaLocator mrl= new MediaLocator(url); if (mrl == null) { System.err.println("Can't build MRL for RTP"); return false; } // Create a player for this rtp session try { player = Manager.createPlayer(mrl); } catch (NoPlayerException e) { System.err.println("Error:" + e); return false; } catch (MalformedURLException e) { System.err.println("Error:" + e); return false; } catch (IOException e) { System.err.println("Error:" + e); return false; }
4、媒体数据处理
Converting Media Data from One Format to Another
你可以调整媒体的格式。
Specifying the Media Destination
你可以指定录像保存的方式,比如输出到文件, 输出到另一个player。
Saving captured media data to a file
DataSink sink; MediaLocator dest = new MediaLocator("file://newfile.wav"); try { sink = Manager.createDataSink(p.getDataOutput(), dest); sink.open(); sink.start(); } catch (Exception) {}
5、扩展JMF
Custom JMF plug-ins can be used seamlessly with Processors
that support the plug-in API. After you implement your plug-in, you need to install it and register it with the PlugInManager
to make it available to plug-in compatible Processors
.
Implementing a Codec or Effect Plug-In
Codec plug-ins are used to decode compressed media data, convert media data from one format to another, or encode raw media data into a compressed format.
用户可以自行扩展压缩格式,以及格式转换。
Implementing a Renderer Plug-In
It is a single-input processing component with no output. Renderer plug-ins read data from a DataSource and typically present the media data to the user, but can also be used to provide access to the processed media data for use by another application or device.
To make a custom plug-in available to a Processor through the TrackControl interface, you need to register it with the PlugInManager
// Name of the new plugin string GainPlugin = new String("COM.mybiz.media.GainEffect"); // Supported input Formats Format[] supportedInputFormats = new Format[] { new AudioFormat( AudioFormat.LINEAR, Format.NOT_SPECIFIED, 16, Format.NOT_SPECIFIED, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED, 16, Format.NOT_SPECIFIED, Format.byteArray ) }; // Supported output Formats Format[] supportedOutputFormats = new Format[] { new AudioFormat( AudioFormat.LINEAR, Format.NOT_SPECIFIED, 16, Format.NOT_SPECIFIED, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED, 16, Format.NOT_SPECIFIED, Format.byteArray ) }; // Add the new plug-in to the plug-in registry PlugInManager.addPlugIn(GainPlugin, supportedInputFormats, supportedOutputFormats, EFFECT); // Save the changes to the plug-in registry PlugInManager.commit();
Implementing a Protocol Data Source
A DataSource is an abstraction of a media protocol-handler. You can implement new types of DataSources to support additional protocols by extending PullDataSource,
Implementing a DataSink
JMF provides a default DataSink that can be used to write data to a file. Other types of DataSink classes can be implemented to facilitate writing data to the network or to other destinations.
6、事例代码
this test program will capture the video and audio stream from your USB camera for 10 seconds and stores it on a file, named "testcam.avi".
发表评论
-
iOS入门(ongoing)
2012-09-13 11:32 1301Record it: The overview of ... -
Stuff about Android
2011-07-09 16:15 1065Foreword: long time ... -
JQuery初体验(Demo)
2011-05-22 13:43 1458Demo:Show <meta content ... -
Java内存模型笔记
2011-04-13 15:48 1538题记: 看到C/C++ ... -
Radiant_The Popular Ruby's CMS Demo篇
2011-04-02 14:49 1241题记: 上篇 记录我第一次安装Rodiant经过和 ... -
Radiant_The Popular Ruby’s CMS安装篇
2011-03-28 00:48 1278题记: 今天第一次参加JE的线下活动,robbin等 ... -
关于Azul 并发垃圾回收器
2011-03-26 14:40 1317题记: 总感觉JE讨论的帖子的东西都比较滞后,所以会 ... -
phpCMS & jQuery是我该做的(阉割了)
2011-02-27 23:02 81WD讲究以plugin挂载为结构,我需要构造一个p ... -
我的玩意:J2ME的Criteria初探
2011-01-20 21:59 1019题记: 前几天跟初中同学聊天,他问我能不能做一个GP ... -
编写自己的ClassLoader知识点
2011-01-13 14:41 1871题记: 看到InfoQ关于ClassLoader的文 ... -
周末好玩,用短信控制你的计算机
2011-01-10 16:34 2986Snapshot: 详情 ... -
About Dock Plugin on Mac
2010-11-21 22:47 1462题记: 第一次接触MAC的开发..... ... -
可变hashcode的隐患和序列化安全
2010-10-25 00:55 1369可变hashcode的隐患 为识别对象,JDK ... -
体验OSGi(helloworld.jar)—富app的热拔插
2010-10-18 23:22 2436记得以前工作的时候,有天direct manager问 ... -
MongoDB on DAO with Java Language
2010-08-26 19:17 1425A Quick Tour Using the Java d ... -
Getting Start on Mongodb
2010-08-26 01:29 1504题记: 最近老和同学聊到non-relational ... -
从WeakLogHandler应用看Java的引用、引用队列
2010-06-14 00:58 1499题记: 前几天讨论到WeakHashMap(这个是个弱引用的 ... -
《重构》读书笔记
2010-05-09 00:05 1045Martin Fowler于2003年出版 ... -
RPC之WebServices&RMI&JMS,phprpc框架?(待续)
2010-05-06 22:31 55前段时间写过基本的WebServices,也没再做深入 ... -
Java应用中的SQL注入攻击和防范
2010-04-24 01:06 6713说说自己对注入的 ...
相关推荐
个人整理的Java Media Framework API (JMF)的API,按Java6 API的风格整理
Java Media Framework(JMF)API指南是一份详细阐述如何在Java平台上处理多媒体内容的重要文档。这份PDF指南旨在帮助开发者理解并有效地利用JMF来开发多媒体应用程序,如播放、捕获、处理音频和视频数据。以下是关于...
Java Media Framework (JMF) 是一个Java平台上的多媒体处理API,它允许开发者处理各种媒体类型,包括音频和视频。本文档是一份基础教程,由Eric Olson撰写并由pawenwen业余时间翻译,旨在为初学者提供JMF的入门知识...
### Java Media Framework (JMF) 简介 Java Media Framework(简称JMF)是Sun Microsystems为Java平台提供的一套多媒体框架,它使得开发者能够轻松地处理音频、视频和其他形式的流媒体数据。JMF提供了丰富的API接口...
Java Media Framework(JMF)是Java平台上的一个多媒体处理框架,它允许开发者处理音频、视频以及复杂的媒体流。本教程将带你深入理解JMF的基本概念、工作原理以及如何在实际项目中应用它。 JMF的核心功能包括播放...
Java Media Framework(JMF)是Java平台上用于处理多媒体数据的核心框架。这个2.1.1e版本是一个较早但仍然广泛使用的发行版,主要用于开发能够播放、捕获、处理和控制音频、视频以及其它时间同步媒体的应用程序。...
在Java Swing中,我们可以通过Java Media Framework (JMF) 或者更现代的JavaFX来实现调用本地摄像头的功能。下面将详细介绍如何在Java Swing应用中实现这一功能。 首先,让我们了解Java Media Framework (JMF)。JMF...
Java 媒体框架(Java Media Framework,JMF)是Java平台上的一个核心API,用于处理多媒体数据,如音频、视频等。这个框架允许开发者创建能够播放、捕获、控制和处理多种媒体格式的应用程序。JMF提供了一个灵活的架构...
根据2013年7月最新文档制作自用,为备份共享。
在Java中,通过Java Media Framework (JMF) 或者 JavaFX 可以实现对电脑摄像头的调用。下面将详细介绍这两个技术以及Spring框架在项目中的应用。 Java Media Framework (JMF) 是Java平台上的多媒体处理框架,它提供...
JMF(java media framework)帮助文档
### Java Media Framework (JMF) 基础教程概述 #### 一、关于本教程 本教程主要介绍Java Media Framework(简称JMF),这是一款功能强大且多用途的应用程序编程接口(API),允许Java开发者以多种方式处理媒体数据...
Java Media Framework (JMF) API 指南是Java开发者在处理多媒体内容时的重要参考资料。JMF 是一个可扩展的平台,用于播放、捕获、处理和操纵音频、视频和其他时间同步的数据流。这个API提供了丰富的功能,使得开发...
然而,JavaDCP并不是标准的Java库,因此在实际项目中,我们通常会依赖第三方库,如Java Media Framework (JMF) 或 OpenIMAJ。 1. **Java Media Framework (JMF)**:JMF是一个开源框架,它为音频、视频和流媒体的...
### Java Media Framework (JMF) 指南 #### 关于 JMF Java Media Framework (JMF) 是一个用于处理时间基媒体(如音频、视频)的开发平台。它为开发者提供了一套全面且强大的 API 来进行媒体的捕获、处理、存储以及...
Java摄像头拍照程序是一种利用Java Media Framework (JMF) 或者其他相关库来访问并操作电脑摄像头,实现拍照功能的应用。JMF是Java平台上的多媒体框架,允许开发者处理音频、视频和流媒体数据。在这个程序中,我们将...
Java中可以使用开源库如Xuggler或者JMF(Java Media Framework)来处理这些视频流。 在给定的文件列表中,“DHTest.rar”可能是大华提供的SDK或者示例代码,而“java封装接口智能交通DEMO.zip”很可能是包含了Java...