Fix double -filter parameter when encoder sets filter

This commit is contained in:
Ingo Oppermann 2024-09-05 14:27:55 +02:00
parent f54adc6b94
commit 05649aa2fd
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
43 changed files with 80 additions and 23 deletions

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: [],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-hwaccel', 'cuda', '-c:v', 'av1_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: [],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'h264_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'h264_mmal'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'hevc_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mjpeg_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg1_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_mmal'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg4_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg4_mmal'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-hwaccel', 'cuda', '-hwaccel_output_format', 'cuda'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'vc1_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'vc1_mmal'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-hwaccel', 'videotoolbox'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'vp8_cuvid'],
filter: [],
};
return mapping;

View File

@ -17,6 +17,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'vp9_cuvid'],
filter: [],
};
return mapping;

View File

@ -27,6 +27,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -27,6 +27,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [['-vsync', 'drop']],
local: local,
filter: [],
};
return mapping;

View File

@ -15,6 +15,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -24,6 +24,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [['-vsync', 'drop']],
local: local,
filter: [],
};
return mapping;

View File

@ -11,6 +11,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -44,6 +44,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [['-vsync', 'drop']],
local: local,
filter: [],
};
return mapping;

View File

@ -23,6 +23,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -23,6 +23,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [['-vsync', 'drop']],
local: local,
filter: [],
};
return mapping;

View File

@ -23,6 +23,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [['-vsync', 'drop']],
local: local,
filter: [],
};
return mapping;

View File

@ -78,6 +78,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -11,6 +11,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -71,6 +71,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: ['erosion'],
};
return mapping;

View File

@ -64,6 +64,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -47,6 +47,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -125,6 +125,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -30,13 +30,12 @@ function createMapping(settings, stream, skills) {
const global = [];
const local = [];
const filter = [];
// https://trac.ffmpeg.org/wiki/Hardware/VAAPI
global.push(['-vaapi_device', '/dev/dri/renderD128']);
local.push(
'-vf',
'format=nv12,hwupload',
'-codec:v',
'h264_vaapi',
'-profile:v',
@ -51,17 +50,18 @@ function createMapping(settings, stream, skills) {
`${settings.bitrate}k`,
'-r',
`${settings.fps}`,
'-g',
`${settings.gop}`
);
if (settings.gop !== 'auto') {
local.push('-g', `${Math.round(parseInt(settings.fps) * parseInt(settings.gop)).toFixed(0)}`);
}
filter.push('format=nv12', 'hwupload');
return {
global: global,
local: local,
filter: filter,
};
}

View File

@ -58,6 +58,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -71,6 +71,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -30,13 +30,12 @@ function createMapping(settings, stream, skills) {
const global = [];
const local = [];
const filter = [];
// https://trac.ffmpeg.org/wiki/Hardware/VAAPI
global.push(['-vaapi_device', '/dev/dri/renderD128']);
local.push(
'-vf',
'format=nv12,hwupload',
'-codec:v',
'hevc_vaapi',
'-profile:v',
@ -59,9 +58,12 @@ function createMapping(settings, stream, skills) {
local.push('-g', `${Math.round(parseInt(settings.fps) * parseInt(settings.gop)).toFixed(0)}`);
}
filter.push('format=nv12', 'hwupload');
return {
global: global,
local: local,
filter: filter,
};
}

View File

@ -53,6 +53,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -11,6 +11,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -11,6 +11,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -54,6 +54,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: local,
filter: [],
};
return mapping;

View File

@ -30,13 +30,12 @@ function createMapping(settings, stream, skills) {
const global = [];
const local = [];
const filter = [];
// https://trac.ffmpeg.org/wiki/Hardware/VAAPI
global.push(['-vaapi_device', '/dev/dri/renderD128']);
local.push(
'-vf',
'format=nv12,hwupload',
'-codec:v',
'vp9_vaapi',
'-profile:v',
@ -52,16 +51,19 @@ function createMapping(settings, stream, skills) {
'-r',
`${settings.fps}`,
'-g',
`${settings.gop}`
`${settings.gop}`,
);
if (settings.gop !== 'auto') {
local.push('-g', `${Math.round(parseInt(settings.fps) * parseInt(settings.gop)).toFixed(0)}`);
}
filter.push('format=nv12', 'hwupload');
return {
global: global,
local: local,
filter: filter,
};
}

View File

@ -662,14 +662,17 @@ const createInputsOutputs = (sources, profiles, requireVideo = true) => {
const local = profile.video.encoder.mapping.local.slice();
if (profile.video.encoder.coder !== 'copy' && profile.video.filter.graph.length !== 0) {
// Check if there's already a video filter in the local mapping
let filterIndex = local.indexOf('-filter:v');
if (filterIndex !== -1) {
local[filterIndex + 1] += ',' + profile.video.filter.graph;
} else {
local.unshift('-filter:v', profile.video.filter.graph);
if (profile.video.encoder.coder !== 'copy' && (profile.video.filter.graph.length !== 0 || profile.video.encoder.mapping.filter.length !== 0)) {
let filter = profile.video.filter.graph;
if (profile.video.encoder.mapping.filter.length !== 0) {
if (filter.length !== 0) {
filter += ',';
}
filter += profile.video.encoder.mapping.filter.join(',');
}
local.unshift('-filter:v', filter);
}
const options = ['-map', index + ':' + stream.stream, ...local];
@ -696,14 +699,17 @@ const createInputsOutputs = (sources, profiles, requireVideo = true) => {
const local = profile.audio.encoder.mapping.local.slice();
if (profile.audio.encoder.coder !== 'copy' && profile.audio.filter.graph.length !== 0) {
// Check if there's already a audio filter in the local mapping
let filterIndex = local.indexOf('-filter:a');
if (filterIndex !== -1) {
local[filterIndex + 1] += ',' + profile.audio.filter.graph;
} else {
local.unshift('-filter:a', profile.audio.filter.graph);
if (profile.audio.encoder.coder !== 'copy' && (profile.audio.filter.graph.length !== 0 || profile.audio.encoder.mapping.filter.length !== 0)) {
let filter = profile.audio.filter.graph;
if (profile.audio.encoder.mapping.filter.length !== 0) {
if (filter.length !== 0) {
filter += ',';
}
filter += profile.audio.encoder.mapping.filter.join(',');
}
local.unshift('-filter:a', filter);
}
options.push('-map', index + ':' + stream.stream, ...local);
@ -844,11 +850,13 @@ const initProfile = (initialProfile) => {
profile.video.encoder.mapping = {
global: [],
local: profile.video.encoder.mapping,
filter: [],
};
} else {
profile.video.encoder.mapping = {
global: [],
local: [],
filter: [],
...profile.video.encoder.mapping,
};
}
@ -864,11 +872,13 @@ const initProfile = (initialProfile) => {
profile.video.decoder.mapping = {
global: [],
local: profile.video.decoder.mapping,
filter: [],
};
} else {
profile.video.decoder.mapping = {
global: [],
local: [],
filter: [],
...profile.video.decoder.mapping,
};
}
@ -899,11 +909,13 @@ const initProfile = (initialProfile) => {
profile.audio.encoder.mapping = {
global: [],
local: profile.audio.encoder.mapping,
filter: [],
};
} else {
profile.audio.encoder.mapping = {
global: [],
local: [],
filter: [],
...profile.audio.encoder.mapping,
};
}
@ -919,11 +931,13 @@ const initProfile = (initialProfile) => {
profile.audio.decoder.mapping = {
global: [],
local: profile.audio.decoder.mapping,
filter: [],
};
} else {
profile.audio.decoder.mapping = {
global: [],
local: [],
filter: [],
...profile.audio.decoder.mapping,
};
}