No results found

Your search did not match any results.

We suggest you try the following to help find what you’re looking for:

  • Check the spelling of your keyword search.
  • Use synonyms for the keyword you typed, for example, try “application” instead of “software.”
  • Try one of the popular searches shown below.
  • Start a new search.
Trending Questions
 

Screen Grabber [DataSource]

JMF Solutions

Problem

How to capture the contents of the screen and feed it to a JMF player or Processor for purposes such as saving screen shots to disk or transmitting live using RTP.

Solution

Java 2 v.1.3 introduced a new class, java.awt.Robot, that provides screen capture facilities. Since this is similar to capturing video from a VCR or camera, it is best encapsulated in a JMF DataSource object. This example shows how to use Robot to create a screen capture DataSource.

The DataSource is a PushDataSource that pushes captured screen shots at regular intervals to the connected Player or Processor. It creates a new protocol "screen" with the following URL syntax:

screen://x,y,width,height/fps

where x, y specify a screen location and width,height specify the size. fps specifies the number of frames to push per second. This can be any fraction greater than zero, although realistic values would be between 0.1 and 30.0.

For example, to capture screen activity in the center of a 1024x768 screen, use

screen://352,264,320,240/5

Note: This program requires JDK 1.3 or higher to compile and to run.

Requirements

Platform: JDK 1.3 or later
JMF API: 2.0 or later
Implementation: AJ, WPP, SPP *

* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack

Related Classes

  • javax.media.protocol.DataSource
  • java.awt.Robot

How to run this sample

  1. Compile the DataSource and LiveStream classes:
    javac -d . DataSource.java LiveStream.java
  2. Run using JMStudio:
    java JMStudio screen://0,0,160,120/10

Source Code

  • DataSource.java
  • LiveStream.java