Package org.opensourcephysics.media.core
Class ImageVideoRecorder
java.lang.Object
org.opensourcephysics.media.core.ScratchVideoRecorder
org.opensourcephysics.media.core.ImageVideoRecorder
- All Implemented Interfaces:
VideoRecorder
This is an image video recorder that uses scratch files.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Field Summary
FieldsFields inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
baseDir, canRecord, chooser, chooserField, chosenExtension, dim, ext, frameDuration, frameImage, hasContent, ignoreChooser, isSaved, saveChanges, saveFile, scratchFile, scratchName, scratchNumber, suggestedFileName, tempDirectory, tempFilePrefix, tempFiles, videoType -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default ImageVideoRecorder object.Constructs a ImageVideoRecorder object for a specific image type. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAppends a frame to the current video by saving the image in a tempFile.protected voidfinalize()Called by the garbage collector when this recorder is no longer in use.protected static intgetAppendedNumber(String path) protected static StringgetCodec()static String[]getFileNames(String fileName, int length, String ext) protected FilegetFileToBeSaved(File file) Return the file that will be saved if the specified file is selected.getVideo()Gets the video.voidreset()Discards the current video and resets the recorder to a ready state.protected static String[]saveImages(String fileName, BufferedImage[] images) Saves images to a numbered sequence of jpg files.protected voidSaves the scratch imagesSaves all video images to a numbered sequence of files.voidsetExpectedFrameCount(int n) Sets the expected frame count.protected booleanStarts the video recording process.Methods inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
addFrame, createScratch, createVideo, createVideo, createVideo, deleteFiles, deleteTempFiles, getFileName, getScratchExtension, getVideoType, saveVideo, saveVideoAs, selectFile, setChooserExtension, setFileName, setFrameDuration, setSize, suggestFileName
-
Field Details
-
frameCount
protected int frameCount
-
-
Constructor Details
-
ImageVideoRecorder
public ImageVideoRecorder()Constructs a default ImageVideoRecorder object. -
ImageVideoRecorder
Constructs a ImageVideoRecorder object for a specific image type.- Parameters:
type- the image type
-
-
Method Details
-
getVideo
Gets the video.- Specified by:
getVideoin interfaceVideoRecorder- Overrides:
getVideoin classScratchVideoRecorder- Returns:
- the video
- Throws:
IOException
-
saveVideo
Saves all video images to a numbered sequence of files.- Specified by:
saveVideoin interfaceVideoRecorder- Overrides:
saveVideoin classScratchVideoRecorder- 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:
resetin interfaceVideoRecorder- Overrides:
resetin classScratchVideoRecorder
-
finalize
protected void finalize()Called by the garbage collector when this recorder is no longer in use.- Overrides:
finalizein classScratchVideoRecorder
-
saveScratch
Saves the scratch images- Specified by:
saveScratchin classScratchVideoRecorder- Throws:
IOException
-
startRecording
protected boolean startRecording()Starts the video recording process.- Specified by:
startRecordingin classScratchVideoRecorder- Returns:
- true if video recording successfully started
-
append
Appends a frame to the current video by saving the image in a tempFile.- Specified by:
appendin classScratchVideoRecorder- Parameters:
image- the image to append- Returns:
- true if image successfully appended
-
getFileToBeSaved
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:
getFileToBeSavedin classScratchVideoRecorder- Parameters:
file- the file selected with the chooser- Returns:
- the file (or first file) to be saved
-
saveImages
Saves images to a numbered sequence of jpg files.- Parameters:
fileName- the file name basis for imagesimages- the images to save- Returns:
- the paths of the saved images
- Throws:
IOException
-
getFileNames
-
getBase
-
getAppendedNumber
-
getCodec
-