public class VideoOptimizer
extends java.lang.Object
Constructor and Description |
---|
VideoOptimizer() |
Modifier and Type | Method and Description |
---|---|
int |
getVideoBitrate(java.lang.String videoFile)
Get the average bitrate (in bits/sec), or -1 in case of error.
|
long |
getVideoDuration(java.lang.String videoFile)
Returns the duration of the videoFile in seconds, or -1 in case of error
|
java.lang.String |
getVideoPreview(java.lang.String videoFile)
Extract a frame from the given video and returns a jpeg file, or null in
case of error
|
com.codename1.ui.geom.Dimension |
getVideoSize(java.lang.String videoFile)
Returns the size of the given video, or null in case of error
|
void |
optimizeVideoForUpload(java.lang.String videoFile,
com.codename1.util.OnComplete<java.lang.String> onCompleteCallback,
java.lang.Runnable onFailureCallback,
OnProgress onProgressCallback)
Asynchronous method to optimize a video for fast upload and maximum
compatibility: it produces a new mp4 file placed in FileSystemStorage (it
ensures to don't overwrite any existing file); note that it produces
always an "mp4" file even if the source video is in QuickTime format.
|
public long getVideoDuration(java.lang.String videoFile)
videoFile
- placed in FileSystemStoragepublic java.lang.String getVideoPreview(java.lang.String videoFile)
videoFile
- placed in FileSystemStoragepublic int getVideoBitrate(java.lang.String videoFile)
videoFile
- placed in FileSystemStoragepublic com.codename1.ui.geom.Dimension getVideoSize(java.lang.String videoFile)
videoFile
- placed in FileSystemStoragepublic void optimizeVideoForUpload(java.lang.String videoFile, com.codename1.util.OnComplete<java.lang.String> onCompleteCallback, java.lang.Runnable onFailureCallback, OnProgress onProgressCallback)
Asynchronous method to optimize a video for fast upload and maximum compatibility: it produces a new mp4 file placed in FileSystemStorage (it ensures to don't overwrite any existing file); note that it produces always an "mp4" file even if the source video is in QuickTime format.
This method is cpu-intensive and it can require a time to complete longer than the video duration.
It throws an IllegalStateException if you invoke this method when there is an ongoing video optimization: you must wait that it finishes before invoking this method again.
videoFile
- placed in FileSystemStorageonCompleteCallback
- executed when the saving of the new video is
completedonFailureCallback
- generic callback in case of error, note that
errors are logged by the EDTonProgressCallback
- generic callback invoked every second to update
the UI with the progress percentage (from 0 to 99)