1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /*
- FFmpeg.js
- ArozOS FFMPEG FACTORY conversion backend
- This script is designed to do server side conversion only.
- For the client-side conversion function, see
- ffmpeg.wasm and the related files for more information.
- Required parameters
- INPUT (input filepath)
- OUTPUT (output filepath)
- COMPRESS (optional, output compression)
- */
- requirelib("filelib");
- requirelib("ffmpeg");
- function main(){
- //Check if the input and output are valid
- if (typeof(INPUT) == "undefined" || typeof(OUTPUT) == "undefined"){
- //Invalid input or output
- sendJSONResp(JSON.stringify({
- "error":"invalid INTPUT or OUTPUT given"
- }));
- return;
- }
- //Check if input exists
- if (!filelib.fileExists(INPUT)){
- sendJSONResp(JSON.stringify({
- "error":"INTPUT file not exists"
- }));
- return;
- }
- var compressionRate = 0;
- if (typeof(COMP) != "undefined"){
- compressionRate = parseInt(COMP)
- }
- console.log("Using compression rate " + compressionRate);
- //Ok. Proceed with conversion
- var succ = ffmpeg.convert(INPUT, OUTPUT, compressionRate);
- if (succ){
- sendJSONResp(JSON.stringify("ok"));
- }else{
- sendJSONResp(JSON.stringify({
- "error":"ffmpeg reports a conversion error"
- }));
- }
-
- }
- //Run the main conversion logic
- main();
|