-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba37646
commit 9b4502f
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; | ||
|
||
export interface VideoInformation { | ||
format: { | ||
bit_rate: string; | ||
duration: string; | ||
filename: string; | ||
format_name: string; | ||
nb_programs: string; | ||
nb_streams: string; | ||
probe_score: string; | ||
size: string; | ||
start_time: string; | ||
}; | ||
[key: string]: any; | ||
} | ||
|
||
/** | ||
* @name FFMpeg | ||
* @description | ||
* Simple plugin that binds mobile ffmpeg to execute ffmpeg commands | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx'; | ||
* | ||
* | ||
* constructor(private ffMpeg: FFMpeg) { } | ||
* | ||
* ... | ||
* | ||
* | ||
* this.fFMpeg.exec('-i someinput.mp4 -vn -c:a copy out.mp3') | ||
* .then((res: any) => console.log(res)) | ||
* .catch((error: any) => console.error(error)); | ||
* | ||
* | ||
* this.fFMpeg.probe('somefile.mp4"') | ||
* .then((res: VideoInformation) => console.log(res)) | ||
* .catch((error: any) => console.error(error)); | ||
* | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'FFMpeg', | ||
plugin: 'cordova-plugin-ffmpeg', | ||
pluginRef: 'ffmpeg', | ||
repo: 'https://github.com/MaximBelov/cordova-plugin-ffmpeg', | ||
platforms: ['Android', 'iOS'], | ||
}) | ||
@Injectable() | ||
export class FFMpeg extends AwesomeCordovaNativePlugin { | ||
/** | ||
* Execute ffmpeg command | ||
* @param cmd {string} command | ||
* @return {Promise<any>} Returns a promise that resolves when execute finished | ||
*/ | ||
@Cordova() | ||
exec(cmd: string): Promise<any> { | ||
return; | ||
} | ||
|
||
/** | ||
* Extracts media information for the file specified with path | ||
* @param filePath {string} file path | ||
* @return {Promise<VideoInformation>} Returns a promise that resolves when media information received | ||
*/ | ||
@Cordova() | ||
probe(filePath: string): Promise<VideoInformation> { | ||
return; | ||
} | ||
} |