JMF Compiling video from a folder of images

Hello,
I am trying to create a video from a folder of images. I am using a modified version of the JPEGImagesToMovie.java code.
The video is not compiling correctly and when I playback it is only showing a blurred image of the final frame.
Any ideas?
Cheers, Paul
import java.util.*;
import java.io.*;
import java.awt.Dimension;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
import javax.media.datasink.*;
import javax.media.format.VideoFormat;
public class VideoThread extends Thread implements ControllerListener, DataSinkListener {
   // Generate the output media locators.
     private MediaLocator oml;
   private int width;
   private int height;
   private int frameRate;
   private String folder;
   public VideoThread(int width, int height, int frameRate, String folder) {
      this.width = width;
      this.height = height;
      this.frameRate = frameRate;
      this.folder = folder;
   public void run() {
      if ((oml = createMediaLocator("images/" + folder + "/" + folder + ".mov")) == null) {
         System.err.println("Cannot build media locator from: " + "images/" + folder + "/" + folder + ".mov");
      ImageDataSource ids = new ImageDataSource(width, height, frameRate, folder);
        Processor p;
      try {
         p = Manager.createProcessor(ids);
      } catch (Exception e) {
         System.err.println("Cannot create a processor from the data source.");        
         return;
      p.addControllerListener(this);
      // Put the Processor into configured state so we can set
        // some processing options on the processor.
        p.configure();
      if (!waitForState(p, p.Configured)) {
         System.err.println("Failed to configure the processor.");
         return;
      // Set the output content descriptor to QuickTime.
      p.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.QUICKTIME));
        // Query for the processor for supported formats.
      // Then set it on the processor.
        TrackControl tcs[] = p.getTrackControls();
        Format f[] = tcs[0].getSupportedFormats();
      if (f == null || f.length <= 0) {
         System.err.println("The mux does not support the input format: " + tcs[0].getFormat());
         return;
      tcs[0].setFormat(f[0]);
      System.err.println("Setting the track format to: " + f[0]);
      // We are done with programming the processor.  Let's just
        // realize it.
        p.realize();
      if (!waitForState(p, p.Realized)) {
         System.err.println("Failed to realize the processor.");
         return;
      // Now, we'll need to create a DataSink.
        DataSink dsink;
      if ((dsink = createDataSink(p, oml)) == null) {
         System.err.println("Failed to create a DataSink for the given output MediaLocator: " + oml);        
         return;
      dsink.addDataSinkListener(this);
        fileDone = false;
      System.err.println("start processing...");
        // OK, we can now start the actual transcoding.
      try {
         p.start();
         dsink.start();
      catch (IOException e) {
         System.err.println("IO error during processing");
         return;
      // Wait for EndOfStream event.
        waitForFileDone();
      // Cleanup.
      try {
         dsink.close();
      } catch (Exception e) {}
      p.removeControllerListener(this);
      System.err.println("...done processing.");
      return;
    * Create the DataSink.
   DataSink createDataSink(Processor p, MediaLocator oml) {
   DataSource ds;
   if ((ds = p.getDataOutput()) == null) {
      System.err.println("Something is really wrong: the processor does not have an output DataSource");
      return null;
     DataSink dsink;
   try {
      System.err.println("- create DataSink for: " + oml);
      dsink = Manager.createDataSink(ds, oml);
      dsink.open();
   catch (Exception e) {
      System.err.println("Cannot create the DataSink: " + e);
      return null;
     return dsink;
   Object waitSync = new Object();
   boolean stateTransitionOK = true;
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
   boolean waitForState(Processor p, int state) {
   synchronized (waitSync) {
      try {
         while (p.getState() < state && stateTransitionOK)
            waitSync.wait();
      catch (Exception e) {}
     return stateTransitionOK;
    * Controller Listener.
   public void controllerUpdate(ControllerEvent evt) {
     if (evt instanceof ConfigureCompleteEvent ||
      evt instanceof RealizeCompleteEvent ||
      evt instanceof PrefetchCompleteEvent) {
      synchronized (waitSync) {
         stateTransitionOK = true;
         waitSync.notifyAll();
   else if (evt instanceof ResourceUnavailableEvent) {
      synchronized (waitSync) {
         stateTransitionOK = false;
         waitSync.notifyAll();
   else if (evt instanceof EndOfMediaEvent) {
      evt.getSourceController().stop();
      evt.getSourceController().close();
   Object waitFileSync = new Object();
   boolean fileDone = false;
   boolean fileSuccess = true;
    * Block until file writing is done.
   boolean waitForFileDone() {
   synchronized (waitFileSync) {
      try {
         while (!fileDone){
            waitFileSync.wait();}
      catch (Exception e) {}
   return fileSuccess;
    * Event handler for the file writer.
   public void dataSinkUpdate(DataSinkEvent evt) {
      if (evt instanceof EndOfStreamEvent) {
         synchronized (waitFileSync) {
            fileDone = true;
            waitFileSync.notifyAll();
      else if (evt instanceof DataSinkErrorEvent) {
         synchronized (waitFileSync) {
            fileDone = true;
            fileSuccess = false;
            waitFileSync.notifyAll();
    * Create a media locator from the given string.
   static MediaLocator createMediaLocator(String url) {
      MediaLocator ml;
        if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
         return ml;
      if (url.startsWith(File.separator)) {
         if ((ml = new MediaLocator("file:" + url)) != null)
            return ml;
      else {
         String file = "file:" + System.getProperty("user.dir") + File.separator + url;
         if ((ml = new MediaLocator(file)) != null)
            return ml;
      return null;
    // Inner classes.
     * A DataSource to read from a list of image files and
     * turn that into a stream of JMF buffers.
     * The DataSource is not seekable or positionable.
class ImageDataSource extends PullBufferDataSource {
     ImageSourceStream streams[];
     ImageDataSource(int width, int height, int frameRate, String folder) {
         streams = new ImageSourceStream[1];
         streams[0] = new ImageSourceStream(width, height, frameRate, folder);
     public void setLocator(MediaLocator source) {
     public MediaLocator getLocator() {
         return null;
      * Content type is of RAW since we are sending buffers of video
      * frames without a container format.
     public String getContentType() {
         return ContentDescriptor.RAW;
     public void connect() {
     public void disconnect() {
     public void start() {
     public void stop() {
      * Return the ImageSourceStreams.
     public PullBufferStream[] getStreams() {
         return streams;
      * We could have derived the duration from the number of
      * frames and frame rate.  But for the purpose of this program,
      * it's not necessary.
     public Time getDuration() {
         return DURATION_UNKNOWN;
     public Object[] getControls() {
         return new Object[0];
     public Object getControl(String type) {
         return null;
     * The source stream to go along with ImageDataSource.
class ImageSourceStream implements PullBufferStream {
     String folder;
   String imageFile;
     int width, height;
     VideoFormat format;
   File file;
     int nextImage = 000001;     // index of the next image to be read.
     boolean ended = false;
     public ImageSourceStream(int width, int height, int frameRate, String folder) {
         this.width = width;
         this.height = height;
         this.folder = folder;
         format = new VideoFormat(VideoFormat.JPEG,
                    new Dimension(width, height),
                    Format.NOT_SPECIFIED,
                    Format.byteArray,
                    (float)frameRate);
      * This is called from the Processor to read a frame worth
      * of video data.
     public void read(Buffer buf) throws IOException {
      imageFile = "images/" + folder + "/webcam" + StringPrefix(nextImage,6) + ".jpeg";
      file = new File(imageFile);
        // Check if we've finished all the frames.
        if (!file.exists()) {
         // We are done.  Set EndOfMedia.
             buf.setEOM(true);
             buf.setOffset(0);
             buf.setLength(0);
             ended = true;
         System.out.println("all images");
         return;
System.err.println("  - reading image file: " + imageFile);
        nextImage++;
         // Open a random access file for the next image.
         RandomAccessFile raFile;
         raFile = new RandomAccessFile(imageFile, "r");
         byte data[] = null;
         // Check the input buffer type & size.
         if (buf.getData() instanceof byte[])
          data = (byte[])buf.getData();
         // Check to see the given buffer is big enough for the frame.
         if (data == null || data.length < raFile.length()) {
          data = new byte[(int)raFile.length()];
          buf.setData(data);
         // Read the entire JPEG image from the file.
         raFile.readFully(data, 0, (int)raFile.length());
         System.err.println("    read " + raFile.length() + " bytes.");
         buf.setOffset(0);
         buf.setLength((int)raFile.length());
         buf.setFormat(format);
         buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
         // Close the random access file.
         raFile.close();
      * We should never need to block assuming data are read from files.
     public boolean willReadBlock() {
         return false;
      * Return the format of each video frame.  That will be JPEG.
     public Format getFormat() {
         return format;
   public ContentDescriptor getContentDescriptor() {
         return new ContentDescriptor(ContentDescriptor.RAW);
     public long getContentLength() {
         return 0;
     public boolean endOfStream() {
         return ended;
     public Object[] getControls() {
         return new Object[0];
     public Object getControl(String type) {
         return null;
   private String StringPrefix(int number, int length) {
      String stringNum = Integer.toString(number);
      while (stringNum.length() < length)
         stringNum = "0" + stringNum;
      return stringNum;
}

If your code was an SSCCE*, I could run it
against some images that I have successfully
used to create MOV's (using my own variant of
JPEGImagesToMovie).
It isn't, so I can't.
The only thing I can suggest (off the top of
my head) is that the images need to be all
the same size/width, and the same as
specified for the MOV, otherwise a corrupted
MOV will be written.
* http://www.physci.org/codes/sscce/

Similar Messages

  • Add Date and Time Stamp to video from AVCHD folder

    New to this software and forum, so I apologize if this has been asked and answered. I am trying to insert the date and time metadata from the AVCHD folder using the .mts clips. Curently I am using VaTS to stamp the video then render the clips through Power Director. I would appreciate any help on this topic. Thank you for your time

    BenB, thanks for responding to both of my posts. The footage was shot using a Sony HDR-XR500 AKA consumer video camera. Date and time is not burned into the image when captured digitally. The only way to do it would be to run the video through a video capture device that basically just records what the video outputs. This solution really ***** so i'm looking for somthing more effective.

  • How do I make a thumbnail that has a gallery inside? And how can I make this gallery have embeded videos from vimeo + Images?

    Hello,
    I'm pretty new to Muse so I don't know a lot about it, but I researched a lot and didn't find an answer to this question.
    I'm trying to make a portfolio website. The website will be a 12 thumbnails. But each thumbnail is one project, not an image.
    When you click one of the thumbnails, I want it to be a lightbox that will show embeded videos from vimeo mixed with images.
    Ex: A coca-cola projet.
    Main page has a thumbnail of a coca cola image. When you click on it, it opens a lightbox with a coca-cola film, when i click to the right arrow, it shows a cocacola poster, then another poster, then another video. (but they are all part of this gallery, that is inside the thumbnail.
    Can you guys help me?
    Thanks!!!

    I don't understand why my thumbnails don't work.
    I dragged a composition lightbox inside another one. But I still have the first lightbox there and can't delete.
    When I try my wabsite i see this:
    But then I click the thumbnail and I see this:
    And when I click one of those 3 I see this:
    Like it is making a double lightbox.
    but it doesn't show the images, it's like the first lightbox is on top of the second one.
    How I deal with this?  =/

  • How do i load images from a folder?

    Hello everyone,
    Please can someone help me as i am stuck.
    I am trying to research loading images from a folder called /images/unknown (unknown is a customer number and is stored in a variable called customerNo).
    I feel that i will need to load the images into an array then display them to the screen with a viewer.
    Can anybody help me.
    Thanks in advance

    Welcome to the Sun forums.
    irknappers wrote:
    ...Please can someone help me as i am stuck.You might want to be more exact in future, about what you are stuck on.
    import javax.imageio.ImageIO;
    import java.io.FileFilter;
    import java.io.File;
    import javax.swing.JFileChooser;
    class LoadImages {
        public static void main(String[] args) {
            String[] suffixes = ImageIO.getReaderFileSuffixes();
            FileFilter fileFilter = new FileFilterType(suffixes);
            File directory = null;
            if (args.length==1) {
                directory = new File( args[0] );
            } else {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
                int result = fileChooser.showOpenDialog( null );
                if ( result == JFileChooser.APPROVE_OPTION ) {
                    directory = fileChooser.getSelectedFile();
                } else {
                    System.err.println("Must select a directory to proceed, exiting.");
            File[] images = directory.listFiles( fileFilter );
            for (File file : images) {
                System.out.println(file);
            System.out.println( "The rest is left an exercise for the reader.  ;-)" );
    class FileFilterType implements FileFilter {
        String[] types;
        FileFilterType(String[] types) {
            this.types = types;
        public boolean accept(File file) {
            for (String type : types) {
                if ( file.getName().toLowerCase().endsWith( type.toLowerCase() ) ) {
                    return true;
            return false;
    }

  • Time-lapse video from existing series of pictures...

    I am new to Premiere Elements and looking for instructions on creating a time-lapse video from a folder of still pictures taken using a GoPro camera.  So far the Help has only discussed creating time-lapse from a video feed.  great thanks for any suggestions...

    Welcome to the forum.
    If you are ONLY using Still Images, and no Video, then you will want to determine your delivery, say DVD-Video, or BD, or posting to YouTube in SD, or HD. That will determine the Project Preset that you will choose.
    Let's say that you will wish to deliver the Project via a BD (Blu-ray Disc). If so, then you can choose a 1920 x 1080 Project, at either 30 (29.97) FPS for NTSC, or 25 FPS for PAL.
    I would Scale all of my images to 1920 x 1080 in Photoshop, or Photoshop Elements. This can be easily done with an Action for an entire folder of Images. See this ARTICLE for some tips.
    As for Import, there are probably two ways to handle that, but someone will have to give you exact instructions on the second, if PrE now supports Importing Numbered Stills Sequences, like PrPro does. I believe that it now does, but use PrPro for such, that I have not explored it. The other is pretty straight forward. When I Scale my Still Images, I number them sequentially, so that file ____00001 is followed by ____00002, etc. through the last Image in the sequence.
    This next part might take some experimentation, depending on the intervals, that you have set your Go-Pro to shoot, and the "look," that you want. For pure Time-Lapse, a Duration of 1 Frame is probably what you want, but if you wish a bit more of a Stop-Motion look, then you might want, say 3 - 5.Frames. For most of my work, I will go with the 3 - 5 Frames, and use very short Cross-Dissolves between each Image. After you have done the experimentation, go to Edit>Preferences and set the Still Image Duration.Then, Import the Stills, or if possible in PrE, Import the Numbered Still Sequence, which, in PrPro, will allow one to add the Cross-Dissolve automatically. Remember, also in Edit>Preferences, set the Video Transition Duration too.
    Good luck, and let us know what works best for you. Also, keep an eye out, because if PrE does support Numbered Still Sequences, that will save you some time. Steve, Neale, John T., or another will verify that PrE has that capability, and where to locate it.
    Hunt

  • HT1473 I am trying to copy videos from my windows based dell into iTunes and they will not coy when I drag and drop nor with they copy when I use the add file command.

    I am trying to copy videos from windows folder into iTunes and it will not copy. I have used drag and drop and the folder sopy comand from iTunes. Anybody got an answer?

    Hi wayneiii,
    If you are having issues adding video files to iTunes on your Windows machine, you may want to verify that they are in a format that iTunes can play. You may find the following article helpful:
    iTunes: Frequently asked questions about viewing and syncing videos
    http://support.apple.com/kb/ht2729
    Regards,
    - Brenden

  • I had this video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.

    I had a video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.  I've tried to undo the action.  No luck.  I wasn't running my Time Machine.  So, I can't go back.  Help.  It's the only copy of this video.

    I've tried to undo the action.
    How?
    Please detail ALL you have done so far in the way of troubleshooting?   Need this info to avoid the been there done that scenarios.
    it's the only copy of this video.
    Where did you get the video from?
    From the pic I noticed that the folder is 841.9mb.  What's inside?  Or what happens when you click on it?

  • Coverting video from images without using JMF.

    Dear All,
    I want to convert video from sequence of images.
    I have used JMF sample for doing the same.It works pretty fine.
    But I want to do same without using JMF.
    Do anyone here used another libraries like FFMPEG for Java or Theora to achieve same.
    If you have any idea about it, please reply.
    Yours Sincerely,
    Ashish Nijai

    I've done this in the past by calling out to ffmpeg as an external application. There's nothing Java specific in that other than the act of calling an external binary - for which the ProcessBuilder API should be your starting point. If you have questions about ProcessBuilder start a new thread in "Java Programming" or "New To Java" but remember to google first - it's a common topic.
    A bit of Googling suggests that there might be some JNI wrappers for ffmpeg too.
    Note that on the project where I used ffmpeg we eventually went over to running it in batches from a cron script with no Java components at all.

  • Creating video from images

    I am trying to make video from images
    here is my program
    import java.awt.Dimension;
    import java.awt.Image;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.datasink.*;
    import javax.media.format.VideoFormat;
    import javax.media.util.ImageToBuffer;
    import java.io.*;
    import java.util.*;
    *For AVI files, each frame must have a time stamp set. See the following message from the jmf-interest archives for details:
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0107&L=jmf-interest&P=R34660
    public class AviCreator implements ControllerListener, DataSinkListener
    private boolean doIt(
    int width,
    int height,
    int frameRate,
    MediaLocator outML)
         File folder=new File("c:/images1");     
              File [] files=folder.listFiles();
    ImageDataSource ids = new ImageDataSource(width, height, frameRate,files);
    Processor p;
    try
    System.err.println(
    "- create processor for the image datasource ...");
    p = Manager.createProcessor(ids);
    catch (Exception e)
    System.err.println(
    "Yikes! Cannot create a processor from the data source.");
    return false;
    p.addControllerListener(this);
    // Put the Processor into configured state so we can set
    // some processing options on the processor.
    p.configure();
    if (!waitForState(p, Processor.Configured))
    System.err.println("Failed to configure the processor.");
    return false;
    // Set the output content descriptor to QuickTime.
    p.setContentDescriptor(
    new ContentDescriptor(FileTypeDescriptor.MSVIDEO));
    // Query for the processor for supported formats.
    // Then set it on the processor.
    TrackControl tcs[] = p.getTrackControls();
    Format f[] = tcs[0].getSupportedFormats();
    if (f == null || f.length <= 0)
    System.err.println(
    "The mux does not support the input format: "
    + tcs[0].getFormat());
    return false;
    tcs[0].setFormat(f[0]);
    System.err.println("Setting the track format to: " + f[0]);
    // We are done with programming the processor. Let's just
    // realize it.
    p.realize();
    if (!waitForState(p, Processor.Realized))
    System.err.println("Failed to realize the processor.");
    return false;
    // Now, we'll need to create a DataSink.
    DataSink dsink;
    if ((dsink = createDataSink(p, outML)) == null)
    System.err.println(
    "Failed to create a DataSink for the given output MediaLocator: "
    + outML);
    return false;
    dsink.addDataSinkListener(this);
    fileDone = false;
    System.err.println("start processing...");
    // OK, we can now start the actual transcoding.
    try
    p.start();
    dsink.start();
    catch (IOException e)
    System.err.println("IO error during processing");
    return false;
    // Wait for EndOfStream event.
    waitForFileDone();
    // Cleanup.
    try
    dsink.close();
    catch (Exception e)
    p.removeControllerListener(this);
    System.err.println("...done processing.");
    return true;
    * Create the DataSink.
    private DataSink createDataSink(Processor p, MediaLocator outML)
    DataSource ds;
    if ((ds = p.getDataOutput()) == null)
    System.err.println(
    "Something is really wrong: the processor does not have an output DataSource");
    return null;
    DataSink dsink;
    try
    System.err.println("- create DataSink for: " + outML);
    dsink = Manager.createDataSink(ds, outML);
    dsink.open();
    catch (Exception e)
    System.err.println("Cannot create the DataSink: " + e);
    return null;
    return dsink;
    private Object waitSync = new Object();
    private boolean stateTransitionOK = true;
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    private boolean waitForState(Processor p, int state)
    synchronized (waitSync)
    try
    while (p.getState() < state && stateTransitionOK)
    waitSync.wait();
    catch (Exception e)
    return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt)
    if (evt instanceof ConfigureCompleteEvent
    || evt instanceof RealizeCompleteEvent
    || evt instanceof PrefetchCompleteEvent)
    synchronized (waitSync)
    stateTransitionOK = true;
    waitSync.notifyAll();
    else if (evt instanceof ResourceUnavailableEvent)
    synchronized (waitSync)
    stateTransitionOK = false;
    waitSync.notifyAll();
    else if (evt instanceof EndOfMediaEvent)
    evt.getSourceController().stop();
    evt.getSourceController().close();
    private Object waitFileSync = new Object();
    private boolean fileDone = false;
    private boolean fileSuccess = true;
    * Block until file writing is done.
    private boolean waitForFileDone()
    synchronized (waitFileSync)
    try
    while (!fileDone)
    waitFileSync.wait();
    catch (Exception e)
    return fileSuccess;
    * Event handler for the file writer.
    public void dataSinkUpdate(DataSinkEvent evt)
    if (evt instanceof EndOfStreamEvent)
    synchronized (waitFileSync)
    fileDone = true;
    waitFileSync.notifyAll();
    else if (evt instanceof DataSinkErrorEvent)
    synchronized (waitFileSync)
    fileDone = true;
    fileSuccess = false;
    waitFileSync.notifyAll();
    public static String[] createParam()
         File folder=new File("c:/images1");     
         String [] files=folder.list();
         String param[]=new String[files.length+8];          
    param[0]="-w";
    param[1]="400";
    param[2]="-h";
    param[3]="300";
    param[4]="-f";
    param[5]="1";
    param[6]="-o";
    param[7]="file:/c:/images/abc.avi";          
         for(int i=8;i<files.length+8;i++)     
              param="file:/c:/images1/"+files[i-8];
    return param;     
    public static void main(String args1[]) throws Exception
    //jpegCreator.main(null);
    //if (args.length == 0)
    // prUsage();
              //String [] args ={"-w","320" ,"-h","240", "-f","1", "-o", "file:/c:/images/abc.mov","file:/c:/images/surya_jo1.jpg", "file:/c:/temp/flower1_jpg.jpg" };
              String [] args=createParam();
    // Parse the arguments.
    int i = 0;
    int width = -1, height = -1, frameRate = 1;
    Vector inputFiles = new Vector();
    inputFiles.add("file:/c:/images/surya_jo1.jpg");
    inputFiles.add("file:/c:/images/flower1_jpg.jpg");
    String outputURL = null;
    width = 128;
    height = 128;
    outputURL = "file:/c:/images/abc.avi";
    // Generate the output media locators.
    MediaLocator oml;
    if ((oml = createMediaLocator(outputURL)) == null)
    System.err.println("Cannot build media locator from: " + outputURL);
    System.exit(0);
    AviCreator imageToMovie = new AviCreator();
    imageToMovie.doIt(width, height, frameRate, oml);
    System.exit(0);
    static void prUsage()
    System.err.println(
    "Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL> <input JPEG file 1> <input JPEG file 2> ...");
    System.exit(-1);
    * Create a media locator from the given string.
    private static MediaLocator createMediaLocator(String url)
    MediaLocator ml;
    if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
    return ml;
    if (url.startsWith(File.separator))
    if ((ml = new MediaLocator("file:" + url)) != null)
    return ml;
    else
    String file =
    "file:" + System.getProperty("user.dir") + File.separator + url;
    if ((ml = new MediaLocator(file)) != null)
    return ml;
    return null;
    // Inner classes.
    * A DataSource to read from a list of JPEG image files and
    * turn that into a stream of JMF buffers.
    * The DataSource is not seekable or positionable.
    /************************************************* private class ImageDataSource extends PullBufferDataSource
    private ImageSourceStream streams[];
    ImageDataSource(int width, int height, int frameRate)
    streams = new ImageSourceStream[1];
    streams[0] = new ImageSourceStream(width, height, frameRate);
    public void setLocator(MediaLocator source)
    public MediaLocator getLocator()
    return null;
    public String getContentType()
    return ContentDescriptor.RAW;
    public void connect()
    public void disconnect()
    public void start()
    public void stop()
    public PullBufferStream[] getStreams()
    return streams;
    public Time getDuration()
    System.out.println("dur is " + streams[0].nextImage);
    //return new Time(1000000000);
    return DURATION_UNKNOWN;
    public Object[] getControls()
    return new Object[0];
    public Object getControl(String type)
    return null;
    * A DataSource to read from a list of JPEG image files or
    * java.awt.Images, and
    * turn that into a stream of JMF buffers.
    * The DataSource is not seekable or positionable.
    private static class ImageDataSource extends PullBufferDataSource {
    private final Time durTime;
    private final PullBufferStream[] streams = new JpegSourceStream[1];
    * Constructor for creating movies out of jpegs
    ImageDataSource(int width, int height, int frameRate, File[] jpegFiles) {
    streams[0] = new JpegSourceStream(width, height, frameRate, jpegFiles);
    this.durTime = new Time(jpegFiles.length / frameRate);
    * Constructor for creating movies out of Images
    * NOTE - this is all done IN MEMORY, so you'd better have enough
    /*ImageDataSource(int width, int height, int frameRate, Image[] images) {
    streams[0] = new AWTImageSourceStream(width, height, frameRate, images);
    this.durTime = new Time(images.length / frameRate);
    public void setLocator(MediaLocator source) {
    public MediaLocator getLocator() {
    return null;
    * Content type is of RAW since we are sending buffers of video
    * frames without a container format.
    public String getContentType() {
    return ContentDescriptor.RAW;
    public void connect() {
    public void disconnect() {
    public void start() {
    public void stop() {
    * Return the ImageSourceStreams.
    public PullBufferStream[] getStreams() {
    return streams;
    public Time getDuration() {
    return durTime;
    public Object[] getControls() {
    return new Object[0];
    public Object getControl(String type) {
    return null;
    * The jpeg-based source stream to go along with ImageDataSource.
    private static class JpegSourceStream implements PullBufferStream {
    private final File[] jpegFiles;
    private final int width, height;
    private final VideoFormat videoFormat;
    private int nextImage = 0; // index of the next image to be read.
    private boolean ended = false;
    // Bug fix from Forums - next one line
    long seqNo = 0;
    public JpegSourceStream(int width, int height, int frameRate, File[] jpegFiles) {
    this.width = width;
    this.height = height;
    this.jpegFiles = jpegFiles;
    this.videoFormat = new VideoFormat(VideoFormat.JPEG,
    new Dimension(width, height),
    Format.NOT_SPECIFIED,
    Format.byteArray,
    (float)frameRate);
    * We should never need to block assuming data are read from files.
    public boolean willReadBlock() {
    return false;
    * This is called from the Processor to read a frame worth
    * of video data.
    public void read(final Buffer buf) {
    try {
    // Check if we've finished all the frames.
    if (nextImage >= jpegFiles.length) {
    // We are done. Set EndOfMedia.
    System.out.println("Done reading all images.");
    buf.setEOM(true);
    buf.setOffset(0);
    buf.setLength(0);
    ended = true;
    return;
    File imageFile = jpegFiles[nextImage];
    nextImage++;
    System.out.println(" - reading image file: " + imageFile);
    // Open a random access file for the next image.
    RandomAccessFile raFile = new RandomAccessFile(imageFile, "r");
    byte[] data = (byte[])buf.getData();
    // Check to see the given buffer is big enough for the frame.
    if (data == null || data.length < raFile.length()) {
    // allocate larger buffer
    data = new byte[(int)raFile.length()];
    buf.setData(data);
    // Read the entire JPEG image from the file.
    raFile.readFully(data, 0, (int)raFile.length());
    System.out.println(" read " + raFile.length() + " bytes.");
    // Bug fix for AVI files from Forums ( next 3 lines).
    long time = (long) (seqNo * (1000 / videoFormat.getFrameRate()) * 1000000);
    buf.setTimeStamp(time);
    buf.setSequenceNumber(seqNo++);
    buf.setOffset(0);
    buf.setLength((int)raFile.length());
    buf.setFormat(videoFormat);
    buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
    // Close the random access file.
    raFile.close();
    } catch (Exception e) {
    // it's important to print the stack trace here because the
    // sun class that calls this method silently ignores
    // any IOExceptions that get thrown
    e.printStackTrace();
    throw new RuntimeException(e);
    * Return the format of each video frame. That will be JPEG.
    public Format getFormat() {
    return videoFormat;
    public ContentDescriptor getContentDescriptor() {
    return new ContentDescriptor(ContentDescriptor.RAW);
    public long getContentLength() {
    return LENGTH_UNKNOWN;
    public boolean endOfStream() {
    return ended;
    public Object[] getControls() {
    return new Object[0];
    public Object getControl(String type) {
    return null;
    * The source stream to go along with ImageDataSource.
    /*************************************************************** class ImageSourceStream implements PullBufferStream
    final int width, height;
    final VideoFormat format;
    // Bug fix from Forums - next two lines
    float frameRate;
    long seqNo = 0;
    int nextImage = 0; // index of the next image to be read.
    boolean ended = false;
    public ImageSourceStream(int width, int height, int frameRate)
    this.width = width;
    this.height = height;
    // Bug fix from Forums (next line)
    this.frameRate = (float) frameRate;
    final int rMask = 0x00ff0000;
    final int gMask = 0x0000FF00;
    final int bMask = 0x000000ff;
    format =
    new javax.media.format.RGBFormat(
    new Dimension(width, height),
    Format.NOT_SPECIFIED,
    Format.intArray,
    frameRate,
    32,
    rMask,
    gMask,
    bMask);
    public boolean willReadBlock()
    return false;
    public void read(Buffer buf) throws IOException
    // Check if we've finished all the frames.
    if (nextImage >= 100)
    // We are done. Set EndOfMedia.
    System.err.println("Done reading all images.");
    buf.setEOM(true);
    buf.setOffset(0);
    buf.setLength(0);
    ended = true;
    return;
    nextImage++;
    int data[] = null;
    // Check the input buffer type & size.
    if (buf.getData() instanceof int[])
    data = (int[]) buf.getData();
    // Check to see the given buffer is big enough for the frame.
    if (data == null || data.length < width * height)
    data = new int[width * height];
    buf.setData(data);
    // Bug fix from Forums ( next 3 lines).
    long time = (long) (seqNo * (1000 / frameRate) * 1000000);
    buf.setTimeStamp(time);
    buf.setSequenceNumber(seqNo++);
    java.awt.Color clr = java.awt.Color.red;
    if (nextImage > 30)
    clr = java.awt.Color.GREEN;
    if (nextImage > 60)
    clr = java.awt.Color.BLUE;
    for (int i = 0; i < width * height; i++)
    // TODO - figure what the guy was trying to do here.
    data[i] = clr.getRGB();
    buf.setOffset(0);
    buf.setLength(width * height);
    buf.setFormat(format);
    buf.setFlags(buf.getFlags() | Buffer.FLAG_KEY_FRAME);
    public Format getFormat()
    return format;
    public ContentDescriptor getContentDescriptor()
    return new ContentDescriptor(ContentDescriptor.RAW);
    public long getContentLength()
    return 0;
    public boolean endOfStream()
    return ended;
    public Object[] getControls()
    return new Object[0];
    public Object getControl(String type)
    return null;
    * The java.awt.Image-based source stream to go along with ImageDataSource.
    * Not sure yet if this class works.
    private static class AWTImageSourceStream implements PullBufferStream {
    private final Image[] images;
    private final int width, height;
    private final VideoFormat videoFormat;
    private int nextImage = 0; // index of the next image to be read.
    private boolean ended = false;
    // Bug fix from Forums - next one line
    private long seqNo = 0;
    public AWTImageSourceStream(int width, int height, int frameRate, Image[] images) {
    this.width = width;
    this.height = height;
    this.images = images;
    // not sure if this is correct, especially the VideoFormat value
    this.videoFormat = new VideoFormat(VideoFormat.RGB,
    new Dimension(width, height),
    Format.NOT_SPECIFIED,
    Format.byteArray,
    (float)frameRate);
    * We should never need to block assuming data are read from files.
    public boolean willReadBlock() {
    return false;
    * This is called from the Processor to read a frame worth
    * of video data.
    public void read(final Buffer buf) throws IOException {
    try {
    // Check if we've finished all the frames.
    if (nextImage >= images.length) {
    // We are done. Set EndOfMedia.
    System.out.println("Done reading all images.");
    buf.setEOM(true);
    buf.setOffset(0);
    buf.setLength(0);
    ended = true;
    return;
    Image image = images[nextImage];
    nextImage++;
    // Open a random access file for the next image.
    //RandomAccessFile raFile = new RandomAccessFile(imageFile, "r");
    Buffer myBuffer = ImageToBuffer.createBuffer(image, videoFormat.getFrameRate());
    buf.copy(myBuffer);
    // Bug fix for AVI files from Forums ( next 3 lines).
    long time = (long) (seqNo * (1000 / videoFormat.getFrameRate()) * 1000000);
    buf.setTimeStamp(time);
    buf.setSequenceNumber(seqNo++);
    //buf.setOffset(0);
    //buf.setLength((int)raFile.length());
    //buf.setFormat(videoFormat);
    //buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
    } catch (Exception e) {
    // it's important to print the stack trace here because the
    // sun class that calls this method silently ignores
    // any Exceptions that get thrown
    e.printStackTrace();
    throw new RuntimeException(e);
    * Return the format of each video frame.
    public Format getFormat() {
    return videoFormat;
    public ContentDescriptor getContentDescriptor() {
    return new ContentDescriptor(ContentDescriptor.RAW);
    public long getContentLength() {
    return LENGTH_UNKNOWN;
    public boolean endOfStream() {
    return ended;
    public Object[] getControls() {
    return new Object[0];
    public Object getControl(String type) {
    return null;
    bit i am getting following exception at run time
    1
    2
    3
    4
    5
    6
    - create processor for the image datasource ...
    Setting the track format to: JPEG
    - create DataSink for: file:/c:/images/abc.mov
    start processing...
    - reading image file: file:/c:/images/surya_jo1.jpg
    - reading image file: file:/c:/images/flower1_jpg.jpg
    Done reading all images.
    Exception in thread "JMF thread: SendEventQueue: com.sun.media.processor.unknown.Handler" java.lang.NullPointerException
    at com.sun.media.multiplexer.video.QuicktimeMux.writeVideoSampleDescription(QuicktimeMux.java:936)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeSTSD(QuicktimeMux.java:925)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeSTBL(QuicktimeMux.java:905)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeMINF(QuicktimeMux.java:806)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeMDIA(QuicktimeMux.java:727)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeTRAK(QuicktimeMux.java:644)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeMOOV(QuicktimeMux.java:582)
    at com.sun.media.multiplexer.video.QuicktimeMux.writeFooter(QuicktimeMux.java:519)
    at com.sun.media.multiplexer.BasicMux.close(BasicMux.java:142)
    at com.sun.media.BasicMuxModule.doClose(BasicMuxModule.java:172)
    at com.sun.media.PlaybackEngine.doClose(PlaybackEngine.java:872)
    at com.sun.media.BasicController.close(BasicController.java:261)
    at com.sun.media.BasicPlayer.doClose(BasicPlayer.java:229)
    at com.sun.media.BasicController.close(BasicController.java:261)
    at JpegImagesToMovie.controllerUpdate(JpegImagesToMovie.java:196)
    at com.sun.media.BasicController.dispatchEvent(BasicController.java:1254)
    at com.sun.media.SendEventQueue.processEvent(BasicController.java:1286)
    at com.sun.media.util.ThreadedEventQueue.dispatchEvents(ThreadedEventQueue.java:65)
    at com.sun.media.util.ThreadedEventQueue.run(ThreadedEventQueue.java:92)
    plz help me
    thanks in advance

    Step 1) Copy that code into a .java file
    Step 2) Compile it
    Step 3) Run it
    Step 4) Look at the output
    Step 5 (optional)) If it didn't work, post a specific question about the code, and use [co[b]de] tags.

  • I am importing videos from my canon sl1 to my macbook when i use iphoto is says "iPhoto cannot import your photos because there was a problem downloading an image." and when i use image capture it says "An error occured while importing. The item 'MVI_1040

    I am importing videos from my canon sl1 to my macbook air when i use iphoto is says "iPhoto cannot import your photos because there was a problem downloading an image." and when i use image capture it says "An error occured while importing. The item ‘MVI_1040'' Thanks in advance

    Can you access the images on the phone with Image Capture (in the Applications Folder) ?

  • Hi, i have a canon 60d and i have been importing videos from it onto my mac for months but suddenly when i go on image capture or iphoto it no longer allows me to import them help!!!

    Hi, i have a canon 60d and i have been importing videos from it onto my mac for months but suddenly when i go on image capture or iphoto it no longer allows me to import them help!!!

    Have you launched and tired Image Capture? When it's launched with the iPad connected the photos will display in the window.  Select those you want to upload and use the Import to: menu and select Other.  Navigate to the Desktop and select the folder you created to hold those photos.

  • Help!!!! when i try to transfer my videos from phone to computer they upload as still images with sound!!!!

    hi all,
    when i try and transfer my videos from phone to computer they are tranfering as still images with sound! I have tried going through i tunes! quick time and vlc player but they are all coming up the same!
    I have bought several apps to aide with this but they all give the same results!
    i find it hard to believe that i cannot transfer videos from iphone as i have a samsung monte too and that requires plugging in and selecting phone then selecting what i want transferring and then they are there to watch as i recorded them!!!!!
    these are really important videos of my daughters first steps etc so really need to get this right! and as phone memory is low i cant do much on phone till i get rid of the vids!!!!
    thanks in advance

    Plug your iPhone into your PC, when it is connected open my computer and you will see your iPhone under devices. Double click on your iPhone and a window will open and display a dics drive called "internal storage", double click on internal storage and a folder will appear (might be named DCIM), double click on that folder and another folder should appear. This folder(s) (their may be more then one) should contain all your pictures and videos taken on your iPhone. Simply select the video(s) you want to save to you computer by right clicking on the video, select copy and then paste it where you would like to save it on your pc (click and drag will also work). After you have transfered the videos to your pc see if they play properly.

  • Downloading images/videos from the phone - again.....

    Hi
    I had setup nokia pc suite to download images to an USB drive which is dead now.
    luckily I have not deleted the images/videos from the phone yet.  
    I want to re-download everything from the phone to a new disk, but pc-suite claims
    no-new photos/videos in the photos.
    how can I RE-DOWNLOAD everything from the phone to my PC?
    thanks a bunch
    prd
    Solved!
    Go to Solution.

    I found a way:
    a) Win XP and PC Suite 7
    -> close Nokia Image Store
    -> go to the folder C:\Documents and settings\%sername%\Application Data\Nokia\Image Store
    -> delete search for a file called TransferLog.xml and delete all results
    -> open Nokia Image Store, it will say that you have new pictures and/or videos (it will consider all images an videos as if you connected the phone for the very first time, although the setting for the transfer will remain, so review them also in the wizard)
    b) Win Vista and PC Suite 7
    -> close Nokia Image Store
    -> go to the folder C:\d:\users\%username%\appdata\roaming\Nokia\Image Store
    -> delete search for a file called TransferLog.xml and delete all results
    -> open Nokia Image Store, it will say that you have new pictures and/or videos (it will consider all images an videos as if you connected the phone for the very first time, although the setting for the transfer will remain, so review them also in the wizard)
    Note: You may have to enable to see hidden folders and files and to clear the checkbox before the Hide protected operating system files in the folder view settings.
    Message Edited by panderson on 02-Mar-2009 09:47 PM

  • Unable to capture video from webcam in JMF in xlet

    hi
    I am unable to capture video from webcam in an Xlet. I am using Xletview to run Xlet. The method CaptureDeviceManager.getDeviceList(vidformat) returns empty array. Which videoformat should I use and why do I get empty array?
    Thanks
    Rajesh

    MHP and OCAP only use JMF 1.0, which does not include support for capturing video. You will not be able to do this in any current MHP/OCAP imlementation that I know of.
    Steve.

  • Unable to capture video from webcam in JMF

    hi
    I am unable to capture video from webcam in an Xlet. I am using Xletview to run Xlet. The method CaptureDeviceManager.getDeviceList(vidformat) returns empty array. Which videoformat should I use and why do I get empty array?

    MHP and OCAP only use JMF 1.0, which does not include support for capturing video. You will not be able to do this in any current MHP/OCAP imlementation that I know of.
    Steve.

Maybe you are looking for

  • Assign event to multiple calendars

    I use Outlook as my main calendar to track my family's activities and commitments, so I use categories for each of our family members.  Frequently, events (i.e. no school days) involves more than one child, so in Outlook the partivular event receives

  • How to populate an item first time with a computation ?

    Hi I have a form based on a table. When a new record is created, I want to populate an item with a value retrieved from a sql query. This is why I made an item (named P26_EMAIL) computation based on a nice sql query. select email from acl_employees w

  • How do I get Menu to show at top of organizer?

    All I have is very tiny double arrow that's very hard to see.  Holding cursor on the arrows brings up "file" "edit" etc vertically ( so it can be used), but otherwise it's just dark. Tried right clicking on arrows; nothing happened.  Right clicked to

  • Idoc mbgmcr02 movement type 311 ..  goods movement not possible w/mvmt type

    i am using we19 to create a test idoc...i have the ports and partners filled in...i am using movement type 311..i have the material , the plant, the storage location...the qty..i have the move material, the move plant and move storage location filled

  • Access of Purchasing Group

    Hi Everyone! I would just like to know how we can limit the access of a purchasing group to a specific purchasing organization. Please help.