|
@@ -1,8 +1,8 @@
|
|
import { spawnSync } from 'child_process';
|
|
import { spawnSync } from 'child_process';
|
|
|
|
+import { closeSync, readFileSync, writeSync } from 'fs';
|
|
import * as temp from 'temp';
|
|
import * as temp from 'temp';
|
|
|
|
|
|
import { getLogger } from './loggers';
|
|
import { getLogger } from './loggers';
|
|
-import { readFileSync, writeSync, closeSync } from 'fs';
|
|
|
|
|
|
|
|
const logger = getLogger('gifski');
|
|
const logger = getLogger('gifski');
|
|
|
|
|
|
@@ -13,7 +13,7 @@ export default function (data: ArrayBuffer) {
|
|
const inputFile = temp.openSync();
|
|
const inputFile = temp.openSync();
|
|
writeSync(inputFile.fd, Buffer.from(data));
|
|
writeSync(inputFile.fd, Buffer.from(data));
|
|
closeSync(inputFile.fd);
|
|
closeSync(inputFile.fd);
|
|
- logger.info(`saved video file to ${inputFile.path}, starting gif conversion...`)
|
|
|
|
|
|
+ logger.info(`saved video file to ${inputFile.path}, starting gif conversion...`);
|
|
const args = [
|
|
const args = [
|
|
'--fps',
|
|
'--fps',
|
|
'12.5',
|
|
'12.5',
|
|
@@ -22,15 +22,15 @@ export default function (data: ArrayBuffer) {
|
|
'80',
|
|
'80',
|
|
'-o',
|
|
'-o',
|
|
outputFilePath,
|
|
outputFilePath,
|
|
- inputFile.path
|
|
|
|
|
|
+ inputFile.path,
|
|
];
|
|
];
|
|
logger.info(` gifski ${args.join(' ')}`);
|
|
logger.info(` gifski ${args.join(' ')}`);
|
|
const gifskiInvocation = spawnSync('gifski', args, {encoding: 'utf8', timeout: 90000});
|
|
const gifskiInvocation = spawnSync('gifski', args, {encoding: 'utf8', timeout: 90000});
|
|
if (gifskiInvocation.stderr) throw Error(gifskiInvocation.stderr);
|
|
if (gifskiInvocation.stderr) throw Error(gifskiInvocation.stderr);
|
|
- logger.info(`gif conversion succeeded, file path: ${outputFilePath}`)
|
|
|
|
|
|
+ logger.info(`gif conversion succeeded, file path: ${outputFilePath}`);
|
|
return readFileSync(outputFilePath).buffer;
|
|
return readFileSync(outputFilePath).buffer;
|
|
} catch (error) {
|
|
} catch (error) {
|
|
logger.error('error converting video to gif' + error ? `message: ${error}` : '');
|
|
logger.error('error converting video to gif' + error ? `message: ${error}` : '');
|
|
throw Error('error converting video to gif');
|
|
throw Error('error converting video to gif');
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|