2024-05-15 18:34:24 +00:00
|
|
|
"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) => {
|
2024-11-04 20:13:59 +00:00
|
|
|
this.shell = new shell_1.Shell(cmd, null, null, null, resolve, true);
|
2024-05-15 18:34:24 +00:00
|
|
|
await this.shell.execute();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
async demuxerInfo(demuxer) {
|
|
|
|
const cmd = [this.bin, `ffmpeg -h demuxer=${demuxer}`];
|
|
|
|
return new Promise(async (resolve, reject) => {
|
2024-11-04 20:13:59 +00:00
|
|
|
this.shell = new shell_1.Shell(cmd, null, null, null, resolve, true);
|
2024-05-15 18:34:24 +00:00
|
|
|
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();
|
2024-05-15 21:29:59 +00:00
|
|
|
//this.log.info(key);
|
2024-05-15 18:34:24 +00:00
|
|
|
/*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();
|
2024-05-15 21:29:59 +00:00
|
|
|
//this.log.info(key);
|
2024-05-15 18:34:24 +00:00
|
|
|
/*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
|