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
 

Transcoding to Different Formats

JMF Solutions

Problem

Given an input URL, the object is to transcode the input media to different track formats and generate a resulting file with the transcoded data.  The output file could also be of a different content type from the original input.

Solution

A sample application is written.  It accepts an input URL where the original data comes from; an output URL where the transcoded data will be saved; and a list of track formats of which the input data will be transcoded to.  The actual algorithm to transcode the data is rather straight forward:

  1. Create a Processor for the given input URL.
  2. Configure the Processor.
  3. Parse the output media locater and based on the file extension, determine the content descriptor using MimeManager.
  4. Set the (output) content descriptor on the Processor.
  5. For each of the given track formats:
    1. Match it against the supported formats of each track.
    2. If there is a match, set the format on that track.
  6. Realize the Processor.
  7. Obtain the output DataSource and use it in conjuction with the output media locator to create a DataSink.
  8. Start the Processor and DataSink.
  9. Wait for the DataSink's EndOfStreamEvent.
  10. Close up the Processor and DataSink.

Some error checking is handled as an example.

Requirements

Platform: JDK 1.1.6 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.Processor
  • javax.media.DataSink
  • javax.media.control.TrackControl
  • javax.media.protocol.ContentDescriptor
  • javax.media.format.AudioFormat
  • javax.media.format.VideoFormat

How to run this sample

java Transcode -o <output URL> -a <audio format> -v <video format> <input URL>

where:

<audio format> is of the form:

[encoding]/[rate]/[sizeInBits]/[channels]/[big|little]/[signed|unsigned] <video format>: is of the form: [encoding]

Example:

java Transcode -o file:/c:/temp/foo.mov -a linear/8000 file:/c:/movies/amovie.avi

will transcode the input AVI movie to a QuickTime movie with 8KHz linear audio.

Source Code

  • Transcode.java