From 2c88c4dbde0b2a3cc52cd4a8cb98de0714322230 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 5 Feb 2024 11:08:06 +0100 Subject: [PATCH] Add ffmpeg6 support --- src/version.js | 2 +- src/views/Edit/Sources/Network.js | 34 ++++++++++++++++++++++++++ src/views/Edit/Sources/Network.test.js | 12 +++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/version.js b/src/version.js index 8dff732..b7c73df 100644 --- a/src/version.js +++ b/src/version.js @@ -1,7 +1,7 @@ import pkg from '../package.json'; const Core = '^16.11.0'; -const FFmpeg = '^5.1.0'; +const FFmpeg = '^5.1.0 || ^6.1.0'; const UI = pkg.bundle ? pkg.bundle : pkg.name + ' v' + pkg.version; const Version = pkg.version; diff --git a/src/views/Edit/Sources/Network.js b/src/views/Edit/Sources/Network.js index 6bcad4e..44bc68f 100644 --- a/src/views/Edit/Sources/Network.js +++ b/src/views/Edit/Sources/Network.js @@ -258,6 +258,23 @@ const createInputs = (settings, config, skills) => { if (settings.general.analyzeduration_rtmp !== 5000000) { input.options.push('-analyzeduration', settings.general.analyzeduration_rtmp); } + + if (ffmpeg_version === 6) { + const codecs = []; + if (skills.codecs.video.hevc?.length > 0) { + codecs.push('hvc1'); + } + if (skills.codecs.video.av1?.length > 0) { + codecs.push('av01'); + } + if (skills.codecs.video.vp9?.length > 0) { + codecs.push('vp09'); + } + + if (codecs.length !== 0) { + input.options.push('-rtmp_enhanced_codecs', codecs.join(',')); + } + } } else if (settings.push.type === 'srt') { if (settings.general.analyzeduration !== 5000000) { input.options.push('-analyzeduration', settings.general.analyzeduration); @@ -272,6 +289,23 @@ const createInputs = (settings, config, skills) => { if (settings.general.analyzeduration_rtmp !== 5000000) { input.options.push('-analyzeduration', settings.general.analyzeduration_rtmp); } + + if (ffmpeg_version === 6) { + const codecs = []; + if (skills.codecs.video.hevc?.length > 0) { + codecs.push('hvc1'); + } + if (skills.codecs.video.av1?.length > 0) { + codecs.push('av01'); + } + if (skills.codecs.video.vp9?.length > 0) { + codecs.push('vp09'); + } + + if (codecs.length !== 0) { + input.options.push('-rtmp_enhanced_codecs', codecs.join(',')); + } + } } else { if (settings.general.analyzeduration !== 5000000) { input.options.push('-analyzeduration', settings.general.analyzeduration); diff --git a/src/views/Edit/Sources/Network.test.js b/src/views/Edit/Sources/Network.test.js index e08c888..a76f6db 100644 --- a/src/views/Edit/Sources/Network.test.js +++ b/src/views/Edit/Sources/Network.test.js @@ -14,6 +14,14 @@ const $skills_ffmpeg6 = { protocols: { input: ['http', 'https', 'rtmp', 'rtmps', 'srt'], }, + codecs: { + audio: {}, + video: { + av1: ['librav1e'], + hevc: ['hevc'], + vp9: ['libvpx-vp9'], + }, + }, }; const $skills_ffmpeg5 = { @@ -241,7 +249,7 @@ pullmatrix.tests = [ skills: $skills_ffmpeg6, input: { address: 'rtmp://admin:foobar@127.0.0.1/live/stream', - options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000], + options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000, '-rtmp_enhanced_codecs', 'hvc1,av01,vp09'], }, }, { @@ -438,7 +446,7 @@ pushmatrix.tests = [ config: $config, input: { address: '{rtmp,name=external.stream}', - options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000], + options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000, '-rtmp_enhanced_codecs', 'hvc1,av01,vp09'], }, }, {