Merge pull request #559 from HaveAGitGat/bitrate

Add samplerate
make-only-subtitle-default
HaveAGitGat 2 years ago committed by GitHub
commit 5dad8c6fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -103,6 +103,45 @@ var details = function () { return ({
}, },
tooltip: 'Specify the audio bitrate for newly added channels', 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: [ outputs: [
{ {
@ -120,7 +159,11 @@ var getHighest = function (first, second) {
return second; return second;
}; };
var attemptMakeStream = function (_a) { 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 langMatch = function (stream) {
var _a; var _a;
return ((langTag === 'und' return ((langTag === 'und'
@ -175,6 +218,9 @@ var attemptMakeStream = function (_a) {
var ffType = (0, fileUtils_1.getFfType)(streamCopy.codec_type); var ffType = (0, fileUtils_1.getFfType)(streamCopy.codec_type);
streamCopy.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(bitrate)); streamCopy.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(bitrate));
} }
if (enableSamplerate) {
streamCopy.outputArgs.push('-ar', "".concat(samplerate));
}
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
args.variables.ffmpegCommand.shouldProcess = true; args.variables.ffmpegCommand.shouldProcess = true;
streams.push(streamCopy); streams.push(streamCopy);
@ -188,8 +234,6 @@ var plugin = function (args) {
var audioEncoder = String(args.inputs.audioEncoder); var audioEncoder = String(args.inputs.audioEncoder);
var langTag = String(args.inputs.language).toLowerCase(); var langTag = String(args.inputs.language).toLowerCase();
var wantedChannelCount = Number(args.inputs.channels); 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 streams = args.variables.ffmpegCommand.streams;
var audioCodec = audioEncoder; var audioCodec = audioEncoder;
if (audioEncoder === 'dca') { if (audioEncoder === 'dca') {
@ -208,8 +252,6 @@ var plugin = function (args) {
audioCodec: audioCodec, audioCodec: audioCodec,
audioEncoder: audioEncoder, audioEncoder: audioEncoder,
wantedChannelCount: wantedChannelCount, wantedChannelCount: wantedChannelCount,
enableBitrate: enableBitrate,
bitrate: bitrate,
}); });
if (!addedOrExists) { if (!addedOrExists) {
attemptMakeStream({ attemptMakeStream({
@ -219,8 +261,6 @@ var plugin = function (args) {
audioCodec: audioCodec, audioCodec: audioCodec,
audioEncoder: audioEncoder, audioEncoder: audioEncoder,
wantedChannelCount: wantedChannelCount, wantedChannelCount: wantedChannelCount,
enableBitrate: enableBitrate,
bitrate: bitrate,
}); });
} }
return { return {

@ -112,6 +112,47 @@ const details = (): IpluginDetails => ({
tooltip: tooltip:
'Specify the audio bitrate for newly added channels', '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: [ outputs: [
{ {
@ -136,8 +177,6 @@ const attemptMakeStream = ({
audioCodec, audioCodec,
audioEncoder, audioEncoder,
wantedChannelCount, wantedChannelCount,
enableBitrate,
bitrate,
}: { }: {
args: IpluginInputArgs, args: IpluginInputArgs,
langTag: string langTag: string
@ -145,9 +184,12 @@ const attemptMakeStream = ({
audioCodec: string, audioCodec: string,
audioEncoder: string, audioEncoder: string,
wantedChannelCount: number, wantedChannelCount: number,
enableBitrate: boolean,
bitrate: string,
}): boolean => { }): 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) => ( const langMatch = (stream: IffmpegCommandStream) => (
(langTag === 'und' (langTag === 'und'
&& (stream.tags === undefined || stream.tags.language === undefined)) && (stream.tags === undefined || stream.tags.language === undefined))
@ -217,6 +259,10 @@ const attemptMakeStream = ({
streamCopy.outputArgs.push(`-b:${ffType}:{outputTypeIndex}`, `${bitrate}`); streamCopy.outputArgs.push(`-b:${ffType}:{outputTypeIndex}`, `${bitrate}`);
} }
if (enableSamplerate) {
streamCopy.outputArgs.push('-ar', `${samplerate}`);
}
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
args.variables.ffmpegCommand.shouldProcess = true; args.variables.ffmpegCommand.shouldProcess = true;
@ -234,8 +280,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const audioEncoder = String(args.inputs.audioEncoder); const audioEncoder = String(args.inputs.audioEncoder);
const langTag = String(args.inputs.language).toLowerCase(); const langTag = String(args.inputs.language).toLowerCase();
const wantedChannelCount = Number(args.inputs.channels); const wantedChannelCount = Number(args.inputs.channels);
const enableBitrate = Boolean(args.inputs.enableBitrate);
const bitrate = String(args.inputs.bitrate);
const { streams } = args.variables.ffmpegCommand; const { streams } = args.variables.ffmpegCommand;
@ -260,8 +304,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
audioCodec, audioCodec,
audioEncoder, audioEncoder,
wantedChannelCount, wantedChannelCount,
enableBitrate,
bitrate,
}); });
if (!addedOrExists) { if (!addedOrExists) {
@ -272,8 +314,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
audioCodec, audioCodec,
audioEncoder, audioEncoder,
wantedChannelCount, wantedChannelCount,
enableBitrate,
bitrate,
}); });
} }

Loading…
Cancel
Save