JMF video streaming

Hi all,
I want to use JMF video streaming api but I have no idea how to do it.
I want to create several "agents" where each agent streams a single video to a certain ip address . (actually i want each agent to stream to the same computer)
I want in my application (not the agents applications) to capture each of these streams and display each of them seperately.
How can this be achieved with JMF ?
thx.

no one ????

Similar Messages

  • JMF Video Stream via Jxta

    Hi all,
    i want to Stream live video and audio from a webcam device.
    I got an mixedDatasource and can display it.
    now my question: if it is possible to stream a infinity large PushBufferDataSource via Jxta (Peer to Peer)?
    Here my code:
              Format formats[]=new Format[2];
              formats[0]=new VideoFormat(VideoFormat.YUV);
              formats[1]=new AudioFormat(AudioFormat.LINEAR);
              Processor proz=null;
              ProcessorModel mod=new ProcessorModel(mixedDataSource,formats,new ContentDescriptor(ContentDescriptor.RAW));
              try {
                   proz=Manager.createRealizedProcessor(mod);
              } catch (Exception e) {               
                   e.printStackTrace();
                   System.exit(-1);
              proz.start();
              PushBufferDataSource ds=(PushBufferDataSource)proz.getDataOutput();
              try {
                   ds.connect();
              } catch (IOException e) {               
                   e.printStackTrace();
              }thanks for any suggestions
    Greetz

    s its possible. we made project i made it . if u want sourcencode mail me to sivaitvlr@gmail,com

  • JMF Video Stream

    I'm transmiting my webcam video to another computer via VideoTransmit.java. But when i'm sending my webcam video, at the same time i want to display my video on my computer too. How can i do that?
    import java.awt.*;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import java.io.*;
    public class VideoTransmit {
        // Input MediaLocator
        // Can be a file or http or capture source
        private MediaLocator locator;
        private String ipAddress;
        private String port;
        private Processor processor = null;
        private DataSink  rtptransmitter = null;
        private DataSource dataOutput = null;
        public VideoTransmit(MediaLocator locator,
                    String ipAddress,
                    String port) {
         this.locator = locator;
         this.ipAddress = ipAddress;
         this.port = port;
         * Starts the transmission. Returns null if transmission started ok.
         * Otherwise it returns a string with the reason why the setup failed.
        public synchronized String start() {
         String result;
         // Create a processor for the specified media locator
         // and program it to output JPEG/RTP
         result = createProcessor();
         if (result != null)
             return result;
         // Create an RTP session to transmit the output of the
         // processor to the specified IP address and port no.
         result = createTransmitter();
         if (result != null) {
             processor.close();
             processor = null;
             return result;
         // Start the transmission
         processor.start();
         return null;
         * Stops the transmission if already started
        public void stop() {
         synchronized (this) {
             if (processor != null) {
              processor.stop();
              processor.close();
              processor = null;
              rtptransmitter.close();
              rtptransmitter = null;
        private String createProcessor() {
         if (locator == null)
             return "Locator is null";
         DataSource ds;
         DataSource clone;
         try {
             ds = Manager.createDataSource(locator);
         } catch (Exception e) {
             return "Couldn't create DataSource";
         // Try to create a processor to handle the input media locator
         try {
             processor = Manager.createProcessor(ds);
         } catch (NoProcessorException npe) {
             return "Couldn't create processor";
         } catch (IOException ioe) {
             return "IOException creating processor";
         // Wait for it to configure
         boolean result = waitForState(processor, Processor.Configured);
         if (result == false)
             return "Couldn't configure processor";
         // Get the tracks from the processor
         TrackControl [] tracks = processor.getTrackControls();
         // Do we have atleast one track?
         if (tracks == null || tracks.length < 1)
             return "Couldn't find tracks in processor";
         boolean programmed = false;
         // Search through the tracks for a video track
         for (int i = 0; i < tracks.length; i++) {
             Format format = tracks.getFormat();
         if ( tracks[i].isEnabled() &&
              format instanceof VideoFormat &&
              !programmed) {
              // Found a video track. Try to program it to output JPEG/RTP
              // Make sure the sizes are multiple of 8's.
              Dimension size = ((VideoFormat)format).getSize();
              float frameRate = ((VideoFormat)format).getFrameRate();
              int w = (size.width % 8 == 0 ? size.width :
                        (int)(size.width / 8) * 8);
              int h = (size.height % 8 == 0 ? size.height :
                        (int)(size.height / 8) * 8);
              VideoFormat jpegFormat = new VideoFormat(VideoFormat.JPEG_RTP,
                                       new Dimension(w, h),
                                       Format.NOT_SPECIFIED,
                                       Format.byteArray,
                                       frameRate);
              tracks[i].setFormat(jpegFormat);
              System.err.println("Video transmitted as:");
              System.err.println(" " + jpegFormat);
              // Assume succesful
              programmed = true;
         } else
              tracks[i].setEnabled(false);
         if (!programmed)
         return "Couldn't find video track";
         // Set the output content descriptor to RAW_RTP
         ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
         processor.setContentDescriptor(cd);
         // Realize the processor. This will internally create a flow
         // graph and attempt to create an output datasource for JPEG/RTP
         // video frames.
         result = waitForState(processor, Controller.Realized);
         if (result == false)
         return "Couldn't realize processor";
         // Set the JPEG quality to .5.
         setJPEGQuality(processor, 0.5f);
         // Get the output data source of the processor
         dataOutput = processor.getDataOutput();
         return null;
    // Creates an RTP transmit data sink. This is the easiest way to create
    // an RTP transmitter. The other way is to use the RTPSessionManager API.
    // Using an RTP session manager gives you more control if you wish to
    // fine tune your transmission and set other parameters.
    private String createTransmitter() {
         // Create a media locator for the RTP data sink.
         // For example:
         // rtp://129.130.131.132:42050/video
         String rtpURL = "rtp://" + ipAddress + ":" + port + "/video";
         MediaLocator outputLocator = new MediaLocator(rtpURL);
         // Create a data sink, open it and start transmission. It will wait
         // for the processor to start sending data. So we need to start the
         // output data source of the processor. We also need to start the
         // processor itself, which is done after this method returns.
         try {
         rtptransmitter = Manager.createDataSink(dataOutput, outputLocator);
         rtptransmitter.open();
         rtptransmitter.start();
         dataOutput.start();
         } catch (MediaException me) {
         return "Couldn't create RTP data sink";
         } catch (IOException ioe) {
         return "Couldn't create RTP data sink";
         return null;
    * Setting the encoding quality to the specified value on the JPEG encoder.
    * 0.5 is a good default.
    void setJPEGQuality(Player p, float val) {
         Control cs[] = p.getControls();
         QualityControl qc = null;
         VideoFormat jpegFmt = new VideoFormat(VideoFormat.JPEG);
         // Loop through the controls to find the Quality control for
         // the JPEG encoder.
         for (int i = 0; i < cs.length; i++) {
         if (cs[i] instanceof QualityControl &&
              cs[i] instanceof Owned) {
              Object owner = ((Owned)cs[i]).getOwner();
              // Check to see if the owner is a Codec.
              // Then check for the output format.
              if (owner instanceof Codec) {
              Format fmts[] = ((Codec)owner).getSupportedOutputFormats(null);
              for (int j = 0; j < fmts.length; j++) {
                   if (fmts[j].matches(jpegFmt)) {
                   qc = (QualityControl)cs[i];
                   qc.setQuality(val);
                   System.err.println("- Setting quality to " +
                             val + " on " + qc);
                   break;
              if (qc != null)
              break;
    * Convenience methods to handle processor's state changes.
    private Integer stateLock = new Integer(0);
    private boolean failed = false;
    Integer getStateLock() {
         return stateLock;
    void setFailed() {
         failed = true;
    private synchronized boolean waitForState(Processor p, int state) {
         p.addControllerListener(new StateListener());
         failed = false;
         // Call the required method on the processor
         if (state == Processor.Configured) {
         p.configure();
         } else if (state == Processor.Realized) {
         p.realize();
         // Wait until we get an event that confirms the
         // success of the method, or a failure event.
         // See StateListener inner class
         while (p.getState() < state && !failed) {
         synchronized (getStateLock()) {
              try {
              getStateLock().wait();
              } catch (InterruptedException ie) {
              return false;
         if (failed)
         return false;
         else
         return true;
    * Inner Classes
    class StateListener implements ControllerListener {
         public void controllerUpdate(ControllerEvent ce) {
         // If there was an error during configure or
         // realize, the processor will be closed
         if (ce instanceof ControllerClosedEvent)
              setFailed();
         // All controller events, send a notification
         // to the waiting thread in waitForState method.
         if (ce instanceof ControllerEvent) {
              synchronized (getStateLock()) {
              getStateLock().notifyAll();
    * Sample Usage for VideoTransmit class
    public static void main(String [] args) {
         // We need three parameters to do the transmission
         // For example,
         // java VideoTransmit file:/C:/media/test.mov 129.130.131.132 42050
         if (args.length < 3) {
         System.err.println("Usage: VideoTransmit <sourceURL> <destIP> <destPort>");
         System.exit(-1);
         // Create a video transmit object with the specified params.
         VideoTransmit vt = new VideoTransmit(new MediaLocator(args[0]),
                             args[1],
                             args[2]);
         // Start the transmission
         String result = vt.start();
         // result will be non-null if there was an error. The return
         // value is a String describing the possible error. Print it.
         if (result != null) {
         System.err.println("Error : " + result);
         System.exit(0);
         System.err.println("Start transmission for 60 seconds...");
         // Transmit for 60 seconds and then close the processor
         // This is a safeguard when using a capture data source
         // so that the capture device will be properly released
         // before quitting.
         // The right thing to do would be to have a GUI with a
         // "Stop" button that would call stop on VideoTransmit
         try {
         Thread.currentThread().sleep(60000);
         } catch (InterruptedException ie) {
         // Stop the transmission
         vt.stop();
         System.err.println("...transmission ended.");
         System.exit(0);
    }Edited by: [email protected] on Dec 24, 2007 9:32 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    s its possible. we made project i made it . if u want sourcencode mail me to sivaitvlr@gmail,com

  • P2p video streaming using jmf (is it possible to "forward" the stream ?)

    Hello
    In my project a peer will start streaming captured video from the webcam to his neighbors and then his neighbors will have to display the video and forward(stream) it to their neighbors and so on . So my question is can i do this using jmf , a simple scenario will be : peer_1 streams to peeer_2 and then peer_2 to forward(stream) the video received from peer_1 to peer_3 .
    I've read the jmf2_0 guide and i've seen that it's only possible to stream from a server to a client and that's about it , but i want also the client to pass the stream forward to another client ... like for example [http://img72.imageshack.us/img72/593/p2pjmf.gif|http://img72.imageshack.us/img72/593/p2pjmf.gif]
    I want to know at least if this it's possible with jmf or should i start looking for another solution ? and do you have any examples of such projects or examples of forwarding the stream with jmf ....
    thanks for any suggestions

    _Cris_ wrote:
    I want to know at least if this it's possible with jmf or should i start looking for another solution ? and do you have any examples of such projects or examples of forwarding the stream with jmf .... You can do what with JMF. Once you receive the stream, it's just a video stream. You can do anything you want with it...display it, record it, or send it as an RTP stream.

  • Advantages of JMF in video streaming

    Hi,
    Video conferencing can be done by many methods but why JMF is used for video/audio streaming
    what are its advantages? and Also what are its disadvantages?
    Is there any other better way to do video conferencing ?
    Please give details regarding the current scenario of JMF in video streaming.
    thanx

    Video conferencing can be done by many methods but why JMF is used for video/audio streaming
    what are its advantages?It has RTP built-in, handles a handful of the most basic codecs, there is decent documentation for it...is written in Java... easily extendible for new codec support...
    what are its disadvantages? It hasn't been updated or supported in 7 years... Windows 2000 was the last supported operating system... has bugs which will never be fixed... only supports a handful of low-bandwidth formats for streaming...
    Is there any other better way to do video conferencing ? Yeah, tons...the best alternative right now would probably be with Adobe Flex technology, but JavaFX and Silverlight will both have audio & video capturing / streaming capabilities soon...

  • Capturing Video stream with JMF under LINUX??

    Ok, i am confused! I have read lots of info over this subject, but at some sites and forums i read that some people did not succeed in capturing ( and displaying) a live video stream with Java under Linux.
    Is it possible? and if so, can someone give me a sample code or a link to a sample code? thankz a lot!!

    Cross-posted
    http://forum.java.sun.com/post.jsp?forum=54&thread=456420&message=2083138&reply=true

  • CTD bug in simple video streaming applet.

    I'm trying to write a simple applet to use JMF to allow an end-user to view a video stream that's being served up by VLC. It doesn't have to look immensely pretty (in fact, streamlined is what I want most). I swiped some code from the jicyshout project (http://jicyshout.sourceforge.net) which handles streaming MP3s, and borrowed a framework for an applet from one of Sun's example applets for the JMF.
    Here's my code so far:
    ** begin file SimpleVideoDataSource.java **
    import java.lang.String;
    import java.net.*;
    import java.io.*;
    import java.util.Properties;
    import javax.media.*;
    import javax.media.protocol.*;
    /* The SeekableStream and DataSource tweaks are based on the code from
    * jicyshout (jicyshout.sourcefourge.net), which was written by Chris Adamson.
    * The code was simplified (no need for mp3 metadata here), cleaned up, then
    * extended for our puposes.
    * This is a DataSource using a SeekableStream suitable for
    * streaming video using the default parser supplied by JMF.
    public class SimpleVideoDataSource extends PullDataSource {
    protected MediaLocator myML;
    protected SeekableInputStream[] seekStreams;
    protected URLConnection urlConnection;
    // Constructor (trivial).
    public SimpleVideoDataSource (MediaLocator ml) throws MalformedURLException {
    super ();
    myML = ml;
    URL url = ml.getURL();
    public void connect () throws IOException {
    try {
    URL url = myML.getURL();
    urlConnection = url.openConnection();
    // Make the stream seekable, so that the JMF parser can try to parse it (instead
    // of throwing up).
    InputStream videoStream = urlConnection.getInputStream();
    seekStreams = new SeekableInputStream[1];
    seekStreams[0] = new SeekableInputStream(videoStream);
    } catch (MalformedURLException murle) {
    throw new IOException ("Malformed URL: " + murle.getMessage());
    } catch (ArrayIndexOutOfBoundsException aioobe) {
    fatalError("Array Index OOB: " + aioobe);
    // Closes up InputStream.
    public void disconnect () {
    try {
    seekStreams[0].close();
    } catch (IOException ioe) {
    System.out.println ("Can't close stream. Ew?");
    ioe.printStackTrace();
    // Returns just what it says.
    public String getContentType () {
    return "video.mpeg";
    // Does nothing, since this is a stream pulled from PullSourceStream.
    public void start () {
    // Ditto.
    public void stop () {
    // Returns a one-member array with the SeekableInputStream.
    public PullSourceStream[] getStreams () {
    try {
    // **** This seems to be the problem. ****
    if (seekStreams != null) {
    return seekStreams;
    } else {
    fatalError("sourceStreams was null! Bad kitty!");
    return seekStreams;
    } catch (Exception e) {
    fatalError("Error in getStreams(): " + e);
    return seekStreams;
    // Duration abstract stuff. Since this is a theoretically endless stream...
    public Time getDuration () {
    return DataSource.DURATION_UNBOUNDED;
    // Controls abstract stuff. No controls supported here!
    public Object getControl (String controlName) {
    return null;
    public Object[] getControls () {
    return null;
    void fatalError (String deathKnell) {
    System.err.println(":[ Fatal Error ]: - " + deathKnell);
    throw new Error(deathKnell);
    ** end file SimpleVideoDataSource.java **
    ** begin file SeekableInputStream.java **
    import java.lang.String;
    import java.net.*;
    import java.io.*;
    import java.util.Properties;
    import javax.media.*;
    import javax.media.protocol.*;
    /* The SeekableStream and DataSource tweaks are based on the code from
    * jicyshout (jicyshout.sourcefourge.net), which was written by Chris Adamson.
    * The code was simplified (no need for mp3 metadata here), cleaned up, then
    * extended for our puposes.
    /* This is an implementation of a SeekableStream which extends a
    * BufferedInputStream to basically fake JMF into thinking that
    * the stream is seekable, when in fact it's not. Basically, this
    * will keep JMF from puking over something it expects but can't
    * actually get.
    public class SeekableInputStream extends BufferedInputStream implements PullSourceStream, Seekable {
    protected int tellPoint;
    public final static int MAX_MARK = 131072; // Give JMF 128k of data to "play" with.
    protected ContentDescriptor unknownCD;
    // Constructor. Effectively trivial.
    public SeekableInputStream (InputStream in) {
    super (in, MAX_MARK);
    tellPoint = 0;
    mark (MAX_MARK);
    unknownCD = new ContentDescriptor ("unknown");
    // Specified size constructor.
    public SeekableInputStream (InputStream in, int size) {
    super (in, Math.max(size, MAX_MARK));
    tellPoint = 0;
    mark(Math.max(size, MAX_MARK));
    unknownCD = new ContentDescriptor ("unknown");
    // Reads a byte and increments tellPoint.
    public int read () throws IOException {
    int readByte = super.read();
    tellPoint++;
    return readByte;
    // Reads bytes (specified by PullSourceStream).
    public int read (byte[] buf, int off, int len) throws IOException {
    int bytesRead = super.read (buf, off, len);
    tellPoint += bytesRead;
    return bytesRead;
    public int read (byte[] buf) throws IOException {
    int bytesRead = super.read (buf);
    tellPoint += bytesRead;
    return bytesRead;
    // Returns true if in.available() <= 0 (that is, if there are no bytes to
    // read without blocking or end-of-stream).
    public boolean willReadBlock () {
    try {
    return (in.available() <= 0);
    } catch (IOException ioe) {
    // Stick a fork in it...
    return true;
    // Resets the tellPoint to 0 (meaningless after you've read one buffer length).
    public void reset () throws IOException {
    super.reset();
    tellPoint = 0;
    // Skips bytes as expected.
    public long skip (long n) throws IOException {
    long skipped = super.skip(n);
    tellPoint += skipped;
    return skipped;
    // Trivial.
    public void mark (int readLimit) {
    super.mark (readLimit);
    // Returns the "unknown" ContentDescriptor.
    public ContentDescriptor getContentDescriptor () {
    return unknownCD;
    // Lengths? We don't need no stinkin' lengths!
    public long getContentLength () {
    return SourceStream.LENGTH_UNKNOWN;
    // Theoretically, this is always false.
    public boolean endOfStream () {
    return false;
    // We don't provide any controls, either.
    public Object getControl (String controlName) {
    return null;
    public Object[] getControls () {
    return null;
    // Not really... but...
    public boolean isRandomAccess () {
    return true;
    // This only works for the first bits of the stream, while JMF is attempting
    // to figure out what the stream is. If it tries to seek after that, bad
    // things are going to happen (invalid-mark exception).
    public long seek (long where) {
    try {
    reset();
    mark(MAX_MARK);
    skip(where);
    } catch (IOException ioe) {
    ioe.printStackTrace();
    return tell();
    // Tells where in the stream we are, adjusted for seeks, resets, skips, etc.
    public long tell () {
    return tellPoint;
    void fatalError (String deathKnell) {
    System.err.println(":[ Fatal Error ]: - " + deathKnell);
    throw new Error(deathKnell);
    ** end file SeekableInputStream.java **
    ** begin file StreamingViewerApplet.java **
    * This Java Applet will take a streaming video passed to it via the applet
    * command in the embedded object and attempt to play it. No fuss, no muss.
    * Based on the SimplePlayerApplet from Sun, and uses a modified version of
    * jicyshout's (jicyshout.sourceforge.net) tweaks to get JMF to play streams.
    * Use it like this:
    * <!-- Sample HTML
    * <APPLET CODE="StreamingViewerApplet.class" WIDTH="320" HEIGHT="240">
    * <PARAM NAME="code" VALUE="StreamingViewerApplet.class">
    * <PARAM NAME="type" VALUE="application/x-java-applet;version=1.1">
    * <PARAM NAME="streamwidth" VALUE="width (defaults to 320, but will resize as per video size)">
    * <PARAM NAME="streamheight" VALUE="height (defaults to 240, but will resize as per video size)">
    * <PARAM NAME="stream" VALUE="insert://your.stream.address.and:port/here/">
    * </APPLET>
    * -->
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.String;
    import java.lang.ArrayIndexOutOfBoundsException;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.net.*;
    import java.io.*;
    import java.io.IOException;
    import java.util.Properties;
    import javax.media.*;
    import javax.media.protocol.*;
    public class StreamingViewerApplet extends Applet implements ControllerListener {
    Player player = null;
    Component visualComponent = null;
    SimpleVideoDataSource dataSource;
    URL url;
    MediaLocator ml;
    Panel panel = null;
    int width = 0;
    static int DEFAULT_VIDEO_WIDTH = 320;
    int height = 0;
    static int DEFAULT_VIDEO_HEIGHT = 240;
    String readParameter = null;
    // Initialize applet, read parameters, create media player.
    public void init () {
    try {
    setLayout(null);
    setBackground(Color.white);
    panel = new Panel();
    panel.setLayout(null);
    add(panel);
    // Attempt to read width from applet parameters. If not given, use default.
    if ((readParameter = getParameter("streamwidth")) == null) {
    width = DEFAULT_VIDEO_WIDTH;
    } else {
    width = Integer.parseInt(readParameter);
    // Ditto for height.
    if ((readParameter = getParameter("streamheight")) == null) {
    height = DEFAULT_VIDEO_HEIGHT;
    } else {
    height = Integer.parseInt(readParameter);
    panel.setBounds(0, 0, width, height);
    // Unfortunately, this we can't default.
    if ((readParameter = getParameter("stream")) == null) {
    fatalError("You must provide a stream parameter!");
    try {
    url = new URL(readParameter);
    ml = new MediaLocator(url);
    dataSource = new SimpleVideoDataSource(ml);
    } catch (MalformedURLException murle) {
    fatalError("Malformed URL Exception: " + murle);
    try {
    dataSource.connect();
    player = Manager.createPlayer(dataSource);
    } catch (IOException ioe) {
    fatalError("IO Exception: " + ioe);
    } catch (NoPlayerException npe) {
    fatalError("No Player Exception: " + npe);
    if (player != null) {
    player.addControllerListener(this);
    } else {
    fatalError("Failed to init() player!");
    } catch (Exception e) {
    fatalError("Error opening player. Details: " + e);
    // Start stream playback. This function is called the
    // first time that the applet runs, and every time the user
    // re-enters the page.
    public void start () {
    try {
    if (player != null) {
    player.realize();
    while (player.getState() != Controller.Realized) {
    Thread.sleep(100);
    // Crashes... here?
    player.start();
    } catch (Exception e) {
    fatalError("Exception thrown: " + e);
    public void stop () {
    if (player != null) {
    player.stop();
    player.deallocate();
    } else {
    fatalError("stop() called on a null player!");
    public void destroy () {
    // player.close();
    // This controllerUpdate function is defined to implement a ControllerListener
    // interface. It will be called whenever there is a media event.
    public synchronized void controllerUpdate(ControllerEvent event) {
    // If the player is dead, just leave.
    if (player == null)
    return;
    // When the player is Realized, get the visual component and add it to the Applet.
    if (event instanceof RealizeCompleteEvent) {
    if (visualComponent == null) {
    if ((visualComponent = player.getVisualComponent()) != null) {
    panel.add(visualComponent);
    Dimension videoSize = visualComponent.getPreferredSize();
    width = videoSize.width;
    height = videoSize.height;
    visualComponent.setBounds(0, 0, width, height);
    } else if (event instanceof CachingControlEvent) {
    // With streaming, this doesn't really matter much, does it?
    // Without, a progress bar of some sort would be appropriate.
    } else if (event instanceof EndOfMediaEvent) {
    // We should never see this... but...
    player.stop();
    fatalError("EndOfMediaEvent reached for streaming media. ewe ewe tea eff?");
    } else if (event instanceof ControllerErrorEvent) {
    player = null;
    fatalError(((ControllerErrorEvent)event).getMessage());
    } else if (event instanceof ControllerClosedEvent) {
    panel.removeAll();
    void fatalError (String deathKnell) {
    System.err.println(":[ Fatal Error ]: - " + deathKnell);
    throw new Error(deathKnell);
    ** end file StreamingViewerApplet.java **
    Now, I'm still new to the JMF, so this might be obvious to some of you... but it's exploding on me, and crashing to desktop (both in IE and Firefox) with some very fun errors:
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x21217921, pid=3200, tid=3160
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
    # Problematic frame:
    # C 0x21217921
    --------------- T H R E A D ---------------
    Current thread (0x058f7280): JavaThread "JMF thread: com.sun.media.amovie.AMController@506411[ com.sun.media.amovie.AMController@506411 ] ( realizeThread)" [_thread_in_native, id=3160]
    siginfo: ExceptionCode=0xc0000005, writing address 0x034e6360
    (plenty more here, I can post the rest if necessary)
    The problem seems to be coming from the "return seekStreams" statement in the first file; when I have execution aborted before that (with a fatalError call), it doesn't crash.
    Any tips/hints/suggestions?

    You should write your own Applet, where you can easily get the visual component (getVisualComponent())and show it directly in your Applet (you call it "embedded"). As far as I know, all examples (AVReceive* etc.) use the component which opens a new window.
    Best regards from Germany,
    r.v.

  • JMF with streaming server like darwin

    Hi all
    I need to know are there any JMF plugin or API to communicate with darwing streaming server or any other RTSP support streaming server?
    I'm on project of video streaming over network
    I was able do the capturing of video using a web cam and streaming using RTP, since JMF support to server side RTP does not RTSP. So I want to know are there any java plugin for darwin streaming server which support RTSP?Thank You

    JMF supports RTSP out of the box.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/support-rtsp.html]

  • Java Video Streaming

    Hello
    I try to get an overview of what's possible according to video streaming in sun's wonderland. The goal is to stream prerecorded videos, stored on a webserver (not necessarily on the same machine like the wl-server ) into our wonderland embedded swing application.
    My first investigation shows me, that I have the following possibilities to stream videos in Java:
    - Java Media Framework (JMF)
    - JVLC (VideoLAN Java API)
    - Quicktime Streaming API (only quicktime movies)
    -> http://www.onjava.com/pub/a/onjava/2005/01/12/strmng_qtj.html
    - Red5 Java Client (only flash movies):
    -> http://www.actionscript.org/resources/articles/617/1/Streaming-and-database-connection-with-red5-media-server/Page1.html
    - Mplayer Java Client:
    -> http://beradrian.wordpress.com/2008/01/30/jmplayer/
    So what do you suggest me? What's the best way? Are there any code-examples for streaming videos from a webserver to a local java-client using JMF?
    Thanks for your help.
    Kind regards,
    Peter
    Edited by: blood_on_ice on Mar 23, 2009 12:44 AM

    Thanks for your answer...
    >
    The "best" way? Considering you're using a Swing application, your best bet is probably going to be JMF. JavaFX has support for playing videos, but I'm not sure if they have support for RTP streams or progressive downloads or anything.
    If you wanted to go the extra mile, you could look into embedding a Silverlight or Flash player into your Swing application. Silverlight is pretty cool because it's HD capable...>
    Yes I have to develop the video streaming in a swing non-top-level Swing JComponent (such as a JPanel) because this is a wonderland restriction...I don't know JavaFX yet, is it possible to build a JavaFX app inside such a non-top-level Swing component? Embedding silverlight in a java-app isn't a really good idea I think...
    Further recherches shows me, that I need on-demand video streaming with the ability to start, stop, play, pause etc. the video which is stored for example on a webserver. This is possible throught RTSP or HTTP according to: [http://www.remlab.net/op/vod.shtml|http://www.remlab.net/op/vod.shtml] ...when I use rtsp, I need a streaming-server like vlc, for http i just need my video stored on a webserver.
    So what do I have for possibilities to stream such a video in a java client (non-top-level Swing JComponent) with RTSP or HTTP?
    I've tried following rtp-code-example: [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVReceive.html|http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVReceive.html]
    but it didn't work...I started my vlc-streaming server this way:
    cvlc -vvv movie.mpg --sout '#rtp{dst=192.168.1.33,port=1234,sdp=http://localhost:8080}'but the output of the rtp-code-example shows the following:
    run:
    - Open RTP session for: addr: 127.0.0.1 port: 8080 ttl: 1
      - Waiting for RTP data to arrive...
      - Waiting for RTP data to arrive...
      - Waiting for RTP data to arrive...
      - Waiting for RTP data to arrive...
      - Waiting for RTP data to arrive...
    With vlc http://127.0.0.1:8080 i receive the stream...
    But I couldn't find an example of how I can get an rtsp-stream or a http-stream in jmf...
    Thanks for your help.
    Kind regards,
    Peter
    Edited by: blood_on_ice on Mar 23, 2009 8:59 AM
    Edited by: blood_on_ice on Mar 23, 2009 9:00 AM

  • Finding a java video streaming player

    I recently use FreePastry to implement a p2p video streaming system.
    But now i have a new challege, which bother me several days.
    In Splitstream, which uses Byte[] to send the data to other peer.
    I want find a java video player. It would be best to receive Byte[] as input.
    I try JMF, but it use RTP as the input.
    Is there any other video players suited about my case.

    There is a function in LiveStream.java called read. Read passes in a buffer object. The goal is to write all of the data you have available into the buffer object.
    What you want to do is something along the lines of the following pseudocode...
    public void read(Buffer buffer) throws IOException {
        synchronized (this) {
            /* Get the data */
            byte[] data = FunctionThatGetsByteArrayFromTheNetwork();
            /* Write the data to the buffer object */
            buffer.setData(data);
    }As for using the PushBufferDataSource, you just create one like you would a normal class (just use the new operator) and give it to a processor or a player like you would a normal data source.
    You need to include the DataSource.java code like the example does, modify it to use your modified LiveStream.java (you'll probably change the names of classes, so update the DataSource.java class to reflect those changes) and then just use it to create your DataSource.
        /* From DataSource.java */
        DataSource ds = new DataSource();
        /* Normal way of doing this */
        Processor p = Manager.createProcessor(ds);

  • Windows Media Player & Video Streaming

    Hi, there!
    Is it possible to send Video Streaming (using JMF) to
    Windows Media Player? If so, how could I do that???
    Thank You very much!!
    Cesar

    Hi Jupiter,
    Yes, JMF supports streaming media using the public standard RTP and RTSP protocols.
    JMF supports both transmission and reception of media over RTP for a variety of media formats. For a list of the default formats supported, check:
    http://java.sun.com/products/java-media/jmf/2.1.1/support-rtp.html
    It also fully supports RTCP. Besides, JMF implements the "RTP Profile for Audio and Video Conferences with Minamal Control", RTP/AVP.
    The front end GUI application, JMStudio can be used as a standalone application to transmit and receive RTP streams. To implement custom RTP applications using JMF as a framework, check out the RTP samples
    on the solutions page: http://java.sun.com/products/java-media/jmf/2.1.1/solutions/index.html
    OR you can refer this URL.
    http://java.sun.com/products/java-media/jmf/2.1.1/faq-jmf.html#jmf2-rtp-features
    I hope this will help you.
    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India

  • How to receive video stream with different codec

    Hello Experts,
    I am transmitting the video stream from a system using RGBFormat with dimension 320x240 but at the receiver side in the absence this CODEC I need to receive the stream with RGBFormat dimension 160x120.
    I request you to please guide me that how can I do this.
    Apart from this please let me know that is there a way through which I can add codec RGBFormat with dimension 320x240 ?

    I am transmitting the video stream from a system using RGBFormat with dimension 320x240 but at the receiver side in the absence this CODEC I need to receive the stream with RGBFormat dimension 160x120.You need to do what exactly? Can you explain that better, because, that doesn't make much sense to me. You want to transmit a video stream at 320x240 and have the client receive it at a different resolution that you sent it at... that just doesn't make sense.
    I'd like to mail you a letter on a legal sized sheet of paper, but I'd like for you to receive it on standard paper... See? Doesn't really make any sense...
    Apart from this please let me know that is there a way through which I can add codec RGBFormat with dimension 320x240 ?The RGB format is already defined for JMF, it just doesn't have an RGB-RTP variant for sending over RTP...and creating all of the things you have to create to make JMF send in RGB is pretty complex, complicated stuff.

  • Playing video streaming

    I begin to implement a video chat in java. I used JMF for capturing video streaming from a digital camera and RTP protocol for transmiting the video stream. I want to play the stream into an Applet (so on the client side). I don't want to use jmf on client side (an RTP Applet Player or something like this) because this means that the client needs to instal the JMF package. I need a solution to play the stream stream into an applet but I want that the client don't need to instal any software. I can use anything on server side (from where I transmit)...Is this possible? Please help me. Thank you.

    I've only done some web cam capturing code, but I thought you only need the "performance pack" of JMF installed on a machine if you want to perform capturing.
    So, maybe you can still use JMF in an applet without a formal installation on the client pc.
    Just itry ncluding the jmf.jar and any CODEC class files necessary to replay your video stream ?
    It's worth a shot... although someone may very well correct me on this.
    regards,
    Owen

  • Capturing, timestamping and saving a video stream from a webcam ?

    Hello everybody,
    Glad to be in this forum.
    I got to do a program in java doing :
    - a capture of a video stream from a webcam
    - adding time and date on it
    - saving the video stream in a video format compatible with linux and windows
    Is it possible to do that in java (using JMF I guess) ?
    Could anyone help me to progress on my project ?
    thx a lot
    agussi

    Hi agussi, yes, it's possible to do that in Java using JMF.
    I'm not a JMF expert, but I've found this code very useful: http://forum.java.sun.com/thread.jspa?threadID=570463&tstart=50
    This piece of code shows the webcam stream and you can take snapshots with it. With a little tweak you can do what you are expecting.
    I hope this helps.
    Ivan

  • Capture video stream from network

    Hi all,
    I have application to broadcast video to network.
    And I want to write app use jmf to capture video stream.
    if you have any sample source code, please send to me
    (my mail: [email protected]).
    Thank you.

    yap
    avtransmit2 is giveing ERROR (line:123 "Couldn't create DataSource") so i thing medialocator is not finding so datasource is not created but variable locator is not NULL.
    i am trying to transmit from webcam (realtime).

Maybe you are looking for