Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3a561ad6c3
51
frameloom
51
frameloom
|
@ -21,7 +21,7 @@ let TMPPATH;
|
|||
**/
|
||||
async function exec(cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return execRaw(cmd, (err, stdio, stderr) => {
|
||||
return execRaw(cmd, { maxBuffer: 500 * 1024 * 1024 }, (err, stdio, stderr) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
return resolve(stdio);
|
||||
|
@ -86,6 +86,11 @@ function shuffle(array) {
|
|||
array[j] = temp;
|
||||
}
|
||||
}
|
||||
function randomInt(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
/**
|
||||
* Clears the temporary directory of all files.
|
||||
* Establishes a directory if none exists.
|
||||
|
@ -388,6 +393,50 @@ async function randomSort(list, pattern, realtime) {
|
|||
}
|
||||
return newList;
|
||||
}
|
||||
async function spinFrames() {
|
||||
let frames;
|
||||
let framePath;
|
||||
let cmd;
|
||||
let flip;
|
||||
let flop;
|
||||
let rotate;
|
||||
console.log('Spinning frames...');
|
||||
try {
|
||||
frames = await fs.readdir(TMPPATH);
|
||||
}
|
||||
catch (err) {
|
||||
console.error('Error reading tmp directory', err);
|
||||
}
|
||||
//console.dir(frames)
|
||||
frames = frames.filter(file => {
|
||||
if (file.indexOf('.tif') !== -1)
|
||||
return true;
|
||||
});
|
||||
for (let frame of frames) {
|
||||
framePath = path.join(TMPPATH, frame);
|
||||
rotate = '';
|
||||
flip = '';
|
||||
flop = '';
|
||||
if (randomInt(0, 1) === 1) {
|
||||
rotate = '-rotate 180 ';
|
||||
}
|
||||
if (randomInt(0, 1) === 1) {
|
||||
flip = '-flip ';
|
||||
}
|
||||
if (randomInt(0, 1) === 1) {
|
||||
flop = '-flop ';
|
||||
}
|
||||
cmd = `convert ${framePath} ${rotate}${flip}${flop} ${framePath}`;
|
||||
console.log(cmd);
|
||||
try {
|
||||
await exec(cmd);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
process.exit(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Render the frames into a video using ffmpeg.
|
||||
*
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "11.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.0.tgz",
|
||||
"integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==",
|
||||
"version": "11.13.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.4.tgz",
|
||||
"integrity": "sha512-+rabAZZ3Yn7tF/XPGHupKIL5EcAbrLxnTr/hgQICxbeuAfWtT0UZSfULE+ndusckBItcv4o6ZeOJplQikVcLvQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ajv": {
|
||||
|
@ -2984,9 +2984,9 @@
|
|||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.1.tgz",
|
||||
"integrity": "sha512-3NSMb2VzDQm8oBTLH6Nj55VVtUEpe/rgkIzMir0qVoLyjDZlnMBva0U6vDiV3IH+sl/Yu6oP5QwsAQtHPmDd2Q==",
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.3.tgz",
|
||||
"integrity": "sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ==",
|
||||
"dev": true
|
||||
},
|
||||
"typical": {
|
||||
|
|
|
@ -25,5 +25,11 @@
|
|||
"pkg": "^4.3.5",
|
||||
"qunit": "^2.8.0",
|
||||
"typescript": "^3.4.1"
|
||||
},
|
||||
"pkg": {
|
||||
"scripts": [
|
||||
"./frameloom",
|
||||
"./lib/**/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ let TMPPATH : string
|
|||
**/
|
||||
async function exec (cmd : string) {
|
||||
return new Promise((resolve : any, reject : any) => {
|
||||
return execRaw(cmd, (err : any, stdio : string, stderr : string) => {
|
||||
return execRaw(cmd, { maxBuffer : 500 * 1024 * 1024}, (err : any, stdio : string, stderr : string) => {
|
||||
if (err) return reject(err)
|
||||
return resolve(stdio)
|
||||
})
|
||||
|
@ -89,6 +89,13 @@ function shuffle (array : any[]) {
|
|||
array[j] = temp
|
||||
}
|
||||
}
|
||||
|
||||
function randomInt (min : number, max : number) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the temporary directory of all files.
|
||||
* Establishes a directory if none exists.
|
||||
|
@ -409,6 +416,53 @@ async function randomSort (list : string[], pattern : number[], realtime : boole
|
|||
|
||||
return newList
|
||||
}
|
||||
|
||||
async function spinFrames () {
|
||||
let frames : string[]
|
||||
let framePath : string
|
||||
let cmd : string
|
||||
let flip : string
|
||||
let flop : string
|
||||
let rotate : string
|
||||
|
||||
console.log('Spinning frames...')
|
||||
|
||||
try {
|
||||
frames = await fs.readdir(TMPPATH)
|
||||
} catch (err) {
|
||||
console.error('Error reading tmp directory', err)
|
||||
}
|
||||
|
||||
//console.dir(frames)
|
||||
frames = frames.filter (file =>{
|
||||
if (file.indexOf('.tif') !== -1) return true
|
||||
})
|
||||
|
||||
for (let frame of frames) {
|
||||
framePath = path.join(TMPPATH, frame)
|
||||
rotate = ''
|
||||
flip = ''
|
||||
flop = ''
|
||||
if (randomInt(0, 1) === 1) {
|
||||
rotate = '-rotate 180 '
|
||||
}
|
||||
if (randomInt(0, 1) === 1) {
|
||||
flip = '-flip '
|
||||
}
|
||||
if (randomInt(0, 1) === 1) {
|
||||
flop = '-flop '
|
||||
}
|
||||
cmd = `convert ${framePath} ${rotate}${flip}${flop} ${framePath}`
|
||||
console.log(cmd)
|
||||
try {
|
||||
await exec(cmd)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
process.exit(10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the frames into a video using ffmpeg.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue