UNPKG

4.95 kBTypeScriptView Raw
1export interface TranscodeOptions {
2 /** The path to the video on the device. */
3 fileUri: string;
4 /** The file name for the transcoded video */
5 outputFileName: string;
6 /** Instructions on how to encode the video. Android is always mp4 */
7 outputFileType?: number;
8 /** Should the video be processed with quailty or speed in mind. iOS only */
9 optimizeForNetworkUse?: number;
10 /** Save the new video the library. Not supported in windows. Defaults to true */
11 saveToLibrary?: boolean;
12 /** Delete the original video. Android only. Defaults to false */
13 deleteInputFile?: boolean;
14 /** iOS only. Defaults to true */
15 maintainAspectRatio?: boolean;
16 /** Width of the result */
17 width?: number;
18 /** Height of the result */
19 height?: number;
20 /** Bitrate in bits. Defaults to 1 megabit (1000000). */
21 videoBitrate?: number;
22 /** Frames per second of the result. Android only. Defaults to 24. */
23 fps?: number;
24 /** Number of audio channels. iOS only. Defaults to 2. */
25 audioChannels?: number;
26 /** Sample rate for the audio. iOS only. Defaults to 44100*/
27 audioSampleRate?: number;
28 /** Sample rate for the audio. iOS only. Defaults to 128 kilobits (128000). */
29 audioBitrate?: number;
30 /** Not supported in windows, progress on the transcode. info will be a number from 0 to 100 */
31 progress?: (info: number) => void;
32}
33export interface TrimOptions {
34 /** Path to input video. */
35 fileUri: string;
36 /** Time to start trimming in seconds */
37 trimStart: number;
38 /** Time to end trimming in seconds */
39 trimEnd: number;
40 /** Output file name */
41 outputFileName: string;
42 /** Progress on transcode. info will be a number from 0 to 100 */
43 progress?: (info: any) => void;
44}
45export interface CreateThumbnailOptions {
46 /** The path to the video on the device */
47 fileUri: string;
48 /** The file name for the JPEG image */
49 outputFileName: string;
50 /** Location in the video to create the thumbnail (in seconds) */
51 atTime?: number;
52 /** Width of the thumbnail. */
53 width?: number;
54 /** Height of the thumbnail. */
55 height?: number;
56 /** Quality of the thumbnail (between 1 and 100). */
57 quality?: number;
58}
59export interface GetVideoInfoOptions {
60 /** The path to the video on the device. */
61 fileUri: string;
62}
63export interface VideoInfo {
64 /** Width of the video in pixels. */
65 width: number;
66 /** Height of the video in pixels. */
67 height: number;
68 /** Orientation of the video. Will be either portrait or landscape. */
69 orientation: 'portrait' | 'landscape';
70 /** Duration of the video in seconds. */
71 duration: number;
72 /** Size of the video in bytes. */
73 size: number;
74 /** Bitrate of the video in bits per second. */
75 bitrate: number;
76}
77/**
78 * @name VideoEditor
79 * @description Edit videos using native device APIs
80 *
81 * @usage
82 * ```
83 * import {VideoEditor} from 'ionic-native';
84 *
85 * VideoEditor.transcodeVideo({
86 * fileUri: '/path/to/input.mov',
87 * outputFileName: 'output.mp4',
88 * outputFileType: VideoEditor.OutputFileType.MPEG4
89 * })
90 * .then((fileUri: string) => console.log('video transcode success', fileUri))
91 * .catch((error: any) => console.log('video transcode error', error));
92 *
93 * ```
94 * @interfaces
95 * TranscodeOptions
96 * TrimOptions
97 * CreateThumbnailOptions
98 * GetVideoInfoOptions
99 * VideoInfo
100 */
101export declare class VideoEditor {
102 static OptimizeForNetworkUse: {
103 NO: number;
104 YES: number;
105 };
106 static OutputFileType: {
107 M4V: number;
108 MPEG4: number;
109 M4A: number;
110 QUICK_TIME: number;
111 };
112 /**
113 * Transcode a video
114 * @param options {TranscodeOptions} Options
115 * @returns {Promise<string>} Returns a promise that resolves to the path of the transcoded video
116 */
117 static transcodeVideo(options: TranscodeOptions): Promise<string>;
118 /**
119 * Trim a video
120 * @param options {TrimOptions} Options
121 * @returns {Promise<string>} Returns a promise that resolves to the path of the trimmed video
122 */
123 static trim(options: TrimOptions): Promise<string>;
124 /**
125 * Create a JPEG thumbnail from a video
126 * @param options {CreateThumbnailOptions} Options
127 * @returns {Promise<string>} Returns a promise that resolves to the path to the jpeg image on the device
128 */
129 static createThumbnail(options: CreateThumbnailOptions): Promise<string>;
130 /**
131 * Get info on a video (width, height, orientation, duration, size, & bitrate)
132 * @param options {GetVideoInfoOptions} Options
133 * @returns {Promise<VideoInfo>} Returns a promise that resolves to an object containing info on the video
134 */
135 static getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
136}