public interface VideoEditor
release()
Modifier and Type | Interface and Description |
---|---|
static interface |
VideoEditor.ExportProgressListener
This listener interface is used by the VideoEditor to emit export status
notifications.
|
static interface |
VideoEditor.MediaProcessingProgressListener |
static class |
VideoEditor.OverlayData
The overlay data
|
static interface |
VideoEditor.PreviewProgressListener
This listener interface is used by the VideoEditor to emit preview
progress notifications.
|
Modifier and Type | Field and Description |
---|---|
static int |
DURATION_OF_STORYBOARD
Use this value instead of the specific end of the storyboard timeline
value.
|
static long |
MAX_SUPPORTED_FILE_SIZE
Maximum supported file size
|
static String |
THUMBNAIL_FILENAME
The file name of the project thumbnail
|
Modifier and Type | Method and Description |
---|---|
void |
addAudioTrack(AudioTrack audioTrack)
Add the specified AudioTrack to the storyboard.
|
void |
addMediaItem(MediaItem mediaItem)
Add a media item at the end of the storyboard.
|
void |
addTransition(Transition transition)
Add a transition between the media items specified by the transition.
|
void |
cancelExport(String filename)
Cancel the running export operation.
|
void |
clearSurface(SurfaceHolder surfaceHolder)
Clears the preview surface
|
void |
export(String filename,
int height,
int bitrate,
int audioCodec,
int videoCodec,
VideoEditor.ExportProgressListener listener)
Create the output movie based on all media items added and the applied
storyboard items.
|
void |
export(String filename,
int height,
int bitrate,
VideoEditor.ExportProgressListener listener)
Create the output movie based on all media items added and the applied
storyboard items.
|
void |
generatePreview(VideoEditor.MediaProcessingProgressListener listener)
This method must be called after any changes made to the storyboard
and before startPreview is called.
|
List<AudioTrack> |
getAllAudioTracks()
Get the list of AudioTracks in order in which they appear in the
storyboard.
|
List<MediaItem> |
getAllMediaItems()
Get the list of media items in the order in which it they appear in the
storyboard timeline.
|
List<Transition> |
getAllTransitions()
Get the list of transitions
|
int |
getAspectRatio()
Get current aspect ratio.
|
AudioTrack |
getAudioTrack(String audioTrackId)
Find the AudioTrack with the specified id
|
long |
getDuration()
Get the preview (and output movie) duration.
|
MediaItem |
getMediaItem(String mediaItemId)
Find the media item with the specified id
|
String |
getPath() |
Transition |
getTransition(String transitionId)
Find the transition with the specified transition id.
|
void |
insertAudioTrack(AudioTrack audioTrack,
String afterAudioTrackId)
Insert an audio track after the audio track with the specified id.
|
void |
insertMediaItem(MediaItem mediaItem,
String afterMediaItemId)
Insert a media item after the media item with the specified id.
|
void |
moveAudioTrack(String audioTrackId,
String afterAudioTrackId)
Move an AudioTrack after the AudioTrack with the specified id.
|
void |
moveMediaItem(String mediaItemId,
String afterMediaItemId)
Move a media item after the media item with the specified id.
|
void |
release()
This method releases all in-memory resources used by the VideoEditor
instance.
|
void |
removeAllMediaItems()
Remove all media items in the storyboard.
|
AudioTrack |
removeAudioTrack(String audioTrackId)
Remove the audio track with the specified id.
|
MediaItem |
removeMediaItem(String mediaItemId)
Remove the media item with the specified id.
|
Transition |
removeTransition(String transitionId)
Remove the transition with the specified id.
|
long |
renderPreviewFrame(SurfaceHolder surfaceHolder,
long timeMs,
VideoEditor.OverlayData overlayData)
Render a frame according to the preview aspect ratio and activating all
storyboard items relative to the specified time.
|
void |
save()
Persist the current internal state of VideoEditor to the project path.
|
void |
setAspectRatio(int aspectRatio)
Set the aspect ratio used in the preview and the export movie.
|
void |
startPreview(SurfaceHolder surfaceHolder,
long fromMs,
long toMs,
boolean loop,
int callbackAfterFrameCount,
VideoEditor.PreviewProgressListener listener)
Start the preview of all the storyboard items applied on all MediaItems
This method does not block (does not wait for the preview to complete).
|
long |
stopPreview()
Stop the current preview.
|
static final String THUMBNAIL_FILENAME
static final int DURATION_OF_STORYBOARD
static final long MAX_SUPPORTED_FILE_SIZE
String getPath()
void release()
void save() throws IOException
VideoEditorFactory#load(String)
method. This method does not
release the internal in-memory state of the VideoEditor. To release
the in-memory state of the VideoEditor the release()
method
must be invoked.
Pending transition generations must be allowed to complete before the
state is saved.
Pending audio waveform generations must be allowed to complete.
Pending export operations must be allowed to continue.IOException
- if the internal state cannot be saved to project filevoid export(String filename, int height, int bitrate, VideoEditor.ExportProgressListener listener) throws IOException
filename
- The output file name (including the full path)height
- The height of the output video file. The supported values
for height are described in the MediaProperties class, for
example: HEIGHT_480. The width will be automatically computed
according to the aspect ratio provided by
setAspectRatio(int)
bitrate
- The bitrate of the output video file. This is approximate
value for the output movie. Supported bitrate values are
described in the MediaProperties class for example: BITRATE_384Klistener
- The listener for progress notifications. Use null if
export progress notifications are not needed.IllegalArgumentException
- if height or bitrate are not supported
or if the audio or video codecs are not supportedIOException
- if output file cannot be createdIllegalStateException
- if a preview or an export is in progress or
if no MediaItem has been addedCancellationException
- if export is canceled by calling
#cancelExport()
UnsupportOperationException
- if multiple simultaneous export() are
not allowedvoid export(String filename, int height, int bitrate, int audioCodec, int videoCodec, VideoEditor.ExportProgressListener listener) throws IOException
filename
- The output file name (including the full path)height
- The height of the output video file. The supported values
for height are described in the MediaProperties class, for
example: HEIGHT_480. The width will be automatically computed
according to the aspect ratio provided by
setAspectRatio(int)
bitrate
- The bitrate of the output video file. This is approximate
value for the output movie. Supported bitrate values are
described in the MediaProperties class for example: BITRATE_384KaudioCodec
- The audio codec to be used for the export. The audio
codec values are defined in the MediaProperties class (e.g.
ACODEC_AAC_LC). Note that not all audio codec types are
supported for export purposes.videoCodec
- The video codec to be used for the export. The video
codec values are defined in the MediaProperties class (e.g.
VCODEC_H264). Note that not all video codec types are
supported for export purposes.listener
- The listener for progress notifications. Use null if
export progress notifications are not needed.IllegalArgumentException
- if height or bitrate are not supported
or if the audio or video codecs are not supportedIOException
- if output file cannot be createdIllegalStateException
- if a preview or an export is in progress or
if no MediaItem has been addedCancellationException
- if export is cancelled by calling
#cancelExport()
UnsupportOperationException
- if multiple simultaneous export() are
not allowedvoid cancelExport(String filename)
filename
- The filename which identifies the export operation to be
canceled.void addMediaItem(MediaItem mediaItem)
mediaItem
- The media item object to addIllegalStateException
- if a preview or an export is in progress or
if the media item id is not unique across all the media items
added.void insertMediaItem(MediaItem mediaItem, String afterMediaItemId)
mediaItem
- The media item object to insertafterMediaItemId
- Insert the mediaItem after the media item
identified by this id. If this parameter is null, the media
item is inserted at the beginning of the timeline.IllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if media item with the specified id does
not exist (null is a valid value) or if the media item id is
not unique across all the media items added.void moveMediaItem(String mediaItemId, String afterMediaItemId)
mediaItemId
- The id of the media item to moveafterMediaItemId
- Move the media item identified by mediaItemId
after the media item identified by this parameter. If this
parameter is null, the media item is moved at the beginning of
the timeline.IllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if one of media item ids is invalid
(null is a valid value)MediaItem removeMediaItem(String mediaItemId)
mediaItemId
- The unique id of the media item to be removedIllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if media item with the specified id does
not existvoid removeAllMediaItems()
IllegalStateException
- if a preview or an export is in progressList<MediaItem> getAllMediaItems()
MediaItem getMediaItem(String mediaItemId)
mediaItemId
- The media item idvoid addTransition(Transition transition)
Transition.generate()
method must be invoked to generate
the transition video clip.
Note that the TransitionAtEnd and TransitionAtStart are special kinds
that can not be applied between two media items.
A crossfade audio transition will be automatically applied regardless of
the video transition.transition
- The transition to applyIllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if the transition duration is larger
than the smallest duration of the two media item files or if
the two media items specified in the transition are not
adjacentTransition removeTransition(String transitionId)
transitionId
- The id of the transition to be removedIllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if transition with the specified id does
not existList<Transition> getAllTransitions()
Transition getTransition(String transitionId)
transitionId
- The transition idvoid addAudioTrack(AudioTrack audioTrack)
audioTrack
- The AudioTrack to addUnsupportedOperationException
- if the implementation supports a
limited number of audio tracks.IllegalArgumentException
- if media item is not unique across all
the audio tracks already added.void insertAudioTrack(AudioTrack audioTrack, String afterAudioTrackId)
audioTrack
- The audio track object to insertafterAudioTrackId
- Insert the audio track after the audio track
identified by this parameter. If this parameter is null the
audio track is added at the beginning of the timeline.IllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if media item with the specified id does
not exist (null is a valid value). if media item is not unique
across all the audio tracks already added.UnsupportedOperationException
- if the implementation supports a
limited number of audio tracksvoid moveAudioTrack(String audioTrackId, String afterAudioTrackId)
audioTrackId
- The id of the AudioTrack to moveafterAudioTrackId
- Move the AudioTrack identified by audioTrackId
after the AudioTrack identified by this parameter. If this
parameter is null the audio track is added at the beginning of
the timeline.IllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if one of media item ids is invalid
(null is a valid value)AudioTrack removeAudioTrack(String audioTrackId)
audioTrackId
- The id of the audio track to be removedIllegalStateException
- if a preview or an export is in progressList<AudioTrack> getAllAudioTracks()
AudioTrack getAudioTrack(String audioTrackId)
audioTrackId
- The AudioTrack idvoid setAspectRatio(int aspectRatio)
aspectRatio
- to apply. If aspectRatio is the same as the current
aspect ratio, then this function just returns. The supported
aspect ratio are defined in the MediaProperties class for
example: ASPECTRATIO_16_9IllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if aspect ratio is not supportedint getAspectRatio()
long getDuration()
long renderPreviewFrame(SurfaceHolder surfaceHolder, long timeMs, VideoEditor.OverlayData overlayData)
surfaceHolder
- SurfaceHolder used by the applicationtimeMs
- time corresponding to the frame to displayoverlayData
- The overlay dataIllegalStateException
- if a preview or an export is already in
progressIllegalArgumentException
- if time is negative or beyond the
preview durationvoid generatePreview(VideoEditor.MediaProcessingProgressListener listener)
void startPreview(SurfaceHolder surfaceHolder, long fromMs, long toMs, boolean loop, int callbackAfterFrameCount, VideoEditor.PreviewProgressListener listener)
surfaceHolder
- SurfaceHolder where the preview is rendered.fromMs
- The time (relative to the timeline) at which the preview
will starttoMs
- The time (relative to the timeline) at which the preview will
stop. Use -1 to play to the end of the timelineloop
- true if the preview should be looped once it reaches the endcallbackAfterFrameCount
- The listener interface should be invoked
after the number of frames specified by this parameter.listener
- The listener which will be notified of the preview
progressIllegalArgumentException
- if fromMs is beyond the preview durationIllegalStateException
- if a preview or an export is already in
progresslong stopPreview()
void clearSurface(SurfaceHolder surfaceHolder)
surfaceHolder
- SurfaceHolder where the preview is rendered
and needs to be cleared.