2019-03-21 18:58:00 +00:00
|
|
|
'use strict';
|
2019-07-07 04:02:01 +00:00
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
2019-03-21 18:58:00 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2019-08-15 19:25:33 +00:00
|
|
|
const animated_gif_detector_1 = __importDefault(require("animated-gif-detector"));
|
2019-07-07 04:02:01 +00:00
|
|
|
const path_1 = require("path");
|
|
|
|
const fs_extra_1 = require("fs-extra");
|
2019-06-15 15:06:57 +00:00
|
|
|
const delay_1 = require("delay");
|
2020-02-21 18:34:22 +00:00
|
|
|
const crypto_1 = require("crypto");
|
2020-04-24 18:33:58 +00:00
|
|
|
const frame_1 = __importDefault(require("frame"));
|
2019-08-25 18:59:39 +00:00
|
|
|
/**
|
|
|
|
* @module FilmOut
|
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
class FilmOut {
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* @constructor
|
|
|
|
* Builds FilmOut class with display, ffmpeg, ffprobe, ui and light as internal properties.
|
2019-03-21 22:03:53 +00:00
|
|
|
*
|
2019-08-25 18:59:39 +00:00
|
|
|
* @param {object} display Display object for showing frames
|
|
|
|
* @param {object} ffmpeg FFMPEG wrapper
|
|
|
|
* @param {object} ffprobe FFPROBE wrapper for file info
|
|
|
|
* @param {object} ui Electron ui object
|
|
|
|
* @param {object} light Light device object
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
2023-02-25 17:40:35 +00:00
|
|
|
constructor(display, server, ffmpeg, ffprobe, ui, light) {
|
2019-06-18 19:42:30 +00:00
|
|
|
this.id = 'filmout';
|
2019-07-07 04:02:01 +00:00
|
|
|
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
|
|
|
|
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
|
2021-02-24 15:05:45 +00:00
|
|
|
this.sequenceExtensions = ['.png', '.jpg', '.jpeg'];
|
2019-07-07 04:02:01 +00:00
|
|
|
this.gifExtension = '.gif';
|
2019-03-21 22:03:53 +00:00
|
|
|
this.state = {
|
|
|
|
frame: 0,
|
|
|
|
frames: 0,
|
2019-07-07 04:02:01 +00:00
|
|
|
still: false,
|
2019-03-21 22:03:53 +00:00
|
|
|
path: null,
|
|
|
|
fileName: null,
|
2021-02-24 00:53:22 +00:00
|
|
|
directory: false,
|
2019-03-21 22:03:53 +00:00
|
|
|
info: {},
|
|
|
|
dir: true,
|
2021-02-24 05:22:08 +00:00
|
|
|
enabled: false,
|
|
|
|
files: []
|
2019-03-21 22:03:53 +00:00
|
|
|
};
|
|
|
|
this.display = display;
|
2023-02-25 17:40:35 +00:00
|
|
|
this.server = server;
|
2019-03-21 22:03:53 +00:00
|
|
|
this.ffmpeg = ffmpeg;
|
|
|
|
this.ffprobe = ffprobe;
|
|
|
|
this.ui = ui;
|
|
|
|
this.light = light;
|
|
|
|
this.init();
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Async function for requiring log, ipcMain and bind events.
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
|
|
|
async init() {
|
2019-06-15 15:06:57 +00:00
|
|
|
const Log = require('log');
|
2019-06-18 19:42:30 +00:00
|
|
|
this.log = await Log({ label: this.id });
|
2019-03-21 22:03:53 +00:00
|
|
|
this.ipc = require('electron').ipcMain;
|
|
|
|
this.listen();
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
listen() {
|
2019-06-18 19:42:30 +00:00
|
|
|
this.ipc.on(this.id, this.onConnect.bind(this));
|
2019-06-18 17:47:55 +00:00
|
|
|
this.ipc.on('focus', this.focus.bind(this));
|
2019-06-18 19:42:30 +00:00
|
|
|
this.ipc.on('field', this.field.bind(this));
|
|
|
|
this.ipc.on('meter', this.meter.bind(this));
|
|
|
|
this.ipc.on('filmout_close', this.close.bind(this));
|
2019-06-27 00:08:49 +00:00
|
|
|
this.ipc.on('preview', this.preview.bind(this));
|
2019-06-25 16:13:15 +00:00
|
|
|
this.ipc.on('preview_frame', this.previewFrame.bind(this));
|
2019-06-27 00:08:49 +00:00
|
|
|
this.ipc.on('display', this.onDisplay.bind(this));
|
2020-02-21 18:34:22 +00:00
|
|
|
this.ipc.on('pre_export', this.onPreExport.bind(this));
|
2020-03-09 19:46:06 +00:00
|
|
|
this.ffmpeg.onProgress = (obj) => {
|
|
|
|
this.ui.send('pre_export_progress', { progress: obj });
|
|
|
|
};
|
2020-02-21 18:34:22 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Create a hash of a string.
|
|
|
|
*
|
|
|
|
* @param {string} data Data to produce hash of
|
|
|
|
*/
|
|
|
|
hash(data) {
|
2024-04-06 23:09:50 +00:00
|
|
|
return (0, crypto_1.createHash)('sha1').update(data).digest('hex');
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Sets filmout direction.
|
2019-03-21 22:03:53 +00:00
|
|
|
*
|
2019-08-25 18:59:39 +00:00
|
|
|
* @param {boolean} dir Direction of filmout
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
|
|
|
set(dir) {
|
|
|
|
this.state.dir = dir;
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Moves filmout a frame at a time.
|
2021-03-19 16:09:03 +00:00
|
|
|
*
|
|
|
|
* @returns {number} Time since start
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
|
|
|
async move() {
|
|
|
|
let start = +new Date();
|
2019-07-07 04:02:01 +00:00
|
|
|
if (this.state.still) {
|
2021-03-19 16:09:03 +00:00
|
|
|
return -1;
|
2019-07-07 04:02:01 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
if (this.state.dir) {
|
|
|
|
this.state.frame++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.state.frame--;
|
|
|
|
}
|
|
|
|
if (this.state.frame < 1) {
|
|
|
|
this.state.frame = 1;
|
|
|
|
}
|
|
|
|
return (+new Date()) - start;
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Begin the process of exporting single frames from the video for display.
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
|
|
|
async start() {
|
2020-02-21 18:34:22 +00:00
|
|
|
let path;
|
2019-03-21 22:03:53 +00:00
|
|
|
try {
|
2020-02-21 18:34:22 +00:00
|
|
|
path = await this.ffmpeg.frame(this.state, this.light.state);
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
2019-06-27 00:08:49 +00:00
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
2019-03-21 22:03:53 +00:00
|
|
|
throw err;
|
|
|
|
}
|
2023-02-25 18:22:20 +00:00
|
|
|
if (this.server.displayImage(path)) {
|
2024-04-06 23:09:50 +00:00
|
|
|
await (0, delay_1.delay)(20);
|
2023-02-25 18:22:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-02-21 18:34:22 +00:00
|
|
|
await this.display.show(path);
|
2024-04-06 23:09:50 +00:00
|
|
|
await (0, delay_1.delay)(20);
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Ends the filmout process and closes the display.
|
2019-07-07 04:02:01 +00:00
|
|
|
**/
|
2019-03-21 22:03:53 +00:00
|
|
|
async end() {
|
2024-04-06 23:09:50 +00:00
|
|
|
await (0, delay_1.delay)(20);
|
2019-03-22 02:33:30 +00:00
|
|
|
this.display.hide();
|
2019-03-21 18:58:00 +00:00
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
/**
|
2019-06-18 19:42:30 +00:00
|
|
|
* Use a video file as a film out source on "projector"
|
2019-03-21 22:03:53 +00:00
|
|
|
*
|
2019-08-25 18:59:39 +00:00
|
|
|
* @param {object} evt Original connect event
|
|
|
|
* @param {object} arg Arguments from ipc message
|
2021-03-19 16:09:03 +00:00
|
|
|
*
|
|
|
|
* @returns {boolean} Success state
|
2019-03-21 22:03:53 +00:00
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
async onConnect(evt, arg) {
|
2019-03-21 22:03:53 +00:00
|
|
|
let frames = 0;
|
2019-07-07 04:02:01 +00:00
|
|
|
let isAnimated = false;
|
|
|
|
let info;
|
|
|
|
let ext;
|
2021-02-24 05:22:08 +00:00
|
|
|
let stats;
|
|
|
|
let frameList;
|
|
|
|
try {
|
2024-04-06 23:09:50 +00:00
|
|
|
stats = await (0, fs_extra_1.lstat)(arg.path);
|
2021-02-24 05:22:08 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
return false;
|
|
|
|
}
|
2024-04-06 23:09:50 +00:00
|
|
|
ext = (0, path_1.extname)(arg.fileName.toLowerCase());
|
2021-02-24 05:22:08 +00:00
|
|
|
if (stats.isDirectory()) {
|
|
|
|
this.state.directory = true;
|
|
|
|
this.state.still = false;
|
|
|
|
}
|
|
|
|
else if (ext === this.gifExtension) {
|
2019-07-07 04:02:01 +00:00
|
|
|
try {
|
|
|
|
isAnimated = await this.isGifAnimated(arg.path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.state.still = !isAnimated;
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
else if (this.stillExtensions.indexOf(ext) !== -1) {
|
|
|
|
this.state.still = true;
|
2021-02-24 16:50:15 +00:00
|
|
|
this.state.directory = false;
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
else if (this.videoExtensions.indexOf(ext) !== -1) {
|
|
|
|
this.state.still = false;
|
2021-02-24 16:50:15 +00:00
|
|
|
this.state.directory = false;
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
else {
|
|
|
|
this.log.error(`File is not of a valid file type`, 'FILMOUT', true, true);
|
2019-03-21 22:03:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-02-21 18:34:22 +00:00
|
|
|
try {
|
|
|
|
await this.ffmpeg.clearAll();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
throw err;
|
|
|
|
}
|
2021-02-24 05:22:08 +00:00
|
|
|
if (this.state.directory) {
|
|
|
|
try {
|
|
|
|
frameList = await this.dirList(arg.path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
this.state.enabled = false;
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
info = await this.dirInfo(frameList);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
this.state.enabled = false;
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
frames = frameList.length;
|
|
|
|
this.state.files = frameList;
|
|
|
|
}
|
|
|
|
else if (this.state.still) {
|
2019-07-07 04:02:01 +00:00
|
|
|
try {
|
|
|
|
info = await this.stillInfo(arg.path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
this.state.enabled = false;
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
frames = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
try {
|
|
|
|
info = await this.ffprobe.info(arg.path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
this.state.enabled = false;
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
frames = await this.ffprobe.frames(arg.path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
this.state.enabled = false;
|
|
|
|
await this.ui.send(this.id, { valid: false });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
this.state.frame = 0;
|
|
|
|
this.state.path = arg.path;
|
|
|
|
this.state.fileName = arg.fileName;
|
|
|
|
this.state.frames = frames;
|
|
|
|
this.state.info = info;
|
2021-02-24 05:22:08 +00:00
|
|
|
this.state.hash = this.hash(arg.path);
|
2021-03-18 15:27:53 +00:00
|
|
|
if (info.fps) {
|
|
|
|
this.state.fps = info.fps;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.state.fps = 24; //default
|
|
|
|
}
|
2020-03-09 19:46:06 +00:00
|
|
|
if (info.seconds) {
|
|
|
|
this.state.seconds = info.seconds;
|
|
|
|
}
|
|
|
|
else if (info.fps && frames) {
|
|
|
|
this.state.seconds = frames / info.fps;
|
|
|
|
}
|
2021-02-24 05:22:08 +00:00
|
|
|
else if (this.state.directory) {
|
|
|
|
this.state.seconds = frames / 24;
|
|
|
|
}
|
2019-06-18 19:42:30 +00:00
|
|
|
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
|
|
|
|
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, true);
|
2019-03-21 22:03:53 +00:00
|
|
|
this.state.enabled = true;
|
2021-03-19 16:09:03 +00:00
|
|
|
await this.ui.send(this.id, { valid: true, state: JSON.stringify(this.state) });
|
|
|
|
return true;
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
2020-02-21 18:34:22 +00:00
|
|
|
/**
|
|
|
|
* Pre-export all frames from video for display.
|
|
|
|
*
|
|
|
|
* @param {object} evt IPC event
|
|
|
|
* @param {object} arg IPC args
|
2021-03-19 16:09:03 +00:00
|
|
|
*
|
|
|
|
* @returns {any} UI send call
|
2020-02-21 18:34:22 +00:00
|
|
|
*/
|
|
|
|
async onPreExport(evt, arg) {
|
|
|
|
if (!this.state.path) {
|
|
|
|
return await this.ui.send('pre_export', { complete: false, err: 'No file to pre export.' });
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
await this.ffmpeg.frames(this.state);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return await this.ui.send('pre_export', { complete: false, err });
|
|
|
|
}
|
|
|
|
return await this.ui.send('pre_export', { complete: true });
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
* Return true if gif is animated, false if it is a still
|
2019-08-25 18:59:39 +00:00
|
|
|
*
|
|
|
|
* @param {string} pathStr Path to gif to check
|
|
|
|
*
|
|
|
|
* @returns {boolean} Whether or not gif is animated
|
2019-07-07 04:02:01 +00:00
|
|
|
**/
|
|
|
|
async isGifAnimated(pathStr) {
|
|
|
|
let gifBuffer;
|
|
|
|
try {
|
2024-04-06 23:09:50 +00:00
|
|
|
gifBuffer = await (0, fs_extra_1.readFile)(pathStr);
|
2019-07-07 04:02:01 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
return false;
|
|
|
|
}
|
2024-04-06 23:09:50 +00:00
|
|
|
return (0, animated_gif_detector_1.default)(gifBuffer);
|
2019-07-07 04:02:01 +00:00
|
|
|
}
|
|
|
|
/**
|
2021-02-24 05:22:08 +00:00
|
|
|
* Return information on a still image using the Jimp module
|
2019-08-25 18:59:39 +00:00
|
|
|
*
|
|
|
|
* @param {string} pathStr Path to gif to check
|
|
|
|
*
|
|
|
|
* @returns {object} Info about still from sharp
|
2019-07-07 04:02:01 +00:00
|
|
|
**/
|
|
|
|
async stillInfo(pathStr) {
|
2020-04-24 18:33:58 +00:00
|
|
|
let info;
|
|
|
|
try {
|
|
|
|
info = await frame_1.default.info(pathStr);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
return info;
|
2019-07-07 04:02:01 +00:00
|
|
|
}
|
2021-02-24 05:22:08 +00:00
|
|
|
/**
|
|
|
|
* Return information on the first still image found in a
|
|
|
|
* directory using the Jimp module.
|
|
|
|
*
|
|
|
|
* @param {array} images List of image paths
|
|
|
|
*
|
|
|
|
* @returns {object} Info about first image
|
|
|
|
**/
|
|
|
|
async dirInfo(images) {
|
|
|
|
let info;
|
|
|
|
try {
|
|
|
|
info = await this.stillInfo(images[0]);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Returns a list of images within a directory, filtered
|
|
|
|
* for supported types and sorted.
|
|
|
|
*
|
|
|
|
* @param {string} pathStr Path to directory
|
|
|
|
*
|
|
|
|
* @returns {array} Array of image paths
|
|
|
|
**/
|
|
|
|
async dirList(pathStr) {
|
|
|
|
let frameList = [];
|
|
|
|
try {
|
2024-04-06 23:09:50 +00:00
|
|
|
frameList = await (0, fs_extra_1.readdir)(pathStr);
|
2021-02-24 05:22:08 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
frameList = frameList.filter((fileName) => {
|
2024-04-06 23:09:50 +00:00
|
|
|
let ext = (0, path_1.extname)(fileName);
|
2021-02-24 15:05:45 +00:00
|
|
|
if (this.sequenceExtensions.indexOf(ext) !== -1) {
|
2021-02-24 05:22:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
frameList.sort();
|
|
|
|
frameList = frameList.map((fileName) => {
|
2024-04-06 23:09:50 +00:00
|
|
|
return (0, path_1.join)(pathStr, fileName);
|
2021-02-24 05:22:08 +00:00
|
|
|
});
|
|
|
|
return frameList;
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
2019-08-25 18:59:39 +00:00
|
|
|
* Preview a frame from the selected video.
|
2019-07-07 04:02:01 +00:00
|
|
|
*
|
2019-08-25 18:59:39 +00:00
|
|
|
* @param {object} evt Original event
|
|
|
|
* @param {object} arg Arguments from message
|
2019-07-07 04:02:01 +00:00
|
|
|
**/
|
2019-06-25 16:13:15 +00:00
|
|
|
async previewFrame(evt, arg) {
|
|
|
|
const state = JSON.parse(JSON.stringify(this.state));
|
|
|
|
let path;
|
|
|
|
state.frame = arg.frame;
|
|
|
|
try {
|
|
|
|
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
|
|
|
|
}
|
|
|
|
catch (err) {
|
2019-06-27 00:08:49 +00:00
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
2019-06-25 16:13:15 +00:00
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
this.ui.send('preview_frame', { path, frame: arg.frame });
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
2020-02-21 18:34:22 +00:00
|
|
|
* Open a single frame in a display window to preview filmout.
|
2019-08-25 18:59:39 +00:00
|
|
|
*
|
|
|
|
* @param {object} evt Original event
|
|
|
|
* @param {object} arg Arguments from message
|
2019-07-07 04:02:01 +00:00
|
|
|
**/
|
2019-06-25 16:13:15 +00:00
|
|
|
async preview(evt, arg) {
|
2019-06-27 00:08:49 +00:00
|
|
|
const state = JSON.parse(JSON.stringify(this.state));
|
|
|
|
let path;
|
|
|
|
state.frame = arg.frame;
|
|
|
|
this.log.info(`Previewing frame ${state.frame} of ${state.fileName}`);
|
|
|
|
try {
|
|
|
|
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
try {
|
2023-02-25 18:22:20 +00:00
|
|
|
if (await this.server.displayImage(path)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-27 00:08:49 +00:00
|
|
|
await this.display.open();
|
2020-02-21 18:34:22 +00:00
|
|
|
await this.display.show(path);
|
2019-06-27 00:08:49 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
2019-06-25 16:13:15 +00:00
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
async focus(evt, arg) {
|
2019-06-27 00:08:49 +00:00
|
|
|
this.log.info(`Showing focus screen`);
|
2019-06-18 19:42:30 +00:00
|
|
|
try {
|
2023-02-25 18:11:40 +00:00
|
|
|
if (await this.server.cmdAll('focus')) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-18 19:42:30 +00:00
|
|
|
await this.display.open();
|
|
|
|
await this.display.focus();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
async field(evt, arg) {
|
2019-08-25 19:26:43 +00:00
|
|
|
const ratio = arg.ratio;
|
2019-06-27 00:08:49 +00:00
|
|
|
this.log.info(`Showing field guide screen`);
|
2019-06-18 19:42:30 +00:00
|
|
|
try {
|
2023-02-25 18:11:40 +00:00
|
|
|
if (await this.server.cmdAll('field', { ratio })) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-18 19:42:30 +00:00
|
|
|
await this.display.open();
|
2019-08-25 19:26:43 +00:00
|
|
|
await this.display.field(ratio);
|
2019-06-18 19:42:30 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
async meter(evt, arg) {
|
2019-06-27 00:08:49 +00:00
|
|
|
this.log.info(`Showing meter screen`);
|
2019-06-18 19:42:30 +00:00
|
|
|
try {
|
2023-02-25 18:11:40 +00:00
|
|
|
if (await this.server.cmdAll('meter')) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-18 19:42:30 +00:00
|
|
|
await this.display.open();
|
|
|
|
await this.display.meter();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
2019-06-18 19:42:30 +00:00
|
|
|
async close(evt, arg) {
|
|
|
|
try {
|
2023-02-25 18:11:40 +00:00
|
|
|
if (await this.server.cmdAll('blank')) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-18 19:42:30 +00:00
|
|
|
await this.display.hide();
|
|
|
|
await this.display.close();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.log.error(err, 'FILMOUT', true, true);
|
|
|
|
}
|
2019-06-18 17:47:55 +00:00
|
|
|
}
|
2019-07-07 04:02:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
**/
|
2019-06-27 00:08:49 +00:00
|
|
|
onDisplay(evt, arg) {
|
|
|
|
this.display.change(arg.display);
|
|
|
|
this.log.info(`Changing the display to ${arg.display}`);
|
|
|
|
}
|
2019-03-21 22:03:53 +00:00
|
|
|
}
|
2023-02-25 17:40:35 +00:00
|
|
|
module.exports = (display, server, ffmpeg, ffprobe, ui, light) => {
|
|
|
|
return new FilmOut(display, server, ffmpeg, ffprobe, ui, light);
|
2019-03-21 18:58:00 +00:00
|
|
|
};
|
|
|
|
//# sourceMappingURL=index.js.map
|