cordova-plugin-video-editor-fork
v0.0.4
Published
This is a cordova plugin to assist in several video editing tasks such as:
Downloads
5
Readme
This is a cordova plugin to assist in several video editing tasks such as:
- Transcoding
- Trimming
- Taking still images from time moments (currently the start of a video)
After looking at an article on How Vine Satisfied Its Need for Speed, it was clear Cordova/Phonegap needed a way to modify videos to be faster for app's that need that speed.
This plugin will address those concerns, hopefully.
Installation
cordova plugin add https://github.com/jbavari/cordova-plugin-video-editor.git
VideoEditor
and VideoEditorOptions
will be available in the window after deviceready.
Usage
###Transcode###
// parameters passed to transcodeVideo
VideoEditor.transcodeVideo(
success, // success cb
error, // error cb
{
fileUri: 'file-uri-here', // the path to the video on the device
outputFileName: 'output-name', // the file name for the transcoded video
quality: VideoEditorOptions.Quality.MEDIUM_QUALITY,
outputFileType: VideoEditorOptions.OutputFileType.MPEG4,
optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES,
duration: 20, // optional, specify duration in seconds from start of video
saveToLibrary: true // optional, defaults to true
}
)
// options used with transcodeVideo function
var VideoEditorOptions = {
Quality: {
HIGH_QUALITY: 0,
MEDIUM_QUALITY: 1,
LOW_QUALITY: 2
},
OptimizeForNetworkUse: {
NO: 0,
YES: 1
},
OutputFileType: {
M4V: 0,
MPEG4: 1,
M4A: 2,
QUICK_TIME: 3
}
};
// this example uses the cordova media capture plugin
navigator.device.capture.captureVideo(
videoCaptureSuccess,
videoCaptureError,
{
limit: 1,
duration: 20
}
);
function videoCaptureSuccess(mediaFiles) {
var file = mediaFiles[0];
var videoFileName = 'video-name-here'; // I suggest a uuid
// Wrap this call in a ~100 ms timeout on Android if
// you just recorded the video using the capture plugin.
// For some reason it is not available immediately in the file system.
VideoEditor.transcodeVideo(
videoTranscodeSuccess,
videoTranscodeError,
{
fileUri: file.fullPath,
outputFileName: videoFileName,
quality: VideoEditorOptions.Quality.MEDIUM_QUALITY,
outputFileType: VideoEditorOptions.OutputFileType.MPEG4,
optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES,
duration: 20
}
);
}
function videoTranscodeSuccess(result) {
// result is the path to the transcoded video on the device
console.log('videoTranscodeSuccess, result: ' + result);
}
function videoTranscodeError(err) {
console.log('videoTranscodeError, err: ' + err);
}
###Create JPEG Image From Video###
VideoEditor.createThumbnail(
success, // success cb
error, // error cb
{
fileUri: 'file-uri-here', // the path to the video on the device
outputFileName: 'output-name' // the file name for the JPEG image
}
)
// this example uses the cordova media capture plugin
navigator.device.capture.captureVideo(
videoCaptureSuccess,
videoCaptureError,
{
limit: 1,
duration: 20
}
);
function videoCaptureSuccess(mediaFiles) {
var file = mediaFiles[0];
var videoFileName = 'video-name-here'; // I suggest a uuid
// Wrap this call in a ~100 ms timeout on Android if
// you just recorded the video using the capture plugin.
// For some reason it is not available immediately in the file system.
VideoEditor.createThumbnail(
createThumbnailSuccess,
createThumbnailError,
{
fileUri: mediaFile.fullPath,
outputFileName: videoFileName
}
)
}
function createThumbnailSuccess(result) {
// result is the path to the jpeg image on the device
console.log('createThumbnailSuccess, result: ' + result);
}
On iOS
iOS Developer AVFoundation Documentation
Video compression in AVFoundation
AVFoundation slides - tips/tricks
Bob McCune's AVFoundation Editor - ios app example
Saving videos after recording videos
On Android
How to Port ffmpeg (the Program) to Android–Ideas and Thoughts
How to Build Android Applications Based on FFmpeg by An Example
License
Android: GPL
iOS: MIT