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 boolean
Appends a frame to the current video by saving the image in a tempFile.protected void
finalize()
Called by the garbage collector when this recorder is no longer in use.protected static int
getAppendedNumber
(String path) protected static String
getCodec()
static String[]
getFileNames
(String fileName, int length, String ext) protected File
getFileToBeSaved
(File file) Return the file that will be saved if the specified file is selected.getVideo()
Gets the video.void
reset()
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 void
Saves the scratch imagesSaves all video images to a numbered sequence of files.void
setExpectedFrameCount
(int n) Sets the expected frame count.protected boolean
Starts 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:
getVideo
in interfaceVideoRecorder
- Overrides:
getVideo
in classScratchVideoRecorder
- Returns:
- the video
- Throws:
IOException
-
saveVideo
Saves all video images to a numbered sequence of files.- Specified by:
saveVideo
in interfaceVideoRecorder
- Overrides:
saveVideo
in 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:
reset
in interfaceVideoRecorder
- Overrides:
reset
in classScratchVideoRecorder
-
finalize
protected void finalize()Called by the garbage collector when this recorder is no longer in use.- Overrides:
finalize
in classScratchVideoRecorder
-
saveScratch
Saves the scratch images- Specified by:
saveScratch
in classScratchVideoRecorder
- Throws:
IOException
-
startRecording
protected boolean startRecording()Starts the video recording process.- Specified by:
startRecording
in 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:
append
in 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:
getFileToBeSaved
in 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
-