Video Editor
Edit videos using native device APIs
Repo: https://github.com/jbavari/cordova-plugin-video-editor
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-video-editor $ npm install --save @ionic-native/video-editor@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows
- Windows Phone 8
Usage
import { VideoEditor } from '@ionic-native/video-editor';
constructor(private videoEditor: VideoEditor) { }
...
this.videoEditor.transcodeVideo({
fileUri: '/path/to/input.mov',
outputFileName: 'output.mp4',
outputFileType: VideoEditor.OutputFileType.MPEG4
})
.then((fileUri: string) => console.log('video transcode success', fileUri))
.catch((error: any) => console.log('video transcode error', error));
Instance Members
OptimizeForNetworkUse
OutputFileType
transcodeVideo(options)
Transcode a video
Param | Type | Details |
---|---|---|
options |
TranscodeOptions
|
Options |
Returns: Promise<string>
Returns a promise that resolves to the path of the transcoded video
trim(options)
Platforms:iOS
Trim a video
Param | Type | Details |
---|---|---|
options |
TrimOptions
|
Options |
Returns: Promise<string>
Returns a promise that resolves to the path of the trimmed video
createThumbnail(options)
Create a JPEG thumbnail from a video
Param | Type | Details |
---|---|---|
options |
CreateThumbnailOptions
|
Options |
Returns: Promise<string>
Returns a promise that resolves to the path to the jpeg image on the device
getVideoInfo(options)
Get info on a video (width, height, orientation, duration, size, & bitrate)
Param | Type | Details |
---|---|---|
options |
GetVideoInfoOptions
|
Options |
Returns: Promise<VideoInfo>
Returns a promise that resolves to an object containing info on the video
TranscodeOptions
Param | Type | Details |
---|---|---|
fileUri |
string
|
The path to the video on the device. |
outputFileName |
string
|
The file name for the transcoded video |
outputFileType |
number
|
Instructions on how to encode the video. Android is always mp4 (optional) |
optimizeForNetworkUse |
number
|
Should the video be processed with quailty or speed in mind. iOS only (optional) |
saveToLibrary |
boolean
|
Save the new video the library. Not supported in windows. Defaults to true (optional) |
deleteInputFile |
boolean
|
Delete the original video. Android only. Defaults to false (optional) |
maintainAspectRatio |
boolean
|
iOS only. Defaults to true (optional) |
width |
number
|
Width of the result (optional) |
height |
number
|
Height of the result (optional) |
videoBitrate |
number
|
Bitrate in bits. Defaults to 1 megabit (1000000). (optional) |
fps |
number
|
Frames per second of the result. Android only. Defaults to 24. (optional) |
audioChannels |
number
|
Number of audio channels. iOS only. Defaults to 2. (optional) |
audioSampleRate |
number
|
(optional) |
audioBitrate |
number
|
Sample rate for the audio. iOS only. Defaults to 128 kilobits (128000). (optional) |
progress |
(info: number) => void
|
Not supported in windows, progress on the transcode. info will be a number from 0 to 100 (optional) |
TrimOptions
Param | Type | Details |
---|---|---|
fileUri |
string
|
Path to input video. |
trimStart |
number
|
Time to start trimming in seconds |
trimEnd |
number
|
Time to end trimming in seconds |
outputFileName |
string
|
Output file name |
progress |
(info: any) => void
|
Progress on transcode. info will be a number from 0 to 100 (optional) |
CreateThumbnailOptions
Param | Type | Details |
---|---|---|
fileUri |
string
|
The path to the video on the device |
outputFileName |
string
|
The file name for the JPEG image |
atTime |
number
|
Location in the video to create the thumbnail (in seconds) (optional) |
width |
number
|
Width of the thumbnail. (optional) |
height |
number
|
Height of the thumbnail. (optional) |
quality |
number
|
Quality of the thumbnail (between 1 and 100). (optional) |
GetVideoInfoOptions
Param | Type | Details |
---|---|---|
fileUri |
string
|
The path to the video on the device. |
VideoInfo
Param | Type | Details |
---|---|---|
width |
number
|
Width of the video in pixels. |
height |
number
|
Height of the video in pixels. |
orientation |
'portrait' | 'landscape'
|
Orientation of the video. Will be either portrait or landscape. |
duration |
number
|
Duration of the video in seconds. |
size |
number
|
Size of the video in bytes. |
bitrate |
number
|
Bitrate of the video in bits per second. |