Add ffmpeg list demux types feature. Add websocket basic server. Add browser build project with stub websocket.
This commit is contained in:
parent
b0c1431bd6
commit
9aaf9a215d
|
@ -0,0 +1,21 @@
|
||||||
|
class Client {
|
||||||
|
private client : WebSocket;
|
||||||
|
private connected : boolean = false;
|
||||||
|
constructor () {
|
||||||
|
let uri : string = 'ws://localhost:8082';
|
||||||
|
this.client = new WebSocket(uri);
|
||||||
|
this.client.onopen = this.onOpen.bind(this);
|
||||||
|
this.client.onmessage = this.onMessage.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onMessage (event : any) {
|
||||||
|
console.log(event.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onOpen (event : any) {
|
||||||
|
console.log('Connected');
|
||||||
|
this.connected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Client();
|
|
@ -5,6 +5,7 @@ WS_PORT=8081
|
||||||
WIDTH=2560
|
WIDTH=2560
|
||||||
HEIGHT=1600
|
HEIGHT=1600
|
||||||
FD=../filmout_display/build/bin/fd
|
FD=../filmout_display/build/bin/fd
|
||||||
|
FFMPEG=ffmpeg
|
||||||
FD_HOST=localhost
|
FD_HOST=localhost
|
||||||
FD_PORT=8081
|
FD_PORT=8081
|
||||||
VIDEOS=/home/users/VIDEOS
|
VIDEOS=/home/users/VIDEOS
|
||||||
|
|
|
@ -46,7 +46,7 @@ class FFMPEG {
|
||||||
if (row.startsWith(' DE ')) {
|
if (row.startsWith(' DE ')) {
|
||||||
key = row.substring(4, row.length - 1).split(' ')[0];
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
||||||
description = row.replace(key, '').trim();
|
description = row.replace(key, '').trim();
|
||||||
this.log.info(key);
|
//this.log.info(key);
|
||||||
/*try {
|
/*try {
|
||||||
this.log.info(await this.demuxerInfo(key));
|
this.log.info(await this.demuxerInfo(key));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -60,7 +60,7 @@ class FFMPEG {
|
||||||
else if (row.startsWith(' D ')) {
|
else if (row.startsWith(' D ')) {
|
||||||
key = row.substring(4, row.length - 1).split(' ')[0];
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
||||||
description = row.replace(key, '').trim();
|
description = row.replace(key, '').trim();
|
||||||
this.log.info(key);
|
//this.log.info(key);
|
||||||
/*try {
|
/*try {
|
||||||
this.log.info(await this.demuxerInfo(key));
|
this.log.info(await this.demuxerInfo(key));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":";;;AACA,gCAAkC;AAClC,oCAAiC;AAEjC,2BAAyB;AAEzB,MAAa,MAAM;IAOlB,YAAa,MAAc,QAAQ;QAH3B,YAAO,GAAc,EAAE,CAAC;QACxB,gBAAW,GAAS,EAAE,CAAC;QAG9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAEO,KAAK,CAAC,OAAO;QACpB,MAAM,GAAG,GAAc,CAAE,IAAI,CAAC,GAAG,EAAE,UAAU,CAAE,CAAC;QAChD,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAkB,EAAE,MAAiB,EAAE,EAAE;YAClE,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACvD,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,WAAW,CAAE,OAAgB;QAC1C,MAAM,GAAG,GAAc,CAAE,IAAI,CAAC,GAAG,EAAE,qBAAqB,OAAO,EAAE,CAAE,CAAC;QACpE,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAkB,EAAE,MAAiB,EAAE,EA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"));
|
const promises_1 = __importDefault(require("fs/promises"));
|
||||||
const hash_1 = require("../hash");
|
const hash_1 = require("../hash");
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const fileExtension = [
|
const fileExtensions = [
|
||||||
'.mp4',
|
'.mp4',
|
||||||
'.mkv',
|
'.mkv',
|
||||||
'.mov'
|
'.mov'
|
||||||
|
@ -53,6 +53,27 @@ class Files {
|
||||||
const videos = [];
|
const videos = [];
|
||||||
let all;
|
let all;
|
||||||
let stats;
|
let stats;
|
||||||
|
try {
|
||||||
|
all = await promises_1.default.readdir(path);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
for (let elem of all) {
|
||||||
|
try {
|
||||||
|
stats = await promises_1.default.lstat(elem);
|
||||||
|
if (stats.isFile() && fileExtensions.indexOf((0, path_1.extname)((0, path_1.basename)(elem))) !== -1) {
|
||||||
|
videos.push({
|
||||||
|
path: elem,
|
||||||
|
hash: hash_1.Hashes.stringHash(elem),
|
||||||
|
name: (0, path_1.basename)(elem)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
return videos;
|
return videos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAE7B,kCAAiC;AACjC,+BAAyC;AAczC,MAAM,aAAa,GAAc;IAChC,MAAM;IACN,MAAM;IACN,MAAM;CACN,CAAC;AAEF,MAAa,KAAK;IACV,MAAM,CAAC,KAAK,CAAC,MAAM,CAAE,IAAa;QACxC,IAAI,CAAC;YACJ,MAAM,kBAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAA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AAC,CAAA;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,GAAG,CAAC;QACX,CAAC;QAED,KAAK,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC;gBACJ,KAAK,GAAG,MAAM,kBAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC1B,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,cAAc,CAAC,OAAO,CAAC,IAAA,cAAO,EAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBAC9E,MAAM,CAAC,IAAI,CAAC;wBACX,IAAI,EAAG,IAAI;wBACX,IAAI,EAAG,aAAM,CAAC,UAAU,CAAC,IAAI,CAAC;wBAC9B,IAAI,EAAG,IAAA,eAAQ,EAAC,IAAI,CAAC;qBACrB,CAAC,CAAC;gBACJ,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,EAAE;YACH,CAAC;QACF,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAlED,sBAkEC;AAGD,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC"}
|
|
@ -30,16 +30,20 @@ require("dotenv/config");
|
||||||
const express_1 = __importDefault(require("express"));
|
const express_1 = __importDefault(require("express"));
|
||||||
const promises_1 = __importDefault(require("fs/promises"));
|
const promises_1 = __importDefault(require("fs/promises"));
|
||||||
const body_parser_1 = __importDefault(require("body-parser"));
|
const body_parser_1 = __importDefault(require("body-parser"));
|
||||||
|
const uuid_1 = require("uuid");
|
||||||
const Handlebars = __importStar(require("handlebars"));
|
const Handlebars = __importStar(require("handlebars"));
|
||||||
|
const ws_1 = require("ws");
|
||||||
const log_1 = require("./log");
|
const log_1 = require("./log");
|
||||||
const files_1 = require("./files");
|
const files_1 = require("./files");
|
||||||
const ffmpeg_1 = require("./ffmpeg");
|
const ffmpeg_1 = require("./ffmpeg");
|
||||||
const log = (0, log_1.createLog)('fm');
|
const log = (0, log_1.createLog)('fm');
|
||||||
const app = (0, express_1.default)();
|
const app = (0, express_1.default)();
|
||||||
|
let wss;
|
||||||
let fd;
|
let fd;
|
||||||
let ffmpeg;
|
let ffmpeg;
|
||||||
let index;
|
let index;
|
||||||
let port;
|
let port;
|
||||||
|
let wsPort;
|
||||||
let sequences;
|
let sequences;
|
||||||
let videos;
|
let videos;
|
||||||
let width;
|
let width;
|
||||||
|
@ -47,6 +51,7 @@ let height;
|
||||||
log.info('Starting filmout_manager...');
|
log.info('Starting filmout_manager...');
|
||||||
app.use(body_parser_1.default.json());
|
app.use(body_parser_1.default.json());
|
||||||
app.use(body_parser_1.default.urlencoded({ extended: true }));
|
app.use(body_parser_1.default.urlencoded({ extended: true }));
|
||||||
|
app.use('/static', express_1.default.static('./static'));
|
||||||
async function createTemplate(filePath) {
|
async function createTemplate(filePath) {
|
||||||
let tmpl;
|
let tmpl;
|
||||||
try {
|
try {
|
||||||
|
@ -68,6 +73,13 @@ async function settings() {
|
||||||
else {
|
else {
|
||||||
log.info(`FD=${process.env['FD']}`);
|
log.info(`FD=${process.env['FD']}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['FFMPEG'] === 'undefined') {
|
||||||
|
log.error('Please include an FFMPEG value containing the path to your ffmpeg binary in .env');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info(`FFMPEG=${process.env['FFMPEG']}`);
|
||||||
|
}
|
||||||
if (typeof process.env['WIDTH'] === 'undefined') {
|
if (typeof process.env['WIDTH'] === 'undefined') {
|
||||||
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
|
@ -106,6 +118,14 @@ async function settings() {
|
||||||
port = parseInt(process.env['PORT']);
|
port = parseInt(process.env['PORT']);
|
||||||
log.info(`PORT=${port}`);
|
log.info(`PORT=${port}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['WS_PORT'] === 'undefined') {
|
||||||
|
log.error('Please include a WSPORT value with the port that the WebSocket web process is hosted on in .env');
|
||||||
|
process.exit(6);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wsPort = parseInt(process.env['WS_PORT']);
|
||||||
|
log.info(`WS_PORT=${port}`);
|
||||||
|
}
|
||||||
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
||||||
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
||||||
process.exit(7);
|
process.exit(7);
|
||||||
|
@ -133,20 +153,32 @@ async function settings() {
|
||||||
log.info(`VIDEOS=${videos}`);
|
log.info(`VIDEOS=${videos}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function onWssConnection(ws, req) {
|
||||||
|
let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
|
if (ip.substr(0, 7) === "::ffff:")
|
||||||
|
ip = ip.substr(7);
|
||||||
|
log.info(`Client ${ip} connected to WebSocket server`);
|
||||||
|
ws.ip = ip;
|
||||||
|
ws.session = (0, uuid_1.v4)();
|
||||||
|
}
|
||||||
app.get('/', async (req, res, next) => {
|
app.get('/', async (req, res, next) => {
|
||||||
const dirs = await files_1.Files.enumerateSequences(sequences);
|
const sequencesArr = await files_1.Files.enumerateSequences(sequences);
|
||||||
const html = index({ dirs, width, height });
|
const videosArr = await files_1.Files.enumerateVideos(videos);
|
||||||
|
const html = index({ sequences: sequencesArr, videos: videosArr, width, height });
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
async function main() {
|
async function main() {
|
||||||
await settings();
|
await settings();
|
||||||
index = await createTemplate('./views/index.hbs');
|
index = await createTemplate('./views/index.hbs');
|
||||||
ffmpeg = new ffmpeg_1.FFMPEG();
|
ffmpeg = new ffmpeg_1.FFMPEG(process.env['FFMPEG']);
|
||||||
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
||||||
app.listen(port, async () => {
|
app.listen(port, async () => {
|
||||||
log.info(`filmout_manager HTTP server running on port ${port}`);
|
log.info(`filmout_manager HTTP server running on port ${port}`);
|
||||||
});
|
});
|
||||||
log.info(await ffmpeg.listFormats());
|
wss = new ws_1.Server({ port: wsPort, clientTracking: true });
|
||||||
|
wss.on('connection', onWssConnection);
|
||||||
|
log.info(`filmout_manager WebSocket server running on port ${wsPort}`);
|
||||||
|
ffmpeg.listFormats();
|
||||||
}
|
}
|
||||||
main();
|
main();
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,9 @@
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"compile": "./node_modules/.bin/tsc -p tsconfig.json"
|
"compile": "npm run compile_node && npm run compile_browser",
|
||||||
|
"compile_node" : "./node_modules/.bin/tsc -p tsconfig.json",
|
||||||
|
"compile_browser" : "./node_modules/.bin/tsc -p tsconfig-browser.json"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class FFMPEG {
|
||||||
if (row.startsWith(' DE ')) {
|
if (row.startsWith(' DE ')) {
|
||||||
key = row.substring(4, row.length - 1).split(' ')[0];
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
||||||
description = row.replace(key, '').trim();
|
description = row.replace(key, '').trim();
|
||||||
this.log.info(key);
|
//this.log.info(key);
|
||||||
/*try {
|
/*try {
|
||||||
this.log.info(await this.demuxerInfo(key));
|
this.log.info(await this.demuxerInfo(key));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -69,7 +69,7 @@ export class FFMPEG {
|
||||||
} else if (row.startsWith(' D ')) {
|
} else if (row.startsWith(' D ')) {
|
||||||
key = row.substring(4, row.length - 1).split(' ')[0];
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
||||||
description = row.replace(key, '').trim();
|
description = row.replace(key, '').trim();
|
||||||
this.log.info(key);
|
//this.log.info(key);
|
||||||
/*try {
|
/*try {
|
||||||
this.log.info(await this.demuxerInfo(key));
|
this.log.info(await this.demuxerInfo(key));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface VideoObject {
|
||||||
name : string
|
name : string
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileExtension : string[] = [
|
const fileExtensions : string[] = [
|
||||||
'.mp4',
|
'.mp4',
|
||||||
'.mkv',
|
'.mkv',
|
||||||
'.mov'
|
'.mov'
|
||||||
|
@ -64,6 +64,27 @@ export class Files {
|
||||||
let all : string[];
|
let all : string[];
|
||||||
let stats : Stats;
|
let stats : Stats;
|
||||||
|
|
||||||
|
try {
|
||||||
|
all = await fs.readdir(path)
|
||||||
|
} catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let elem of all) {
|
||||||
|
try {
|
||||||
|
stats = await fs.lstat(elem);
|
||||||
|
if (stats.isFile() && fileExtensions.indexOf(extname(basename(elem))) !== -1) {
|
||||||
|
videos.push({
|
||||||
|
path : elem,
|
||||||
|
hash : Hashes.stringHash(elem),
|
||||||
|
name : basename(elem)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return videos;
|
return videos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
45
src/index.ts
45
src/index.ts
|
@ -12,6 +12,7 @@ import getType from 'mime';
|
||||||
import type { Logger } from 'winston';
|
import type { Logger } from 'winston';
|
||||||
import * as Handlebars from 'handlebars';
|
import * as Handlebars from 'handlebars';
|
||||||
import { Server } from 'ws';
|
import { Server } from 'ws';
|
||||||
|
import type { WebSocket } from 'ws';
|
||||||
|
|
||||||
import { createLog } from './log'
|
import { createLog } from './log'
|
||||||
import { sendMail } from './mail';
|
import { sendMail } from './mail';
|
||||||
|
@ -24,11 +25,13 @@ import { FFMPEG } from './ffmpeg';
|
||||||
|
|
||||||
const log : Logger = createLog('fm');
|
const log : Logger = createLog('fm');
|
||||||
const app : Express = express();
|
const app : Express = express();
|
||||||
|
let wss : Server;
|
||||||
let fd : FD;
|
let fd : FD;
|
||||||
let ffmpeg : FFMPEG;
|
let ffmpeg : FFMPEG;
|
||||||
let index : HandlebarsTemplateDelegate<any>;
|
let index : HandlebarsTemplateDelegate<any>;
|
||||||
|
|
||||||
let port : number;
|
let port : number;
|
||||||
|
let wsPort : number;
|
||||||
let sequences : string;
|
let sequences : string;
|
||||||
let videos : string;
|
let videos : string;
|
||||||
let width : number;
|
let width : number;
|
||||||
|
@ -39,6 +42,13 @@ log.info('Starting filmout_manager...');
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
app.use('/static', express.static('./static'));
|
||||||
|
|
||||||
|
interface WebSocketExtended extends WebSocket {
|
||||||
|
ip? : string,
|
||||||
|
session? : string
|
||||||
|
}
|
||||||
|
|
||||||
async function createTemplate (filePath : string) : Promise<HandlebarsTemplateDelegate<any>> {
|
async function createTemplate (filePath : string) : Promise<HandlebarsTemplateDelegate<any>> {
|
||||||
let tmpl : string;
|
let tmpl : string;
|
||||||
try {
|
try {
|
||||||
|
@ -59,6 +69,12 @@ async function settings () {
|
||||||
} else {
|
} else {
|
||||||
log.info(`FD=${process.env['FD']}`);
|
log.info(`FD=${process.env['FD']}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['FFMPEG'] === 'undefined') {
|
||||||
|
log.error('Please include an FFMPEG value containing the path to your ffmpeg binary in .env');
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
log.info(`FFMPEG=${process.env['FFMPEG']}`);
|
||||||
|
}
|
||||||
if (typeof process.env['WIDTH'] === 'undefined') {
|
if (typeof process.env['WIDTH'] === 'undefined') {
|
||||||
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
log.error('Please include a WIDTH value containing the width of the screen you are using in .env');
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
|
@ -92,6 +108,13 @@ async function settings () {
|
||||||
port = parseInt(process.env['PORT']);
|
port = parseInt(process.env['PORT']);
|
||||||
log.info(`PORT=${port}`);
|
log.info(`PORT=${port}`);
|
||||||
}
|
}
|
||||||
|
if (typeof process.env['WS_PORT'] === 'undefined') {
|
||||||
|
log.error('Please include a WSPORT value with the port that the WebSocket web process is hosted on in .env');
|
||||||
|
process.exit(6);
|
||||||
|
} else {
|
||||||
|
wsPort = parseInt(process.env['WS_PORT']);
|
||||||
|
log.info(`WS_PORT=${port}`);
|
||||||
|
}
|
||||||
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
if (typeof process.env['SEQUENCES'] === 'undefined') {
|
||||||
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
log.error('Please include a SEQUENCES directory where the image sequences will be located in .env');
|
||||||
process.exit(7);
|
process.exit(7);
|
||||||
|
@ -118,21 +141,35 @@ async function settings () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onWssConnection (ws : WebSocketExtended, req : Request) {
|
||||||
|
let ip : string = req.headers['x-forwarded-for'] as string || req.connection.remoteAddress;
|
||||||
|
if (ip.substr(0, 7) === "::ffff:") ip = ip.substr(7)
|
||||||
|
log.info(`Client ${ip} connected to WebSocket server`);
|
||||||
|
ws.ip = ip;
|
||||||
|
ws.session = uuid();
|
||||||
|
}
|
||||||
|
|
||||||
app.get('/', async (req : Request, res : Response, next : NextFunction) => {
|
app.get('/', async (req : Request, res : Response, next : NextFunction) => {
|
||||||
const dirs : SequenceObject[] = await Files.enumerateSequences(sequences);
|
const sequencesArr : SequenceObject[] = await Files.enumerateSequences(sequences);
|
||||||
const html : string = index({ dirs, width, height });
|
const videosArr : VideoObject[] = await Files.enumerateVideos(videos);
|
||||||
|
const html : string = index({ sequences : sequencesArr, videos : videosArr, width, height });
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
await settings();
|
await settings();
|
||||||
index = await createTemplate('./views/index.hbs');
|
index = await createTemplate('./views/index.hbs');
|
||||||
ffmpeg = new FFMPEG();
|
ffmpeg = new FFMPEG(process.env['FFMPEG']);
|
||||||
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));
|
||||||
app.listen(port, async () => {
|
app.listen(port, async () => {
|
||||||
log.info(`filmout_manager HTTP server running on port ${port}`);
|
log.info(`filmout_manager HTTP server running on port ${port}`);
|
||||||
});
|
});
|
||||||
log.info(await ffmpeg.listFormats());
|
|
||||||
|
wss = new Server({ port : wsPort, clientTracking : true });
|
||||||
|
wss.on('connection', onWssConnection);
|
||||||
|
log.info(`filmout_manager WebSocket server running on port ${wsPort}`);
|
||||||
|
|
||||||
|
ffmpeg.listFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
declare class Client {
|
||||||
|
private client;
|
||||||
|
private connected;
|
||||||
|
constructor();
|
||||||
|
private onMessage;
|
||||||
|
private onOpen;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
class Client {
|
||||||
|
constructor() {
|
||||||
|
this.connected = false;
|
||||||
|
let uri = 'ws://localhost:8082';
|
||||||
|
this.client = new WebSocket(uri);
|
||||||
|
this.client.onopen = this.onOpen.bind(this);
|
||||||
|
this.client.onmessage = this.onMessage.bind(this);
|
||||||
|
}
|
||||||
|
onMessage(event) {
|
||||||
|
console.log(event.data);
|
||||||
|
}
|
||||||
|
onOpen(event) {
|
||||||
|
console.log('Connected');
|
||||||
|
this.connected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new Client();
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../browser/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM;IAGV;QADQ,cAAS,GAAa,KAAK,CAAC;QAElC,IAAI,GAAG,GAAY,qBAAqB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAEO,SAAS,CAAE,KAAW;QAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAE,KAAW;QACzB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AAED,IAAI,MAAM,EAAE,CAAC"}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "amd",
|
||||||
|
"lib" : ["es2015", "dom", "es5", "es6"],
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"removeComments" : true,
|
||||||
|
"baseUrl" : "static/js",
|
||||||
|
"outDir": "./static/js",
|
||||||
|
"rootDir" : "./browser/",
|
||||||
|
"declaration": true,
|
||||||
|
"paths" : {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exclude" : [
|
||||||
|
"./dist", "./src", "./static"
|
||||||
|
]
|
||||||
|
}
|
|
@ -15,6 +15,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exclude" : [
|
"exclude" : [
|
||||||
"./dist"
|
"./dist", "./browser", "./static"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -5,11 +5,18 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>Screen Resolution : {{width}}x{{height}}</div>
|
<div>Screen Resolution : {{width}}x{{height}}</div>
|
||||||
<select>
|
<select name="sequence" id="sequence">
|
||||||
<option> - Select Image Sequence - </option>
|
<option> - Select Image Sequence - </option>
|
||||||
{{#each dirs}}
|
{{#each sequences}}
|
||||||
<option value="{{this.hash}}">{{this.name}}</option>
|
<option value="{{this.hash}}">{{this.name}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
|
<select name="video" id="video">
|
||||||
|
<option> - Select Video - </option>
|
||||||
|
{{#each videos}}
|
||||||
|
<option value="{{this.hash}}">{{this.name}}</option>
|
||||||
|
{{/each}}
|
||||||
|
</select>
|
||||||
|
<script src="/static/js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue