Package org.opensourcephysics.media.core
Class VideoIO
java.lang.Object
org.opensourcephysics.media.core.VideoIO
- Direct Known Subclasses:
TrackerIO
This provides static methods for managing video and text input/output.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
VideoClip and VideoRecorder need persistent loaders that must later be asynchronously finalized.static class
static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static javajs.async.AsyncFileChooser
static final String
delimiters TAB, SPACE, COMMA, SEMICOLONprotected static boolean
static final String
static final String
protected static String
protected static String
static VideoIO.SingleExtFileFilter
protected static String
protected static VideoIO.SingleExtFileFilter
static int
static VideoIO.SingleExtFileFilter
protected static VideoIO.SingleExtFileFilter
static final String[]
static javajs.async.AsyncSwingWorker
static boolean
protected static String
static final int
static final int
static final int
static final int
static final int
static final int
static final String
delimiters TAB, SPACE, COMMA, SEMICOLONprotected static Collection<VideoFileFilter>
static final String
delimiters TAB, SPACE, COMMA, SEMICOLONstatic final String
delimiters TAB, SPACE, COMMA, SEMICOLONstatic VideoIO.SingleExtFileFilter
static VideoIO.SingleExtFileFilter
static VideoIO.SingleExtFileFilter
static final String
static VideoIO.SingleExtFileFilter
protected static VideoFileFilter
static VideoIO.SingleExtFileFilter
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
VideoIO()
protected constructor to discourage instantiation -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addVideoType
(VideoType type) Adds a video type to the list of available typesstatic boolean
Determines if a file can be written.static boolean
checkMP4
(String path, LibraryBrowser libraryBrowser, VideoPanel panel) JavaScript only.static Video
Returns a clone of the specified video.static javajs.async.AsyncFileChooser
Gets the file chooser.static File[]
getChooserFilesAsync
(String type, Function<File[], Void> processFiles) Displays a file chooser and returns the chosen files.static String
Gets the delimiter for copied or exported dataGets the delimiters for copied or exported datastatic String
getExtension
(File file) Gets the extension of a file.static String[]
getImageSequencePaths
(String imagePath, Set<String> names) Gets the paths that make up an image sequence.static MovieVideoType
getMovieType
(String extension) static String
Gets the preferred file extension for video exports.static String
getRelativePath
(String absolutePath) Gets the path relative to the user directory.static Video
getVideo
(String path, String basePath, VideoType vidType, XMLControl control) Open a video from a TRK or TRZ file.static Video
Open a video from a video file opening or dropping.static String
getVideoCodec
(String path0) static String[]
Returns the currently supported video file extensionsstatic VideoType
getVideoType
(String typeName, String extension) Returns the first registered video type corresponding to a class name and/or extension.getVideoTypes
(boolean mustBeWritable) Gets an array of available video typesgetVideoTypesForPath
(String path) Gets an array of video types that can open files with a given extension.static String[]
getZippedImagePaths
(String zipPath) Gets an array of image paths inside a zip file.static void
handleUnsupportedVideo
(String path0, String ext, String codec, VideoPanel vidPanel, String why) static boolean
Determines if the current operation is canceled.static boolean
isKnownVideoExtension
(String path) Determines if a path ends with a know video extension.static void
openVideoPanelFileAsync
(File file, VideoPanel vidPanel) Loads the specified video panel from a file selected with a chooser or a video from a specified file into a VideoPanel.protected static File
processChoose
(javajs.async.AsyncFileChooser chooser, File ret, boolean isAsync) Also used by TrackerIOstatic int
progressForFraction
(double iFrame, double nFrames) static void
requiresReload
(String zipPath) Adds a zip image file path to those requiring a reload rather than cached bytes.static File
save
(File file, VideoPanel vidPanel) Writes VideoPanel data to the specified file.static File
save
(File file, VideoPanel vidPanel, String chooserTitle) Writes VideoPanel data to the specified file.static void
setCanceled
(boolean cancel) Cancels the current operation when true.static void
Sets the default xml extension used when saving data.static void
Sets the delimiter for copied or exported datastatic void
setPreferredExportExtension
(String extension) Gets the preferred file extension for video exports.static void
testExec()
test executing shell commandsstatic File
writeImageFile
(BufferedImage image, String filePath) Writes an image to a file.
-
Field Details
-
PROGRESS_LOAD_INIT
public static final int PROGRESS_LOAD_INIT- See Also:
-
PROGRESS_VIDEO_LOADING
public static final int PROGRESS_VIDEO_LOADING- See Also:
-
PROGRESS_VIDEO_PROCESSING
public static final int PROGRESS_VIDEO_PROCESSING- See Also:
-
PROGRESS_VIDEO_READY
public static final int PROGRESS_VIDEO_READY- See Also:
-
PROGRESS_COMPLETE
public static final int PROGRESS_COMPLETE- See Also:
-
PROGRESS_VIDEO_CANCELED
public static final int PROGRESS_VIDEO_CANCELED- See Also:
-
DEFAULT_PREFERRED_EXPORT_EXTENSION
- See Also:
-
DEFAULT_VIDEO_EXTENSION
- See Also:
-
KNOWN_VIDEO_EXTENSIONS
-
VIDEO_CONVERSION_HELP_PATH
- See Also:
-
TAB
delimiters TAB, SPACE, COMMA, SEMICOLON- See Also:
-
SPACE
delimiters TAB, SPACE, COMMA, SEMICOLON- See Also:
-
COMMA
delimiters TAB, SPACE, COMMA, SEMICOLON- See Also:
-
SEMICOLON
delimiters TAB, SPACE, COMMA, SEMICOLON- See Also:
-
defaultDelimiter
-
delimiters
-
delimiter
-
customDelimiters
-
zipFileFilter
-
trkFileFilter
-
trzFileFilter
-
videoAndTrkFileFilter
-
txtFileFilter
-
jarFileFilter
-
delimitedTextFileFilter
-
dataCopiedToClipboard
protected static boolean dataCopiedToClipboard -
chooser
protected static javajs.async.AsyncFileChooser chooser -
imageFileFilter
-
jpgFileFilter
-
videoTypes
-
videoFileFilter
-
singleVideoTypeFilters
-
defaultXMLExt
-
preferredExportExtension
-
loadIncrementally
public static boolean loadIncrementally -
incrementToLoad
public static int incrementToLoad -
loader
public static javajs.async.AsyncSwingWorker loader
-
-
Constructor Details
-
VideoIO
protected VideoIO()protected constructor to discourage instantiation
-
-
Method Details
-
getExtension
Gets the extension of a file.- Parameters:
file
- the file- Returns:
- the extension of the file
-
getZippedImagePaths
Gets an array of image paths inside a zip file.- Parameters:
path
- the path to the zip file OR to an image inside the zip file- Returns:
- String[] with image paths in numerical order
-
getDelimiter
Gets the delimiter for copied or exported data- Returns:
- the delimiter
-
setDelimiter
Sets the delimiter for copied or exported data- Parameters:
d
- the delimiter
-
getDelimiters
Gets the delimiters for copied or exported data- Returns:
- the delimiter map
-
getChooser
public static javajs.async.AsyncFileChooser getChooser()Gets the file chooser.- Returns:
- the file chooser
-
setDefaultXMLExtension
Sets the default xml extension used when saving data.- Parameters:
ext
- the default extension
-
getRelativePath
Gets the path relative to the user directory.- Parameters:
absolutePath
- the absolute path- Returns:
- the relative path
-
testExec
public static void testExec()test executing shell commands -
getVideoExtensions
Returns the currently supported video file extensions- Returns:
- an array of extensions
-
getPreferredExportExtension
Gets the preferred file extension for video exports.- Returns:
- the preferred extension
-
setPreferredExportExtension
Gets the preferred file extension for video exports.- Parameters:
extension
- the preferred extension
-
addVideoType
Adds a video type to the list of available types- Parameters:
type
- the video type
-
getMovieType
-
getVideoType
Returns the first registered video type corresponding to a class name and/or extension. Strings are case-insensitive.- Parameters:
typeName
- one of the predefined video type names (may be null)extension
- the extension (may be null)- Returns:
- the VideoType, or null if none found
-
getVideoTypesForPath
Gets an array of video types that can open files with a given extension.- Parameters:
ext
- the extension- Returns:
- the video types
-
getVideoTypes
Gets an array of available video types- Parameters:
canRecord
- true if we need a recorder (TrackerIO and VideoGrabber only)- Returns:
- the video types
-
requiresReload
Adds a zip image file path to those requiring a reload rather than cached bytes. This is required when a zip file is overwritten, for example- Parameters:
zipPath
-
-
setCanceled
public static void setCanceled(boolean cancel) Cancels the current operation when true.- Parameters:
cancel
- true to cancel
-
isCanceled
public static boolean isCanceled()Determines if the current operation is canceled.- Returns:
- true if canceled
-
isKnownVideoExtension
Determines if a path ends with a know video extension.- Parameters:
path
- the path- Returns:
- true if in KNOWN_VIDEO_EXTENSIONS
-
getVideoCodec
-
handleUnsupportedVideo
public static void handleUnsupportedVideo(String path0, String ext, String codec, VideoPanel vidPanel, String why) -
getVideo
Open a video from a video file opening or dropping. Returns a video from a specified path. May return null.- Parameters:
path
- the pathvidType
- a requested video type (may be null)- Returns:
- the video
-
getVideo
Open a video from a TRK or TRZ file.- Parameters:
path
-basePath
-vidType
-control
-- Returns:
-
clone
Returns a clone of the specified video. Never called.- Parameters:
video
- the video to clone- Returns:
- the clone
-
canWrite
Determines if a file can be written. If the file exists, the user is prompted for approval to overwrite.- Parameters:
file
- the file to check- Returns:
- true if the file can be written
-
getChooserFilesAsync
Displays a file chooser and returns the chosen files. The parameter "type" can be "open", "save video", "save resource", "save image", "open image". There are more types defined in TrackerIO.getChooserFilesAsync- Parameters:
type
- StringprocessFiles
- asynchronous follower method- Returns:
- the files, or null if no files chosen or asynchronous
-
processChoose
protected static File processChoose(javajs.async.AsyncFileChooser chooser, File ret, boolean isAsync) Also used by TrackerIO- Parameters:
chooser
-ret
-isAsync
-- Returns:
-
openVideoPanelFileAsync
Loads the specified video panel from a file selected with a chooser or a video from a specified file into a VideoPanel. If file is null, a file chooser is displayed.- Parameters:
file
- the file to be loadedvidPanel
- the video panel
-
save
Writes VideoPanel data to the specified file. If the file is null it brings up a chooser.- Parameters:
file
- the file to write tovidPanel
- the video panel- Returns:
- the file written to, or null if not written
-
save
Writes VideoPanel data to the specified file. If the file is null it displays a filechooser.- Parameters:
file
- the file to write tovidPanel
- the video panelchooserTitle
- the title for the filechooser- Returns:
- the file written to, or null if not written
-
writeImageFile
Writes an image to a file.- Parameters:
image
- the image to writefilePath
- the path to write to, including extension (png, jpg, gif)- Returns:
- the file written, or null if failed
-
getImageSequencePaths
Gets the paths that make up an image sequence.- Parameters:
imagePath
- the path to the first imagenames
- a set of names of available numbered images- Returns:
- array of full paths to all images in sequence
-
checkMP4
JavaScript only. Check for a valid video codec and file format. Handle it if it is an MP4 or MOV with unsupported codec From JSMovieVideo.load, TFrame.loadVideo, TrackerIO.AsyncLoader.loadVideo- Parameters:
path
-libraryBrowser
-- Returns:
- true if not JS or not an mp4 and not mov, or not is a valid mp4/mov
-
progressForFraction
public static int progressForFraction(double iFrame, double nFrames)
-