Sun Java Solaris Communities My SDN Account Join SDN
 
Code sample

Cutting Sections from an Input

 

JMF Solutions

Cutting Sections from an Input

Problem
Given an input media file, the object is to cut pieces from the file and generate an output file from that.

Solution
A sample application is written.  It accepts an input URL and a list of start and end points specifying the parts to be kept from the input. A Processor is created for the input URL. A custom DataSource is then created from the output of the Processor. This custom DataSource reads from the Processor's output and cuts out the pieces that are not needed according to the list of start and end points specified. This DataSources is then used to create a second Processor to generate the final edited bits. The output from this Processor is then fed to a file DataSink to generate the final output file.

Limitations
  • For MPEG-1 input, the data will be transcoded to JPEG video and Linear audio before cutting takes place.
  • As much as possible, the program attempts to maintain A/V synchronization in the final output file. There are some cases that it may fail.
  • Specifying the start and end points in video frames unit will only work for files with frame positioning accuracy.

  •  
    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
    How to run this sample
    java Cut -o <output URL> <input URL> [-f] -s <start> -e <end> ...
    where:
    <start>: start time in milliseconds.
    <end>: end time in milliseconds.
    -f: specify start and end times in video frames instead of milliseconds.
    Example:
    java Cut -o file:/c:/temp/foo.mov file:/c:/movies/amovie.avi -s 5000 -e 10000
    Source Code