Add jsdoc comments to ffmpeg lib. Also added types for tsc where they were implicit any type. Also added some semi-colons. Whoops.
This commit is contained in:
parent
5695bfd645
commit
7c4e9d5823
|
@ -5,6 +5,13 @@ const fs_extra_1 = require("fs-extra");
|
|||
const exec_1 = require("exec");
|
||||
let system = {};
|
||||
let TMPDIR;
|
||||
/**
|
||||
* Add padding to a number to 5 places. Return a string.
|
||||
*
|
||||
* @param {integer} i Integer to pad
|
||||
*
|
||||
* @returns {string} Padded string
|
||||
**/
|
||||
function padded_frame(i) {
|
||||
let len = (i + '').length;
|
||||
let str = i + '';
|
||||
|
@ -13,6 +20,14 @@ function padded_frame(i) {
|
|||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Render a single frame from a video or image to a png.
|
||||
*
|
||||
* @param {object} state State object containing file data
|
||||
* @param {object} light Object containing color information for frame
|
||||
*
|
||||
* @returns {string} Path of frame
|
||||
**/
|
||||
async function frame(state, light) {
|
||||
const frameNum = state.frame;
|
||||
const video = state.path;
|
||||
|
@ -66,8 +81,17 @@ async function frame(state, light) {
|
|||
console.log(`"${output2.stdout}"`);
|
||||
return tmpoutput;
|
||||
}
|
||||
/**
|
||||
* Render all frames in a video to the temp directory.
|
||||
* Not in use.
|
||||
*
|
||||
* @param {string} video Path to video
|
||||
* @param {object} obj Not sure
|
||||
*
|
||||
* @returns {?}
|
||||
**/
|
||||
async function frames(video, obj) {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let ext = 'tif';
|
||||
let tmpoutput;
|
||||
//if (system.platform !== 'nix') {
|
||||
|
@ -82,8 +106,15 @@ async function frames(video, obj) {
|
|||
}
|
||||
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
|
||||
}
|
||||
/**
|
||||
* Clears a specific frame from the tmp directory
|
||||
*
|
||||
* @param {integer} frame Integer of frame to clear
|
||||
*
|
||||
* @returns {boolean} True if successful, false if not
|
||||
**/
|
||||
async function clear(frame) {
|
||||
let padded = padded_frame(frame);
|
||||
const padded = padded_frame(frame);
|
||||
let ext = 'tif';
|
||||
let tmppath;
|
||||
let tmpoutput;
|
||||
|
@ -110,8 +141,12 @@ async function clear(frame) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Delete all frames in temp directory.
|
||||
*
|
||||
**/
|
||||
async function clearAll() {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let files;
|
||||
try {
|
||||
files = await fs_extra_1.readdir(tmppath);
|
||||
|
@ -130,6 +165,10 @@ async function clearAll() {
|
|||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if mcopy temp directory exists. If it doesn't,
|
||||
* create it.
|
||||
**/
|
||||
async function checkDir() {
|
||||
let fileExists;
|
||||
try {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,MAAM,QAAQ,GAAY,KAAK,CAAC,KAAK,CAAA;IACrC,MAAM,KAAK,GAAY,KAAK,CAAC,IAAI,CAAA;IACjC,MAAM,CAAC,GAAY,KAAK,CAAC,IAAI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ACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"}
|
|
@ -5,6 +5,13 @@ const fs_extra_1 = require("fs-extra");
|
|||
const exec_1 = require("exec");
|
||||
let system = {};
|
||||
let TMPDIR;
|
||||
/**
|
||||
* Add padding to a number to 5 places. Return a string.
|
||||
*
|
||||
* @param {integer} i Integer to pad
|
||||
*
|
||||
* @returns {string} Padded string
|
||||
**/
|
||||
function padded_frame(i) {
|
||||
let len = (i + '').length;
|
||||
let str = i + '';
|
||||
|
@ -13,6 +20,14 @@ function padded_frame(i) {
|
|||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Render a single frame from a video or image to a png.
|
||||
*
|
||||
* @param {object} state State object containing file data
|
||||
* @param {object} light Object containing color information for frame
|
||||
*
|
||||
* @returns {string} Path of frame
|
||||
**/
|
||||
async function frame(state, light) {
|
||||
const frameNum = state.frame;
|
||||
const video = state.path;
|
||||
|
@ -66,8 +81,17 @@ async function frame(state, light) {
|
|||
console.log(`"${output2.stdout}"`);
|
||||
return tmpoutput;
|
||||
}
|
||||
/**
|
||||
* Render all frames in a video to the temp directory.
|
||||
* Not in use.
|
||||
*
|
||||
* @param {string} video Path to video
|
||||
* @param {object} obj Not sure
|
||||
*
|
||||
* @returns {?}
|
||||
**/
|
||||
async function frames(video, obj) {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let ext = 'tif';
|
||||
let tmpoutput;
|
||||
//if (system.platform !== 'nix') {
|
||||
|
@ -82,8 +106,15 @@ async function frames(video, obj) {
|
|||
}
|
||||
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
|
||||
}
|
||||
/**
|
||||
* Clears a specific frame from the tmp directory
|
||||
*
|
||||
* @param {integer} frame Integer of frame to clear
|
||||
*
|
||||
* @returns {boolean} True if successful, false if not
|
||||
**/
|
||||
async function clear(frame) {
|
||||
let padded = padded_frame(frame);
|
||||
const padded = padded_frame(frame);
|
||||
let ext = 'tif';
|
||||
let tmppath;
|
||||
let tmpoutput;
|
||||
|
@ -110,8 +141,12 @@ async function clear(frame) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Delete all frames in temp directory.
|
||||
*
|
||||
**/
|
||||
async function clearAll() {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let files;
|
||||
try {
|
||||
files = await fs_extra_1.readdir(tmppath);
|
||||
|
@ -130,6 +165,10 @@ async function clearAll() {
|
|||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if mcopy temp directory exists. If it doesn't,
|
||||
* create it.
|
||||
**/
|
||||
async function checkDir() {
|
||||
let fileExists;
|
||||
try {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,MAAM,QAAQ,GAAY,KAAK,CAAC,KAAK,CAAA;IACrC,MAAM,KAAK,GAAY,KAAK,CAAC,IAAI,CAAA;IACjC,MAAM,CAAC,GAAY,KAAK,CAAC,IAAI,CAAC,KAAK,CAAA;IACnC,MAAM,CAAC,GAAY,KAAK,CAAC,I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,13 @@ const fs_extra_1 = require("fs-extra");
|
|||
const exec_1 = require("exec");
|
||||
let system = {};
|
||||
let TMPDIR;
|
||||
/**
|
||||
* Add padding to a number to 5 places. Return a string.
|
||||
*
|
||||
* @param {integer} i Integer to pad
|
||||
*
|
||||
* @returns {string} Padded string
|
||||
**/
|
||||
function padded_frame(i) {
|
||||
let len = (i + '').length;
|
||||
let str = i + '';
|
||||
|
@ -13,6 +20,14 @@ function padded_frame(i) {
|
|||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Render a single frame from a video or image to a png.
|
||||
*
|
||||
* @param {object} state State object containing file data
|
||||
* @param {object} light Object containing color information for frame
|
||||
*
|
||||
* @returns {string} Path of frame
|
||||
**/
|
||||
async function frame(state, light) {
|
||||
const frameNum = state.frame;
|
||||
const video = state.path;
|
||||
|
@ -66,8 +81,17 @@ async function frame(state, light) {
|
|||
console.log(`"${output2.stdout}"`);
|
||||
return tmpoutput;
|
||||
}
|
||||
/**
|
||||
* Render all frames in a video to the temp directory.
|
||||
* Not in use.
|
||||
*
|
||||
* @param {string} video Path to video
|
||||
* @param {object} obj Not sure
|
||||
*
|
||||
* @returns {?}
|
||||
**/
|
||||
async function frames(video, obj) {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let ext = 'tif';
|
||||
let tmpoutput;
|
||||
//if (system.platform !== 'nix') {
|
||||
|
@ -82,8 +106,15 @@ async function frames(video, obj) {
|
|||
}
|
||||
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
|
||||
}
|
||||
/**
|
||||
* Clears a specific frame from the tmp directory
|
||||
*
|
||||
* @param {integer} frame Integer of frame to clear
|
||||
*
|
||||
* @returns {boolean} True if successful, false if not
|
||||
**/
|
||||
async function clear(frame) {
|
||||
let padded = padded_frame(frame);
|
||||
const padded = padded_frame(frame);
|
||||
let ext = 'tif';
|
||||
let tmppath;
|
||||
let tmpoutput;
|
||||
|
@ -110,8 +141,12 @@ async function clear(frame) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Delete all frames in temp directory.
|
||||
*
|
||||
**/
|
||||
async function clearAll() {
|
||||
let tmppath = TMPDIR;
|
||||
const tmppath = TMPDIR;
|
||||
let files;
|
||||
try {
|
||||
files = await fs_extra_1.readdir(tmppath);
|
||||
|
@ -130,6 +165,10 @@ async function clearAll() {
|
|||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if mcopy temp directory exists. If it doesn't,
|
||||
* create it.
|
||||
**/
|
||||
async function checkDir() {
|
||||
let fileExists;
|
||||
try {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,MAAM,QAAQ,GAAY,KAAK,CAAC,KAAK,CAAA;IACrC,MAAM,KAAK,GAAY,KAAK,CAAC,IAAI,CAAA;IACjC,MAAM,CAAC,GAAY,KAAK,CAAC,IAAI,CAAC,KAAK,CAAA;IACnC,MAAM,CAAC,GAAY,KAAK,CAAC,IAAI,CAAC,MAAM,CAAA;IACpC,MAAM,MAAM,GAAY,YAAY,CAA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||||
import uuid from 'uuid/v4';
|
||||
import { join } from 'path';
|
||||
import { exists, mkdir, readdir, unlink } from 'fs-extra';
|
||||
|
@ -10,6 +12,14 @@ import { exit } from 'exit';
|
|||
let system : any = {};
|
||||
let TMPDIR : string;
|
||||
|
||||
/**
|
||||
* Add padding to a number to 5 places. Return a string.
|
||||
*
|
||||
* @param {integer} i Integer to pad
|
||||
*
|
||||
* @returns {string} Padded string
|
||||
**/
|
||||
|
||||
function padded_frame (i : number) {
|
||||
let len = (i + '').length;
|
||||
let str = i + '';
|
||||
|
@ -19,13 +29,21 @@ function padded_frame (i : number) {
|
|||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a single frame from a video or image to a png.
|
||||
*
|
||||
* @param {object} state State object containing file data
|
||||
* @param {object} light Object containing color information for frame
|
||||
*
|
||||
* @returns {string} Path of frame
|
||||
**/
|
||||
async function frame (state : any, light : any) {
|
||||
const frameNum : number = state.frame
|
||||
const video : string = state.path
|
||||
const w : number = state.info.width
|
||||
const h : number = state.info.height
|
||||
const padded : string = padded_frame(frameNum)
|
||||
let ext : string = 'tif'
|
||||
const frameNum : number = state.frame;
|
||||
const video : string = state.path;
|
||||
const w : number = state.info.width;
|
||||
const h : number = state.info.height;
|
||||
const padded : string = padded_frame(frameNum);
|
||||
let ext : string = 'tif';
|
||||
let rgb : any[] = light.color;
|
||||
let tmpoutput : string;
|
||||
let cmd : string;
|
||||
|
@ -78,10 +96,19 @@ async function frame (state : any, light : any) {
|
|||
return tmpoutput
|
||||
}
|
||||
|
||||
/**
|
||||
* Render all frames in a video to the temp directory.
|
||||
* Not in use.
|
||||
*
|
||||
* @param {string} video Path to video
|
||||
* @param {object} obj Not sure
|
||||
*
|
||||
* @returns {?}
|
||||
**/
|
||||
async function frames (video : string, obj : any) {
|
||||
let tmppath = TMPDIR;
|
||||
let ext = 'tif';
|
||||
let tmpoutput;
|
||||
const tmppath : string = TMPDIR;
|
||||
let ext : string = 'tif';
|
||||
let tmpoutput : string;
|
||||
|
||||
//if (system.platform !== 'nix') {
|
||||
ext = 'png';
|
||||
|
@ -97,13 +124,20 @@ async function frames (video : string, obj : any) {
|
|||
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears a specific frame from the tmp directory
|
||||
*
|
||||
* @param {integer} frame Integer of frame to clear
|
||||
*
|
||||
* @returns {boolean} True if successful, false if not
|
||||
**/
|
||||
async function clear (frame : number) {
|
||||
let padded = padded_frame(frame);
|
||||
let ext = 'tif';
|
||||
let tmppath;
|
||||
let tmpoutput;
|
||||
let cmd;
|
||||
let fileExists;
|
||||
const padded : string = padded_frame(frame);
|
||||
let ext : string = 'tif';
|
||||
let tmppath : string;
|
||||
let tmpoutput : string;
|
||||
let cmd : string;
|
||||
let fileExists : boolean;
|
||||
|
||||
//if (system.platform !== 'nix') {
|
||||
ext = 'png';
|
||||
|
@ -129,9 +163,13 @@ async function clear (frame : number) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all frames in temp directory.
|
||||
*
|
||||
**/
|
||||
async function clearAll () {
|
||||
let tmppath = TMPDIR;
|
||||
let files;
|
||||
const tmppath : string = TMPDIR;
|
||||
let files : any;
|
||||
try {
|
||||
files = await readdir(tmppath);
|
||||
} catch (err) {
|
||||
|
@ -148,8 +186,12 @@ async function clearAll () {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if mcopy temp directory exists. If it doesn't,
|
||||
* create it.
|
||||
**/
|
||||
async function checkDir () {
|
||||
let fileExists;
|
||||
let fileExists : boolean;
|
||||
try {
|
||||
fileExists = await exists(TMPDIR);
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in New Issue