Add samplerate

make-only-subtitle-default
HaveAGitGat 2 years ago
parent ef88971bcf
commit 6ef5e2f79f

@ -103,6 +103,45 @@ var details = function () { return ({
},
tooltip: 'Specify the audio bitrate for newly added channels',
},
{
label: 'Enable Samplerate',
name: 'enableSamplerate',
type: 'boolean',
defaultValue: 'false',
inputUI: {
type: 'dropdown',
options: [
'false',
'true',
],
},
tooltip: 'Toggle whether to enable setting audio samplerate',
},
{
label: 'Samplerate',
name: 'samplerate',
type: 'string',
defaultValue: '48k',
inputUI: {
type: 'text',
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'enableSamplerate',
value: 'true',
condition: '===',
},
],
},
],
},
},
tooltip: 'Specify the audio samplerate for newly added channels',
},
],
outputs: [
{
@ -120,7 +159,11 @@ var getHighest = function (first, second) {
return second;
};
var attemptMakeStream = function (_a) {
var args = _a.args, langTag = _a.langTag, streams = _a.streams, audioCodec = _a.audioCodec, audioEncoder = _a.audioEncoder, wantedChannelCount = _a.wantedChannelCount, enableBitrate = _a.enableBitrate, bitrate = _a.bitrate;
var args = _a.args, langTag = _a.langTag, streams = _a.streams, audioCodec = _a.audioCodec, audioEncoder = _a.audioEncoder, wantedChannelCount = _a.wantedChannelCount;
var enableBitrate = Boolean(args.inputs.enableBitrate);
var bitrate = String(args.inputs.bitrate);
var enableSamplerate = Boolean(args.inputs.enableSamplerate);
var samplerate = String(args.inputs.samplerate);
var langMatch = function (stream) {
var _a;
return ((langTag === 'und'
@ -175,6 +218,9 @@ var attemptMakeStream = function (_a) {
var ffType = (0, fileUtils_1.getFfType)(streamCopy.codec_type);
streamCopy.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(bitrate));
}
if (enableSamplerate) {
streamCopy.outputArgs.push('-ar', "".concat(samplerate));
}
// eslint-disable-next-line no-param-reassign
args.variables.ffmpegCommand.shouldProcess = true;
streams.push(streamCopy);
@ -188,8 +234,6 @@ var plugin = function (args) {
var audioEncoder = String(args.inputs.audioEncoder);
var langTag = String(args.inputs.language).toLowerCase();
var wantedChannelCount = Number(args.inputs.channels);
var enableBitrate = Boolean(args.inputs.enableBitrate);
var bitrate = String(args.inputs.bitrate);
var streams = args.variables.ffmpegCommand.streams;
var audioCodec = audioEncoder;
if (audioEncoder === 'dca') {
@ -208,8 +252,6 @@ var plugin = function (args) {
audioCodec: audioCodec,
audioEncoder: audioEncoder,
wantedChannelCount: wantedChannelCount,
enableBitrate: enableBitrate,
bitrate: bitrate,
});
if (!addedOrExists) {
attemptMakeStream({
@ -219,8 +261,6 @@ var plugin = function (args) {
audioCodec: audioCodec,
audioEncoder: audioEncoder,
wantedChannelCount: wantedChannelCount,
enableBitrate: enableBitrate,
bitrate: bitrate,
});
}
return {

@ -112,6 +112,47 @@ const details = (): IpluginDetails => ({
tooltip:
'Specify the audio bitrate for newly added channels',
},
{
label: 'Enable Samplerate',
name: 'enableSamplerate',
type: 'boolean',
defaultValue: 'false',
inputUI: {
type: 'dropdown',
options: [
'false',
'true',
],
},
tooltip:
'Toggle whether to enable setting audio samplerate',
},
{
label: 'Samplerate',
name: 'samplerate',
type: 'string',
defaultValue: '48k',
inputUI: {
type: 'text',
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'enableSamplerate',
value: 'true',
condition: '===',
},
],
},
],
},
},
tooltip:
'Specify the audio samplerate for newly added channels',
},
],
outputs: [
{
@ -136,8 +177,6 @@ const attemptMakeStream = ({
audioCodec,
audioEncoder,
wantedChannelCount,
enableBitrate,
bitrate,
}: {
args: IpluginInputArgs,
langTag: string
@ -145,9 +184,12 @@ const attemptMakeStream = ({
audioCodec: string,
audioEncoder: string,
wantedChannelCount: number,
enableBitrate: boolean,
bitrate: string,
}): boolean => {
const enableBitrate = Boolean(args.inputs.enableBitrate);
const bitrate = String(args.inputs.bitrate);
const enableSamplerate = Boolean(args.inputs.enableSamplerate);
const samplerate = String(args.inputs.samplerate);
const langMatch = (stream: IffmpegCommandStream) => (
(langTag === 'und'
&& (stream.tags === undefined || stream.tags.language === undefined))
@ -217,6 +259,10 @@ const attemptMakeStream = ({
streamCopy.outputArgs.push(`-b:${ffType}:{outputTypeIndex}`, `${bitrate}`);
}
if (enableSamplerate) {
streamCopy.outputArgs.push('-ar', `${samplerate}`);
}
// eslint-disable-next-line no-param-reassign
args.variables.ffmpegCommand.shouldProcess = true;
@ -234,8 +280,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const audioEncoder = String(args.inputs.audioEncoder);
const langTag = String(args.inputs.language).toLowerCase();
const wantedChannelCount = Number(args.inputs.channels);
const enableBitrate = Boolean(args.inputs.enableBitrate);
const bitrate = String(args.inputs.bitrate);
const { streams } = args.variables.ffmpegCommand;
@ -260,8 +304,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
audioCodec,
audioEncoder,
wantedChannelCount,
enableBitrate,
bitrate,
});
if (!addedOrExists) {
@ -272,8 +314,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
audioCodec,
audioEncoder,
wantedChannelCount,
enableBitrate,
bitrate,
});
}

Loading…
Cancel
Save