Class ImageVideoRecorder

java.lang.Object
org.opensourcephysics.media.core.ScratchVideoRecorder
org.opensourcephysics.media.core.ImageVideoRecorder
All Implemented Interfaces:
VideoRecorder

public class ImageVideoRecorder extends ScratchVideoRecorder
This is an image video recorder that uses scratch files.
Version:
1.0
Author:
Douglas Brown
  • Field Details

    • frameCount

      protected int frameCount
  • Constructor Details

    • ImageVideoRecorder

      public ImageVideoRecorder()
      Constructs a default ImageVideoRecorder object.
    • ImageVideoRecorder

      public ImageVideoRecorder(ImageVideoType type)
      Constructs a ImageVideoRecorder object for a specific image type.
      Parameters:
      type - the image type
  • Method Details

    • getVideo

      public Video getVideo() throws IOException
      Gets the video.
      Specified by:
      getVideo in interface VideoRecorder
      Overrides:
      getVideo in class ScratchVideoRecorder
      Returns:
      the video
      Throws:
      IOException
    • saveVideo

      public String saveVideo(String fileName) throws IOException
      Saves all video images to a numbered sequence of files.
      Specified by:
      saveVideo in interface VideoRecorder
      Overrides:
      saveVideo in class ScratchVideoRecorder
      Parameters:
      fileName - the file name basis for images
      Returns:
      the full path of the first image in the sequence
      Throws:
      IOException
    • setExpectedFrameCount

      public void setExpectedFrameCount(int n)
      Sets the expected frame count.
      Parameters:
      n - the expected frame count
    • reset

      public void reset()
      Discards the current video and resets the recorder to a ready state.
      Specified by:
      reset in interface VideoRecorder
      Overrides:
      reset in class ScratchVideoRecorder
    • finalize

      protected void finalize()
      Called by the garbage collector when this recorder is no longer in use.
      Overrides:
      finalize in class ScratchVideoRecorder
    • saveScratch

      protected void saveScratch() throws IOException
      Saves the scratch images
      Specified by:
      saveScratch in class ScratchVideoRecorder
      Throws:
      IOException
    • startRecording

      protected boolean startRecording()
      Starts the video recording process.
      Specified by:
      startRecording in class ScratchVideoRecorder
      Returns:
      true if video recording successfully started
    • append

      protected boolean append(Image image)
      Appends a frame to the current video by saving the image in a tempFile.
      Specified by:
      append in class ScratchVideoRecorder
      Parameters:
      image - the image to append
      Returns:
      true if image successfully appended
    • getFileToBeSaved

      protected File getFileToBeSaved(File file)
      Return the file that will be saved if the specified file is selected. This is needed by ImageVideoRecorder since it strips and/or appends digits to the selected file name.
      Overrides:
      getFileToBeSaved in class ScratchVideoRecorder
      Parameters:
      file - the file selected with the chooser
      Returns:
      the file (or first file) to be saved
    • saveImages

      protected static String[] saveImages(String fileName, BufferedImage[] images) throws IOException
      Saves images to a numbered sequence of jpg files.
      Parameters:
      fileName - the file name basis for images
      images - the images to save
      Returns:
      the paths of the saved images
      Throws:
      IOException
    • getFileNames

      public static String[] getFileNames(String fileName, int length, String ext)
    • getBase

      protected static String getBase(String path)
    • getAppendedNumber

      protected static int getAppendedNumber(String path)
    • getCodec

      public String getCodec()