81 lines
2.7 KiB
JavaScript
81 lines
2.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.FFMPEG = void 0;
|
|
const log_1 = require("../log");
|
|
const shell_1 = require("../shell");
|
|
const os_1 = require("os");
|
|
class FFMPEG {
|
|
constructor(bin = 'ffmpeg') {
|
|
this.formats = [];
|
|
this.formatsInfo = {};
|
|
this.bin = bin;
|
|
this.log = (0, log_1.createLog)('ffmpeg');
|
|
}
|
|
async rawList() {
|
|
const cmd = [this.bin, '-formats'];
|
|
return new Promise(async (resolve, reject) => {
|
|
this.shell = new shell_1.Shell(cmd, null, null, resolve, true);
|
|
await this.shell.execute();
|
|
});
|
|
}
|
|
async demuxerInfo(demuxer) {
|
|
const cmd = [this.bin, `ffmpeg -h demuxer=${demuxer}`];
|
|
return new Promise(async (resolve, reject) => {
|
|
this.shell = new shell_1.Shell(cmd, null, null, resolve, true);
|
|
await this.shell.execute();
|
|
});
|
|
}
|
|
async listFormats() {
|
|
let list = null;
|
|
let rows;
|
|
let key;
|
|
let description;
|
|
let info;
|
|
this.formats = [];
|
|
this.formatsInfo = {};
|
|
try {
|
|
list = await this.rawList();
|
|
}
|
|
catch (err) {
|
|
this.log.error('Error listing formats', err);
|
|
}
|
|
if (list !== null) {
|
|
rows = list.split(os_1.EOL);
|
|
for (let row of rows) {
|
|
//this.log.info(`"${row}"`);
|
|
if (row.startsWith(' DE ')) {
|
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
|
description = row.replace(key, '').trim();
|
|
//this.log.info(key);
|
|
/*try {
|
|
this.log.info(await this.demuxerInfo(key));
|
|
} catch (err) {
|
|
this.log.error(err);
|
|
}*/
|
|
this.formats.push(key);
|
|
this.formatsInfo[key] = {
|
|
description
|
|
};
|
|
}
|
|
else if (row.startsWith(' D ')) {
|
|
key = row.substring(4, row.length - 1).split(' ')[0];
|
|
description = row.replace(key, '').trim();
|
|
//this.log.info(key);
|
|
/*try {
|
|
this.log.info(await this.demuxerInfo(key));
|
|
} catch (err) {
|
|
this.log.error(err);
|
|
}*/
|
|
this.formats.push(key);
|
|
this.formatsInfo[key] = {
|
|
description
|
|
};
|
|
}
|
|
}
|
|
}
|
|
return this.formats;
|
|
}
|
|
}
|
|
exports.FFMPEG = FFMPEG;
|
|
module.exports = { FFMPEG };
|
|
//# sourceMappingURL=index.js.map
|