{"_id":"@bazuka5801/cordova-plugin-video-editor","_rev":"1-ae9befc130b7a6b6bde19288fe3146b4","name":"@bazuka5801/cordova-plugin-video-editor","dist-tags":{"latest":"1.1.6"},"versions":{"1.1.5":{"name":"@bazuka5801/cordova-plugin-video-editor","version":"1.1.5","keywords":[],"author":{"name":"Josh Bavari"},"license":"MIT","_id":"@bazuka5801/cordova-plugin-video-editor@1.1.5","maintainers":[{"name":"bazuka5801","email":"bazuka5801@mail.ru"}],"contributors":[{"url":"https://twitter.com/jbavari","name":"Josh Bavari","email":"jbavari@gmail.com"},{"url":"https://twitter.com/MountainDoofus","name":"Ross Martin","email":"rmartin311@gmail.com"}],"homepage":"https://github.com/bazuka5801/cordova-plugin-video-editor#readme","bugs":{"url":"https://github.com/bazuka5801/cordova-plugin-video-editor/issues"},"dist":{"shasum":"8ddd3a71650dc2fe262b8f9d02df54792c68fb53","tarball":"https://registry.npmjs.org/@bazuka5801/cordova-plugin-video-editor/-/cordova-plugin-video-editor-1.1.5.tgz","fileCount":25,"integrity":"sha512-ae+KKOa6JV1NCmGQjNsbIhKxt7EWdAbS3uhZss7qAXbRBQyuJkyHeRqdg0JW7C7uzTpwVzJCMO8bwp5pSMF+uA==","signatures":[{"sig":"MEUCIQDnMDSRhx3SQeak+8ISEEdm2LxavJKgd9g9OWxL1wiV9AIgUMQoryuIigA/6h/aYZPfS02hjykSFNTrFXVcfOZWNcY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":119230},"access":"public","cordova":{"id":"cordova-plugin-video-editor","platforms":["android","ios"]},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"bazuka5801","email":"bazuka5801@mail.ru"},"repository":{"url":"git+https://github.com/bazuka5801/cordova-plugin-video-editor.git","type":"git"},"description":"Cordova Video Editor Plugin","directories":{},"licenseText":"# Licenses\n\n## Android version\n\nApache 2.0\n\n## iOS version\n\nMIT\n\n## Windows version\n\nApache 2.0\n","_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_npmOperationalInternal":{"tmp":"tmp/cordova-plugin-video-editor_1.1.5_1738680582942_0.558565593777905","host":"s3://npm-registry-packages-npm-production"}},"1.1.6":{"name":"@bazuka5801/cordova-plugin-video-editor","version":"1.1.6","description":"Cordova Video Editor Plugin","access":"public","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"cordova":{"id":"cordova-plugin-video-editor","platforms":["android","ios"]},"keywords":[],"repository":{"type":"git","url":"git+https://github.com/bazuka5801/cordova-plugin-video-editor.git"},"contributors":[{"name":"Josh Bavari","email":"jbavari@gmail.com","url":"https://twitter.com/jbavari"},{"name":"Ross Martin","email":"rmartin311@gmail.com","url":"https://twitter.com/MountainDoofus"}],"author":{"name":"Josh Bavari"},"license":"MIT","bugs":{"url":"https://github.com/bazuka5801/cordova-plugin-video-editor/issues"},"homepage":"https://github.com/bazuka5801/cordova-plugin-video-editor#readme","packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","licenseText":"# Licenses\n\n## Android version\n\nApache 2.0\n\n## iOS version\n\nMIT\n\n## Windows version\n\nApache 2.0\n","_id":"@bazuka5801/cordova-plugin-video-editor@1.1.6","dist":{"shasum":"526ff76e16dc498122ab2f80fc0e656eb3b52c99","integrity":"sha512-j0/jYtzusH5Ido70VW3gdDEkIncWNLk/h6elcZRXbP3PHxD0XqRecpdCmpaNl+Kjp7lA8BFA/lfmulkcXLvPsg==","tarball":"https://registry.npmjs.org/@bazuka5801/cordova-plugin-video-editor/-/cordova-plugin-video-editor-1.1.6.tgz","fileCount":25,"unpackedSize":119241,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB6VIQwVGrreYHIZRunQ3sb4m8YeujCfJAdVGX1ArMhAAiB3hBoL9HoE3J+bjZ840cQjvEz63ic8hdQffqdc8pk0Dg=="}]},"_npmUser":{"name":"bazuka5801","email":"bazuka5801@mail.ru"},"directories":{},"maintainers":[{"name":"bazuka5801","email":"bazuka5801@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cordova-plugin-video-editor_1.1.6_1738680719654_0.6645684166938668"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-04T14:49:42.823Z","modified":"2025-02-04T14:52:00.017Z","1.1.5":"2025-02-04T14:49:43.124Z","1.1.6":"2025-02-04T14:51:59.834Z"},"bugs":{"url":"https://github.com/bazuka5801/cordova-plugin-video-editor/issues"},"author":{"name":"Josh Bavari"},"license":"MIT","homepage":"https://github.com/bazuka5801/cordova-plugin-video-editor#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/bazuka5801/cordova-plugin-video-editor.git"},"description":"Cordova Video Editor Plugin","contributors":[{"name":"Josh Bavari","email":"jbavari@gmail.com","url":"https://twitter.com/jbavari"},{"name":"Ross Martin","email":"rmartin311@gmail.com","url":"https://twitter.com/MountainDoofus"}],"maintainers":[{"name":"bazuka5801","email":"bazuka5801@mail.ru"}],"readme":"[![npm version](https://badge.fury.io/js/cordova-plugin-video-editor.svg)](https://badge.fury.io/js/cordova-plugin-video-editor)\n\nThis is a cordova plugin to assist in several video editing tasks such as:\n\n* Transcoding\n* Trimming\n* Creating thumbnails from a video file (now at a specific time in the video)\n* Getting info on a video - width, height, orientation, duration, size, & bitrate.\n\nAfter looking at an article on [How Vine Satisfied Its Need for Speed](http://www.technologyreview.com/view/510511/how-vine-satisfies-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.\n\nThis plugin will address those concerns, hopefully.\n\n## Installation\n```\ncordova plugin add cordova-plugin-video-editor\n```\n`VideoEditor` and `VideoEditorOptions` will be available in the window after deviceready.\n\n## Usage\n\n### Transcode a video\n\n```javascript\n// parameters passed to transcodeVideo\nVideoEditor.transcodeVideo(\n    success, // success cb\n    error, // error cb\n    {\n        fileUri: 'file-uri-here', // the path to the video on the device\n        outputFileName: 'output-name', // the file name for the transcoded video\n        outputFileType: VideoEditorOptions.OutputFileType.MPEG4, // android is always mp4\n        optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES, // ios only\n        saveToLibrary: true, // optional, defaults to true\n        deleteInputFile: false, // optional (android only), defaults to false\n        maintainAspectRatio: true, // optional (ios only), defaults to true\n        width: 640, // optional, see note below on width and height\n        height: 640, // optional, see notes below on width and height\n        videoBitrate: 1000000, // optional, bitrate in bits, defaults to 1 megabit (1000000)\n        fps: 24, // optional (android only), defaults to 24\n        audioChannels: 2, // optional (ios only), number of audio channels, defaults to 2\n        audioSampleRate: 44100, // optional (ios only), sample rate for the audio, defaults to 44100\n        audioBitrate: 128000, // optional (ios only), audio bitrate for the video in bits, defaults to 128 kilobits (128000)\n        progress: function(info) {} // info will be a number from 0 to 100\n    }\n);\n```\n#### A note on width and height used by transcodeVideo\nI recommend setting `maintainAspectRatio` to true.  When this option is true you can provide any width/height and the height provided will be used to calculate the new width for the output video.  If you set `maintainAspectRatio` false there is a good chance you'll end up with videos that are stretched and/or distorted.  Here is the simplified formula used on iOS when `maintainAspectRatio` is true -\n```objective-c\naspectRatio = videoWidth / videoHeight;\noutputWidth = height * aspectRatio;\noutputHeight = outputWidth / aspectRatio;\n```\n\nAndroid will always use the aspect ratio of the input video to calculate the scaled output width and height.  Setting `maintainAspectRatio` on android will make not make a difference.\n\nIf you don't provide width and height to `transcodeVideo` the output video will have the same dimensions as the input video.\n\n#### transcodeVideo example -\n```javascript\n// options used with transcodeVideo function\n// VideoEditorOptions is global, no need to declare it\nvar VideoEditorOptions = {\n    OptimizeForNetworkUse: {\n        NO: 0,\n        YES: 1\n    },\n    OutputFileType: {\n        M4V: 0,\n        MPEG4: 1,\n        M4A: 2,\n        QUICK_TIME: 3\n    }\n};\n```\n```javascript\n// this example uses the cordova media capture plugin\nnavigator.device.capture.captureVideo(\n    videoCaptureSuccess,\n    videoCaptureError,\n    {\n        limit: 1,\n        duration: 20\n    }\n);\n\nfunction videoCaptureSuccess(mediaFiles) {\n    // Wrap this below in a ~100 ms timeout on Android if\n    // you just recorded the video using the capture plugin.\n    // For some reason it is not available immediately in the file system.\n\n    var file = mediaFiles[0];\n    var videoFileName = 'video-name-here'; // I suggest a uuid\n\n    VideoEditor.transcodeVideo(\n        videoTranscodeSuccess,\n        videoTranscodeError,\n        {\n            fileUri: file.fullPath,\n            outputFileName: videoFileName,\n            outputFileType: VideoEditorOptions.OutputFileType.MPEG4,\n            optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES,\n            saveToLibrary: true,\n            maintainAspectRatio: true,\n            width: 640,\n            height: 640,\n            videoBitrate: 1000000, // 1 megabit\n            audioChannels: 2,\n            audioSampleRate: 44100,\n            audioBitrate: 128000, // 128 kilobits\n            progress: function(info) {\n                console.log('transcodeVideo progress callback, info: ' + info);\n            }\n        }\n    );\n}\n\nfunction videoTranscodeSuccess(result) {\n\t// result is the path to the transcoded video on the device\n    console.log('videoTranscodeSuccess, result: ' + result);\n}\n\nfunction videoTranscodeError(err) {\n\tconsole.log('videoTranscodeError, err: ' + err);\n}\n```\n\n#### Windows Quirks\nWindows does not support any of the optional parameters at this time. Specifying them will not cause an error but, there is no functionality behind them.\n\n### Trim a Video (iOS only)\n```javascript\nVideoEditor.trim(\n    trimSuccess,\n    trimFail,\n    {\n        fileUri: 'file-uri-here', // path to input video\n        trimStart: 5, // time to start trimming in seconds\n        trimEnd: 15, // time to end trimming in seconds\n        outputFileName: 'output-name', // output file name\n        progress: function(info) {} // optional, see docs on progress\n    }\n);\n\nfunction trimSuccess(result) {\n    // result is the path to the trimmed video on the device\n    console.log('trimSuccess, result: ' + result);\n}\n\nfunction trimFail(err) {\n    console.log('trimFail, err: ' + err);\n}\n```\n\n### Create a JPEG thumbnail from a video\n```javascript\nVideoEditor.createThumbnail(\n    success, // success cb\n    error, // error cb\n    {\n        fileUri: 'file-uri-here', // the path to the video on the device\n        outputFileName: 'output-name', // the file name for the JPEG image\n        atTime: 2, // optional, location in the video to create the thumbnail (in seconds)\n        width: 320, // optional, width of the thumbnail\n        height: 480, // optional, height of the thumbnail\n        quality: 100 // optional, quality of the thumbnail (between 1 and 100)\n    }\n);\n// atTime will default to 0 if not provided\n// width and height will be the same as the video input if they are not provided\n// quality will default to 100 if not provided\n```\n\n```javascript\n// this example uses the cordova media capture plugin\nnavigator.device.capture.captureVideo(\n    videoCaptureSuccess,\n    videoCaptureError,\n    {\n        limit: 1,\n        duration: 20\n    }\n);\n\nfunction videoCaptureSuccess(mediaFiles) {\n    // Wrap this below in a ~100 ms timeout on Android if\n    // you just recorded the video using the capture plugin.\n    // For some reason it is not available immediately in the file system.\n\n    var file = mediaFiles[0];\n    var videoFileName = 'video-name-here'; // I suggest a uuid\n\n    VideoEditor.createThumbnail(\n        createThumbnailSuccess,\n        createThumbnailError,\n        {\n            fileUri: file.fullPath,\n            outputFileName: videoFileName,\n            atTime: 2,\n            width: 320,\n            height: 480,\n            quality: 100\n        }\n    );\n}\n\nfunction createThumbnailSuccess(result) {\n    // result is the path to the jpeg image on the device\n    console.log('createThumbnailSuccess, result: ' + result);\n}\n```\n\n#### A note on width and height used by createThumbnail\nThe aspect ratio of the thumbnail created will match that of the video input.  This means you may not get exactly the width and height dimensions you give to `createThumbnail` for the jpeg.  This for your convenience but let us know if it is a problem.  I am considering adding a `maintainAspectRatio` option to `createThumbnail` (and when this option is false you might have stretched, square thumbnails :laughing:).\n\n### Get info on a video (width, height, orientation, duration, size, & bitrate)\n```javascript\nVideoEditor.getVideoInfo(\n    success, // success cb\n    error, // error cb\n    {\n        fileUri: 'file-uri-here', // the path to the video on the device\n    }\n);\n```\n\n```javascript\nVideoEditor.getVideoInfo(\n    getVideoInfoSuccess,\n    getVideoInfoError,\n    {\n        fileUri: file.fullPath\n    }\n);\n\nfunction getVideoInfoSuccess(info) {\n    console.log('getVideoInfoSuccess, info: ' + JSON.stringify(info, null, 2));\n    // info is a JSON object with the following properties -\n    {\n        width: 1920,\n        height: 1080,\n        orientation: 'landscape', // will be portrait or landscape\n        duration: 3.541, // duration in seconds\n        size: 6830126, // size of the video in bytes\n        bitrate: 15429777 // bitrate of the video in bits per second\n    }\n}\n```\n\n## Android & FFmpeg\nFFmpeg has been removed from android for several reasons but mainly for performance.  If you still need the old functionality that FFmpeg provided  [V1.09](https://github.com/jbavari/cordova-plugin-video-editor/tree/1.0.9) is the last version that will use it.\n\n## On iOS\n\n[iOS Developer AVFoundation Documentation](https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/01_UsingAssets.html#//apple_ref/doc/uid/TP40010188-CH7-SW8)\n\n[Video compression in AVFoundation](http://www.iphonedevsdk.com/forum/iphone-sdk-development/110246-video-compression-avassetwriter-in-avfoundation.html)\n\n[AVFoundation slides - tips/tricks](https://speakerdeck.com/bobmccune/composing-and-editing-media-with-av-foundation)\n\n[AVFoundation slides #2](http://www.slideshare.net/bobmccune/learning-avfoundation)\n\n[Bob McCune's AVFoundation Editor - ios app example](https://github.com/tapharmonic/AVFoundationEditor)\n\n[Saving videos after recording videos](http://stackoverflow.com/questions/20902234/save-video-to-library-after-capturing-video-using-phonegap-capturevideo)\n\n\n\n## On Android\n\n[Android Documentation](http://developer.android.com/guide/appendix/media-formats.html#recommendations)\n\n[Android Media Stores](http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY)\n\n[How to Port ffmpeg (the Program) to Android–Ideas and Thoughts](http://www.roman10.net/how-to-port-ffmpeg-the-program-to-androidideas-and-thoughts/)\n\n[How to Build Android Applications Based on FFmpeg by An Example](http://www.roman10.net/how-to-build-android-applications-based-on-ffmpeg-by-an-example/)\n\n\n## On Windows\n\n\n## License\n\nAndroid: Apache 2.0\n\niOS: MIT\n\nWindows: Apache 2.0\n","readmeFilename":"README.md"}