obs-amf: remove, libcef: remove, ffmpeg: use from nixpkgs

This commit is contained in:
Mateusz Słodkowicz 2024-06-25 11:59:28 +02:00
parent 0c50a9aeff
commit e206138a39
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
12 changed files with 1 additions and 5958 deletions

View File

@ -1,4 +0,0 @@
import ./old.nix rec {
version = "6.1";
sha256 = "sha256-NzhD2D16bCVCyCXo0TRwZYp3Ta5eFSfoQPa+iRkeNZg=";
}

View File

@ -1,719 +0,0 @@
#FFMPEG from nixpkgs, added AMF flag, defaults to full ffmpeg
{ version, sha256, extraPatches ? [], knownVulnerabilities ? [] }:
{ lib, stdenv, buildPackages, removeReferencesTo, addOpenGLRunpath, pkg-config, perl, texinfo, yasm
, ffmpegVariant ? "full" # Decides which dependencies are enabled by default
# Build with headless deps; excludes dependencies that are only necessary for
# GUI applications. To be used for purposes that don't generally need such
# components and i.e. only depend on libav
, withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps
# Dependencies a user might customarily expect from a regular ffmpeg build.
# /All/ packages that depend on ffmpeg and some of its feaures should depend
# on the small variant. Small means the minimal set of features that satisfies
# all dependants in Nixpkgs
, withSmallDeps ? ffmpegVariant == "small" || withFullDeps
# Everything enabled; only guarded behind platform exclusivity or brokeness.
# If you need to depend on ffmpeg-full because ffmpeg is missing some feature
# your package needs, you should enable that feature in regular ffmpeg
# instead.
, withFullDeps ? ffmpegVariant == "full"
, fetchgit
, fetchpatch
# Feature flags
, withAmf ? withFullDeps
, withAlsa ? withHeadlessDeps && stdenv.isLinux # Alsa in/output supporT
, withAom ? withFullDeps # AV1 reference encoder
, withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering
, withBluray ? withFullDeps # BluRay reading
, withBs2b ? withFullDeps # bs2b DSP library
, withBzlib ? withHeadlessDeps
, withCaca ? withFullDeps # Textual display (ASCII art)
, withCelt ? withFullDeps # CELT decoder
, withCrystalhd ? withFullDeps
, withCuda ? withFullDeps && (with stdenv; (!isDarwin && !hostPlatform.isAarch))
, withCudaLLVM ? withFullDeps
, withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness)
, withDc1394 ? withFullDeps && !stdenv.isDarwin # IIDC-1394 grabbing (ieee 1394)
, withDrm ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # libdrm support
, withFdkAac ? withFullDeps && withUnfree # Fraunhofer FDK AAC de/encoder
, withFontconfig ? withHeadlessDeps # Needed for drawtext filter
, withFreetype ? withHeadlessDeps # Needed for drawtext filter
, withFrei0r ? withFullDeps # frei0r video filtering
, withFribidi ? withFullDeps # Needed for drawtext filter
, withGlslang ? withFullDeps && !stdenv.isDarwin
, withGme ? withFullDeps # Game Music Emulator
, withGnutls ? withHeadlessDeps
, withGsm ? withFullDeps # GSM de/encoder
, withIconv ? withHeadlessDeps
, withIlbc ? withFullDeps
, withJack ? withFullDeps && !stdenv.isDarwin # Jack audio
, withLadspa ? withFullDeps # LADSPA audio filtering
, withLibplacebo ? withFullDeps && !stdenv.isDarwin # libplacebo video processing library
, withLzma ? withHeadlessDeps # xz-utils
, withMfx ? withFullDeps && (with stdenv.targetPlatform; isLinux && !isAarch) # Hardware acceleration via intel-media-sdk/libmfx
, withModplug ? withFullDeps && !stdenv.isDarwin # ModPlug support
, withMp3lame ? withHeadlessDeps # LAME MP3 encoder
, withMysofa ? withFullDeps # HRTF support via SOFAlizer
, withNvdec ? withHeadlessDeps && !stdenv.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isAarch32
, withNvenc ? withHeadlessDeps && !stdenv.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isAarch32
, withOgg ? withHeadlessDeps # Ogg container used by vorbis & theora
, withOpenal ? withFullDeps # OpenAL 1.1 capture support
, withOpencl ? withFullDeps
, withOpencoreAmrnb ? withFullDeps # AMR-NB de/encoder & AMR-WB decoder
, withOpengl ? withFullDeps # OpenGL rendering
, withOpenh264 ? withFullDeps # H.264/AVC encoder
, withOpenjpeg ? withFullDeps # JPEG 2000 de/encoder
, withOpenmpt ? withFullDeps # Tracked music files decoder
, withOpus ? withHeadlessDeps # Opus de/encoder
, withPulse ? withSmallDeps && !stdenv.isDarwin # Pulseaudio input support
, withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety)
, withRtmp ? false # RTMP[E] support
, withSamba ? withFullDeps && !stdenv.isDarwin # Samba protocol
, withSdl2 ? withSmallDeps
, withSoxr ? withHeadlessDeps # Resampling via soxr
, withSpeex ? withHeadlessDeps # Speex de/encoder
, withSrt ? withHeadlessDeps # Secure Reliable Transport (SRT) protocol
, withSsh ? withHeadlessDeps # SFTP protocol
, withSvg ? withFullDeps # SVG protocol
, withSvtav1 ? withFullDeps && !stdenv.isAarch64 # AV1 encoder/decoder (focused on speed and correctness)
, withTensorflow ? false # Tensorflow dnn backend support
, withTheora ? withHeadlessDeps # Theora encoder
, withV4l2 ? withFullDeps && !stdenv.isDarwin # Video 4 Linux support
, withV4l2M2m ? withV4l2
, withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration
, withVdpau ? withSmallDeps # Vdpau hardware acceleration
, withVidStab ? withFullDeps # Video stabilization
, withVmaf ? withFullDeps && withGPLv3 && !stdenv.isAarch64 # Netflix's VMAF (Video Multi-Method Assessment Fusion)
, withVoAmrwbenc ? withFullDeps # AMR-WB encoder
, withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists
, withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform # VP8 & VP9 de/encoding
, withVulkan ? withFullDeps && !stdenv.isDarwin
, withWebp ? withFullDeps # WebP encoder
, withX264 ? withHeadlessDeps # H.264/AVC encoder
, withX265 ? withHeadlessDeps # H.265/HEVC encoder
, withXavs ? withFullDeps # AVS encoder
, withXcb ? withXcbShm || withXcbxfixes || withXcbShape # X11 grabbing using XCB
, withXcbShape ? withFullDeps # X11 grabbing shape rendering
, withXcbShm ? withFullDeps # X11 grabbing shm communication
, withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering
, withXlib ? withFullDeps # Xlib support
, withXml2 ? withFullDeps # libxml2 support, for IMF and DASH demuxers
, withXvid ? withHeadlessDeps # Xvid encoder, native encoder exists
, withZimg ? withHeadlessDeps
, withZlib ? withHeadlessDeps
, withZmq ? withFullDeps # Message passing
/*
* Licensing options (yes some are listed twice, filters and such are not listed)
*/
, withGPL ? true
, withGPLv3 ? true
, withUnfree ? false
/*
* Build options
*/
, withSmallBuild ? false # Optimize for size instead of speed
, withRuntimeCPUDetection ? true # Detect CPU capabilities at runtime (disable to compile natively)
, withGrayscale ? withFullDeps # Full grayscale support
, withSwscaleAlpha ? buildSwscale # Alpha channel support in swscale. You probably want this when buildSwscale.
, withHardcodedTables ? withHeadlessDeps # Hardcode decode tables instead of runtime generation
, withSafeBitstreamReader ? withHeadlessDeps # Buffer boundary checking in bitreaders
, withMultithread ? true # Multithreading via pthreads/win32 threads
, withNetwork ? withHeadlessDeps # Network support
, withPixelutils ? withHeadlessDeps # Pixel utils in libavutil
/*
* Program options
*/
, buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable
, buildFfplay ? withFullDeps # Build ffplay executable
, buildFfprobe ? withHeadlessDeps # Build ffprobe executable
, buildQtFaststart ? withFullDeps # Build qt-faststart executable
, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart
/*
* Library options
*/
, buildAvcodec ? withHeadlessDeps # Build avcodec library
, buildAvdevice ? withHeadlessDeps # Build avdevice library
, buildAvfilter ? withHeadlessDeps # Build avfilter library
, buildAvformat ? withHeadlessDeps # Build avformat library
# Deprecated but depended upon by some packages.
# https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991)
, buildAvresample ? withHeadlessDeps && lib.versionOlder version "5" # Build avresample library
, buildAvutil ? withHeadlessDeps # Build avutil library
, buildPostproc ? withHeadlessDeps # Build postproc library
, buildSwresample ? withHeadlessDeps # Build swresample library
, buildSwscale ? withHeadlessDeps # Build swscale library
, withLib ? buildAvcodec
|| buildAvdevice
|| buildAvfilter
|| buildAvformat
|| buildAvutil
|| buildPostproc
|| buildSwresample
|| buildSwscale
/*
* Documentation options
*/
, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc
, withHtmlDoc ? withHeadlessDeps # HTML documentation pages
, withManPages ? withHeadlessDeps # Man documentation pages
, withPodDoc ? withHeadlessDeps # POD documentation pages
, withTxtDoc ? withHeadlessDeps # Text documentation pages
# Whether a "doc" output will be produced. Note that withManPages does not produce
# a "doc" output because its files go to "man".
, withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc)
/*
* Developer options
*/
, withDebug ? false
, withOptimisations ? true
, withExtraWarnings ? false
, withStripping ? false
/*
* External libraries options
*/
, amf-headers
, alsa-lib
, bzip2
, clang
, celt
, dav1d
, fdk_aac
, fontconfig
, freetype
, frei0r
, fribidi
, game-music-emu
, gnutls
, gsm
, libjack2
, ladspaH
, lame
, libass
, libaom
, libbluray
, libbs2b
, libcaca
, libdc1394
, libraw1394
, libdrm
, libiconv
, intel-media-sdk
, libmodplug
, libmysofa
, libogg
, libopenmpt
, libopus
, libplacebo
, librsvg
, libssh
, libtensorflow
, libtheora
, libv4l
, libva
, libva-minimal
, libvdpau
, libvmaf
, libvorbis
, libvpx
, libwebp
, libX11
, libxcb
, libXv
, libXext
, libxml2
, xz
, openal
, ocl-icd # OpenCL ICD
, opencl-headers # OpenCL headers
, opencore-amr
, libGL
, libGLU
, openh264
, openjpeg
, libpulseaudio
, rav1e
, svt-av1
, rtmpdump
, samba
, SDL2
, soxr
, speex
, srt
, vid-stab
, vo-amrwbenc
, x264
, x265
, xavs
, xvidcore
, zeromq4
, zimg
, zlib
, vulkan-headers
, vulkan-loader
, glslang
/*
* Darwin frameworks
*/
, AVFoundation
, Cocoa
, CoreAudio
, CoreMedia
, CoreServices
, MediaToolbox
, VideoDecodeAcceleration
, VideoToolbox
/*
* Testing
*/
, testers
}:
/* Maintainer notes:
*
* Version bumps:
* It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release)
* If adding a new branch, note any configure flags that were added, changed, or deprecated/removed
* and make the necessary changes.
*
* Known issues:
* Cross-compiling will disable features not present on host OS
* (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin)
*
*/
let
inherit (lib) optional optionals optionalString enableFeature versionAtLeast;
in
assert lib.elem ffmpegVariant [ "headless" "small" "full" ];
/*
* Licensing dependencies
*/
assert withGPLv3 -> withGPL;
assert withUnfree -> withGPL && withGPLv3;
/*
* Build dependencies
*/
assert withPixelutils -> buildAvutil;
/*
* Program dependencies
*/
assert buildFfmpeg -> buildAvcodec
&& buildAvfilter
&& buildAvformat
&& (buildSwresample || buildAvresample);
assert buildFfplay -> buildAvcodec
&& buildAvformat
&& buildSwscale
&& (buildSwresample || buildAvresample);
assert buildFfprobe -> buildAvcodec && buildAvformat;
/*
* Library dependencies
*/
assert buildAvcodec -> buildAvutil; # configure flag since 0.6
assert buildAvdevice -> buildAvformat
&& buildAvcodec
&& buildAvutil; # configure flag since 0.6
assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6
assert buildPostproc -> buildAvutil;
assert buildSwscale -> buildAvutil;
stdenv.mkDerivation (finalAttrs: {
pname = "ffmpeg" + (if ffmpegVariant == "small" then "" else "-${ffmpegVariant}") + (if withAmf then "-amf" else "");
inherit version;
src = fetchgit {
url = "https://git.ffmpeg.org/ffmpeg.git";
rev = "n${finalAttrs.version}";
inherit sha256;
};
postPatch = ''
patchShebangs .
'' + lib.optionalString withFrei0r ''
substituteInPlace libavfilter/vf_frei0r.c \
--replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1
substituteInPlace doc/filters.texi \
--replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1
'';
patches = map (patch: fetchpatch patch) (extraPatches
++ (lib.optional (lib.versionAtLeast version "6" && lib.versionOlder version "6.1")
{ # this can be removed post 6.1
name = "fix_aacps_tablegen";
url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/814178f92647be2411516bbb82f48532373d2554";
hash = "sha256-FQV9/PiarPXCm45ldtCsxGHjlrriL8DKpn1LaKJ8owI=";
}
));
configurePlatforms = [];
setOutputFlags = false; # Only accepts some of them
configureFlags = [
#mingw64 is internally treated as mingw32, so 32 and 64 make no difference here
"--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}"
"--arch=${stdenv.hostPlatform.parsed.cpu.name}"
"--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config"
/*
* Licensing flags
*/
(enableFeature withGPL "gpl")
(enableFeature withGPLv3 "version3")
(enableFeature withUnfree "nonfree")
/*
* Build flags
*/
# On some ARM platforms --enable-thumb
"--enable-shared"
"--enable-pic"
(enableFeature withSmallBuild "small")
(enableFeature withRuntimeCPUDetection "runtime-cpudetect")
(enableFeature withGrayscale "gray")
(enableFeature withSwscaleAlpha "swscale-alpha")
(enableFeature withHardcodedTables "hardcoded-tables")
(enableFeature withSafeBitstreamReader "safe-bitstream-reader")
(enableFeature (withMultithread && stdenv.targetPlatform.isUnix) "pthreads")
(enableFeature (withMultithread && stdenv.targetPlatform.isWindows) "w32threads")
"--disable-os2threads" # We don't support OS/2
(enableFeature withNetwork "network")
(enableFeature withPixelutils "pixelutils")
"--datadir=${placeholder "data"}/share/ffmpeg"
/*
* Program flags
*/
(enableFeature buildFfmpeg "ffmpeg")
(enableFeature buildFfplay "ffplay")
(enableFeature buildFfprobe "ffprobe")
] ++ optionals withBin [
"--bindir=${placeholder "bin"}/bin"
] ++ [
/*
* Library flags
*/
(enableFeature buildAvcodec "avcodec")
(enableFeature buildAvdevice "avdevice")
(enableFeature buildAvfilter "avfilter")
(enableFeature buildAvformat "avformat")
] ++ optionals (lib.versionOlder version "5") [
# Ffmpeg > 4 doesn't know about the flag anymore
(enableFeature buildAvresample "avresample")
] ++ [
(enableFeature buildAvutil "avutil")
(enableFeature (buildPostproc && withGPL) "postproc")
(enableFeature buildSwresample "swresample")
(enableFeature buildSwscale "swscale")
] ++ optionals withLib [
"--libdir=${placeholder "lib"}/lib"
"--incdir=${placeholder "dev"}/include"
] ++ [
/*
* Documentation flags
*/
(enableFeature withDocumentation "doc")
(enableFeature withHtmlDoc "htmlpages")
(enableFeature withManPages "manpages")
] ++ optionals withManPages [
"--mandir=${placeholder "man"}/share/man"
] ++ [
(enableFeature withPodDoc "podpages")
(enableFeature withTxtDoc "txtpages")
] ++ optionals withDoc [
"--docdir=${placeholder "doc"}/share/doc/ffmpeg"
] ++ [
/*
* External libraries
*/
(enableFeature withAmf "amf")
(enableFeature withAlsa "alsa")
(enableFeature withBzlib "bzlib")
(enableFeature withCelt "libcelt")
(enableFeature withCuda "cuda")
(enableFeature withCudaLLVM "cuda-llvm")
(enableFeature withDav1d "libdav1d")
(enableFeature withFdkAac "libfdk-aac")
"--disable-libflite" # Force disable until a solution is found
(enableFeature withFontconfig "fontconfig")
(enableFeature withFreetype "libfreetype")
(enableFeature withFrei0r "frei0r")
(enableFeature withFribidi "libfribidi")
(enableFeature withGme "libgme")
(enableFeature withGnutls "gnutls")
(enableFeature withGsm "libgsm")
(enableFeature withLadspa "ladspa")
(enableFeature withMp3lame "libmp3lame")
(enableFeature withAom "libaom")
(enableFeature withAss "libass")
(enableFeature withBluray "libbluray")
(enableFeature withBs2b "libbs2b")
(enableFeature withDc1394 "libdc1394")
(enableFeature withDrm "libdrm")
(enableFeature withIconv "iconv")
(enableFeature withJack "libjack")
(enableFeature withMfx "libmfx")
(enableFeature withModplug "libmodplug")
(enableFeature withMysofa "libmysofa")
(enableFeature withOpus "libopus")
(optionalString (versionAtLeast version "5.0" && withLibplacebo) "--enable-libplacebo")
(enableFeature withSvg "librsvg")
(enableFeature withSrt "libsrt")
(enableFeature withSsh "libssh")
(enableFeature withTensorflow "libtensorflow")
(enableFeature withTheora "libtheora")
(enableFeature withV4l2 "libv4l2")
(enableFeature withV4l2M2m "v4l2-m2m")
(enableFeature withVaapi "vaapi")
(enableFeature withVdpau "vdpau")
(enableFeature withVorbis "libvorbis")
(enableFeature withVmaf "libvmaf")
(enableFeature withVpx "libvpx")
(enableFeature withWebp "libwebp")
(enableFeature withXlib "xlib")
(enableFeature withXcb "libxcb")
(enableFeature withXcbShm "libxcb-shm")
(enableFeature withXcbxfixes "libxcb-xfixes")
(enableFeature withXcbShape "libxcb-shape")
(enableFeature withXml2 "libxml2")
(enableFeature withLzma "lzma")
(enableFeature withNvdec "cuvid")
(enableFeature withNvdec "nvdec")
(enableFeature withNvenc "nvenc")
(enableFeature withOpenal "openal")
(enableFeature withOpencl "opencl")
(enableFeature withOpencoreAmrnb "libopencore-amrnb")
(enableFeature withOpengl "opengl")
(enableFeature withOpenh264 "libopenh264")
(enableFeature withOpenjpeg "libopenjpeg")
(enableFeature withOpenmpt "libopenmpt")
(enableFeature withPulse "libpulse")
(enableFeature withRav1e "librav1e")
(enableFeature withSvtav1 "libsvtav1")
(enableFeature withRtmp "librtmp")
(enableFeature withSdl2 "sdl2")
(enableFeature withSoxr "libsoxr")
(enableFeature withSpeex "libspeex")
(enableFeature withVidStab "libvidstab") # Actual min. version 2.0
(enableFeature withVoAmrwbenc "libvo-amrwbenc")
(enableFeature withX264 "libx264")
(enableFeature withX265 "libx265")
(enableFeature withXavs "libxavs")
(enableFeature withXvid "libxvid")
(enableFeature withZmq "libzmq")
(enableFeature withZimg "libzimg")
(enableFeature withZlib "zlib")
(enableFeature withVulkan "vulkan")
(enableFeature withGlslang "libglslang")
(enableFeature withSamba "libsmbclient")
/*
* Developer flags
*/
(enableFeature withDebug "debug")
(enableFeature withOptimisations "optimizations")
(enableFeature withExtraWarnings "extra-warnings")
(enableFeature withStripping "stripping")
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--host-cc=${buildPackages.stdenv.cc}/bin/cc"
] ++ optionals stdenv.cc.isClang [
"--cc=clang"
"--cxx=clang++"
];
# ffmpeg embeds the configureFlags verbatim in its binaries and because we
# configure binary, include, library dir etc., this causes references in
# outputs where we don't want them. Patch the generated config.h to remove all
# such references except for data.
postConfigure = let
toStrip = lib.remove "data" finalAttrs.outputs; # We want to keep references to the data dir.
in
"remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${placeholder o}") toStrip)} config.h";
nativeBuildInputs = [ removeReferencesTo addOpenGLRunpath perl pkg-config texinfo yasm ];
# TODO This was always in buildInputs before, why?
buildInputs =
let
nv-codec-headers = stdenv.mkDerivation rec {
pname = "nv-codec-headers";
version = "12.1.14.0";
src = fetchgit {
url = "https://git.videolan.org/git/ffmpeg/nv-codec-headers.git";
rev = "n${version}";
sha256 = "sha256-WJYuFmMGSW+B32LwE7oXv/IeTln6TNEeXSkquHh85Go=";
};
makeFlags = [
"PREFIX=$(out)"
];
};
in
optionals withFullDeps [ libdc1394 ]
++ optionals (withFullDeps && !stdenv.isDarwin) [ libraw1394 ] # TODO where does this belong to
++ optionals (withNvdec || withNvenc || withCuda) [ nv-codec-headers ]
++ optionals withAmf [ amf-headers ]
++ optionals withAlsa [ alsa-lib ]
++ optionals withAom [ libaom ]
++ optionals withAss [ libass ]
++ optionals withBluray [ libbluray ]
++ optionals withBs2b [ libbs2b ]
++ optionals withBzlib [ bzip2 ]
++ optionals withCaca [ libcaca ]
++ optionals withCelt [ celt ]
++ optionals withCudaLLVM [ clang ]
++ optionals withDav1d [ dav1d ]
++ optionals withDrm [ libdrm ]
++ optionals withFdkAac [ fdk_aac ]
++ optionals withFontconfig [ fontconfig ]
++ optionals withFreetype [ freetype ]
++ optionals withFrei0r [ frei0r ]
++ optionals withFribidi [ fribidi ]
++ optionals withGlslang [ glslang ]
++ optionals withGme [ game-music-emu ]
++ optionals withGnutls [ gnutls ]
++ optionals withGsm [ gsm ]
++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it?
++ optionals withJack [ libjack2 ]
++ optionals withLadspa [ ladspaH ]
++ optionals withLibplacebo [ libplacebo vulkan-headers ]
++ optionals withLzma [ xz ]
++ optionals withMfx [ intel-media-sdk ]
++ optionals withModplug [ libmodplug ]
++ optionals withMp3lame [ lame ]
++ optionals withMysofa [ libmysofa ]
++ optionals withOgg [ libogg ]
++ optionals withOpenal [ openal ]
++ optionals withOpencl [ ocl-icd opencl-headers ]
++ optionals withOpencoreAmrnb [ opencore-amr ]
++ optionals withOpengl [ libGL libGLU ]
++ optionals withOpenh264 [ openh264 ]
++ optionals withOpenjpeg [ openjpeg ]
++ optionals withOpenmpt [ libopenmpt ]
++ optionals withOpus [ libopus ]
++ optionals withPulse [ libpulseaudio ]
++ optionals withRav1e [ rav1e ]
++ optionals withRtmp [ rtmpdump ]
++ optionals withSamba [ samba ]
++ optionals withSdl2 [ SDL2 ]
++ optionals withSoxr [ soxr ]
++ optionals withSpeex [ speex ]
++ optionals withSrt [ srt ]
++ optionals withSsh [ libssh ]
++ optionals withSvg [ librsvg ]
++ optionals withSvtav1 [ svt-av1 ]
++ optionals withTensorflow [ libtensorflow ]
++ optionals withTheora [ libtheora ]
++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ]
++ optionals withVdpau [ libvdpau ]
++ optionals withVidStab [ vid-stab ]
++ optionals withVmaf [ libvmaf ]
++ optionals withVoAmrwbenc [ vo-amrwbenc ]
++ optionals withVorbis [ libvorbis ]
++ optionals withVpx [ libvpx ]
++ optionals withV4l2 [ libv4l ]
++ optionals withVulkan [ vulkan-headers vulkan-loader ]
++ optionals withWebp [ libwebp ]
++ optionals withX264 [ x264 ]
++ optionals withX265 [ x265 ]
++ optionals withXavs [ xavs ]
++ optionals withXcb [ libxcb ]
++ optionals withXlib [ libX11 libXv libXext ]
++ optionals withXml2 [ libxml2 ]
++ optionals withXvid [ xvidcore ]
++ optionals withZimg [ zimg ]
++ optionals withZlib [ zlib ]
++ optionals withZmq [ zeromq4 ]
++ optionals stdenv.isDarwin [
# TODO fine-grained flags
AVFoundation
Cocoa
CoreAudio
CoreMedia
CoreServices
MediaToolbox
VideoDecodeAcceleration
VideoToolbox
];
buildFlags = [ "all" ]
++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
# Fails with SIGABRT otherwise FIXME: Why?
checkPhase = let
ldLibraryPathEnv = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
libsToLink = [ ]
++ optional buildAvcodec "libavcodec"
++ optional buildAvdevice "libavdevice"
++ optional buildAvfilter "libavfilter"
++ optional buildAvformat "libavformat"
++ optional buildAvresample "libavresample"
++ optional buildAvutil "libavutil"
++ optional buildPostproc "libpostproc"
++ optional buildSwresample "libswresample"
++ optional buildSwscale "libswscale"
;
in ''
${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES
'';
outputs = optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default!
++ optionals withLib [ "lib" "dev" ]
++ optionals withDoc [ "doc" ]
++ optionals withManPages [ "man" ]
++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir.
;
postInstall = optionalString buildQtFaststart ''
install -D tools/qt-faststart -t $bin/bin
'';
# Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
postFixup = optionalString (stdenv.isLinux && withLib) ''
addOpenGLRunpath ${placeholder "lib"}/lib/libavcodec.so
addOpenGLRunpath ${placeholder "lib"}/lib/libavutil.so
'';
enableParallelBuilding = true;
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
meta = with lib; {
description = "A complete, cross-platform solution to record, convert and stream audio and video";
homepage = "https://www.ffmpeg.org/";
changelog = "https://github.com/FFmpeg/FFmpeg/blob/n${version}/Changelog";
longDescription = ''
FFmpeg is the leading multimedia framework, able to decode, encode, transcode,
mux, demux, stream, filter and play pretty much anything that humans and machines
have created. It supports the most obscure ancient formats up to the cutting edge.
No matter if they were designed by some standards committee, the community or
a corporation.
'';
license = with licenses; [ lgpl21Plus ]
++ optional withGPL gpl2Plus
++ optional withGPLv3 gpl3Plus
++ optional withUnfree unfreeRedistributable;
pkgConfigModules = [ "libavutil" ];
platforms = platforms.all;
maintainers = with maintainers; [ atemu ];
};
})

View File

@ -1,36 +0,0 @@
From 0de0a90f8fe5e1e48fa4ec7aa7c825ef88770f9d Mon Sep 17 00:00:00 2001
From: Ryan Foster <RytoEX@gmail.com>
Date: Mon, 9 Sep 2019 23:55:02 -0400
Subject: [PATCH] Enable file access and universal access for file URLs
When loading a local file, instead of disabling CEF's web security,
enable file access and universal access for file URLs. This should allow
local files to make CORS requests without completely disabling CEF's
security model.
---
obs-browser-source.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp
index ab1181e..c775283 100644
--- a/plugins/obs-browser/obs-browser-source.cpp
+++ b/plugins/obs-browser/obs-browser-source.cpp
@@ -179,9 +179,12 @@ bool BrowserSource::CreateBrowser()
#if ENABLE_LOCAL_FILE_URL_SCHEME
if (is_local) {
- /* Disable web security for file:// URLs to allow
- * local content access to remote APIs */
- cefBrowserSettings.web_security = STATE_DISABLED;
+ /* Enable file access and universal access from file://
+ * URLs to allow local content access to remote APIs */
+ cefBrowserSettings.file_access_from_file_urls =
+ STATE_ENABLED;
+ cefBrowserSettings.universal_access_from_file_urls =
+ STATE_ENABLED;
}
#endif
--
2.31.1

File diff suppressed because it is too large Load Diff

View File

@ -1,196 +0,0 @@
{ config
, lib
, stdenv
, fetchFromGitHub
, addOpenGLRunpath
, cmake
, fdk_aac
, ffmpeg
, jansson
, libjack2
, libxkbcommon
, libpthreadstubs
, libXdmcp
, qtbase
, qtsvg
, speex
, libv4l
, x264
, curl
, wayland
, xorg
, pkg-config
, libvlc
, mbedtls
, wrapGAppsHook
, scriptingSupport ? true
, luajit
, swig4
, python3
, alsaSupport ? stdenv.isLinux
, alsa-lib
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux
, libpulseaudio
, pciutils
, pipewireSupport ? stdenv.isLinux
, pipewire
, libdrm
, libajantv2
, librist
, libva
, srt
, qtwayland
, wrapQtAppsHook
, nlohmann_json
, asio
, websocketpp
, amf-headers
, libGL
, vulkan-loader
, decklinkSupport ? false
, blackmagic-desktop-video ? null
, libcef
, libdatachannel
, pkgs
, qrcodegencpp ? pkgs.callPackage ./qrcodegencpp.nix {}
, onevpl ? pkgs.callPackage ./onevpl.nix {}
}:
assert (!decklinkSupport || blackmagic-desktop-video!=null) || builtins.throw "decklinkSupport enabled but blackmagic-desktop-video is null";
let
inherit (lib) optional optionals;
in
stdenv.mkDerivation rec {
pname = "obs-studio-amf";
version = "30.0.2";
src = fetchFromGitHub {
owner = "obsproject";
repo = "obs-studio";
rev = version;
sha256 = "sha256-8pX1kqibrtDIaE1+/Pey1A5bu6MwFTXLrBOah4rsF+4=";
fetchSubmodules = true;
};
env.NIX_CFLAGS_COMPILE = toString [
"-Wno-error"
];
patches = [
./obs-amf-patch.patch # OBS AMF Patch
./Enable-file-access-and-universal-access-for-file-URL.patch
./fix-nix-plugin-path.patch
./av1-vaapi.patch
./ffmpeg61.patch
];
nativeBuildInputs = [
addOpenGLRunpath
cmake
pkg-config
wrapGAppsHook
wrapQtAppsHook
]
++ optional scriptingSupport swig4;
buildInputs = [
amf-headers
websocketpp
asio
nlohmann_json
curl
fdk_aac
ffmpeg
jansson
libcef
libjack2
libv4l
libxkbcommon
libpthreadstubs
libXdmcp
qtbase
qtsvg
speex
wayland
x264
libvlc
mbedtls
pciutils
libajantv2
librist
libva
srt
qtwayland
libdatachannel
qrcodegencpp
onevpl
]
++ optionals scriptingSupport [ luajit python3 ]
++ optional alsaSupport alsa-lib
++ optional pulseaudioSupport libpulseaudio
++ optionals pipewireSupport [ pipewire libdrm ];
# Copied from the obs-linuxbrowser
postUnpack = ''
cp -rs ${libcef}/share/cef cef
'';
# obs attempts to dlopen libobs-opengl, it fails unless we make sure
# DL_OPENGL is an explicit path. Not sure if there's a better way
# to handle this.
cmakeFlags = [
"-DOBS_VERSION_OVERRIDE=${version}"
"-Wno-dev" # kill dev warnings that are useless for packaging
# Add support for browser source
"-DBUILD_BROWSER=ON"
"-DCEF_ROOT_DIR=../../cef"
"-DENABLE_JACK=ON"
];
dontWrapGApps = true;
preFixup = let
wrapperLibraries = [
xorg.libX11
libvlc
] ++ optionals decklinkSupport [
blackmagic-desktop-video
];
in
''
#Remove libs from libcef, they are symlinks and can't be patchelfed
rm $out/lib/obs-plugins/libcef.so $out/lib/obs-plugins/libEGL.so $out/lib/obs-plugins/libGLESv2.so $out/lib/obs-plugins/libvk_swiftshader.so
#Suffix on libgl and vulkan-loader so it can be overriden by helper scripts from amdgpu-pro
qtWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}"
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL vulkan-loader ]}"
''${gappsWrapperArgs[@]}
)
'';
postFixup = lib.optionalString stdenv.isLinux ''
addOpenGLRunpath $out/lib/lib*.so
addOpenGLRunpath $out/lib/obs-plugins/*.so
##Symlink libcef related things after patchelfing
ln -s ${libcef}/share/cef/Release/libcef.so $out/lib/obs-plugins/libcef.so
#OBS seems to need those to be from libcef for hardware acceleration (at least on AMD card)
ln -s ${libcef}/share/cef/Release/libEGL.so $out/lib/obs-plugins/libEGL.so
ln -s ${libcef}/share/cef/Release/libGLESv2.so $out/lib/obs-plugins/libGLESv2.so
#Doesn't seem needed but added anyway
ln -s ${libcef}/share/cef/Release/libvk_swiftshader.so $out/lib/obs-plugins/libvk_swiftshader.so
'';
meta = with lib; {
description = "Free and open source software for video recording and live streaming. With AMD AMF";
longDescription = ''
This project is a rewrite of what was formerly known as "Open Broadcaster
Software", software originally designed for recording and streaming live
video content, efficiently
'';
homepage = "https://obsproject.com";
maintainers = with maintainers; [ ];
license = licenses.gpl2Plus;
platforms = [ "x86_64-linux" ];
mainProgram = "obs";
};
}

View File

@ -1,286 +0,0 @@
From 7ed9b1f3a6b5e73a39daf906c8e8c19e93fce4b4 Mon Sep 17 00:00:00 2001
From: Stephen Seo <seo.disparate@gmail.com>
Date: Wed, 29 Nov 2023 22:06:09 +0900
Subject: [PATCH 1/4] deps/media-playback: Use new (nb_)coded_side_data FFmpeg
6.1 API
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
The change in deps/media-playback/media-playback/decode.c is due to
FFmpeg moving "side_data" into AVCodecParameters which is mentioned in
commit [1] in FFmpeg's repository.
In summary of the "side_data" change, AVStream.side_data is deprecated
and replaced with AVStream.codecpar->coded_side_data, and
AVStream.nb_side_data is replaced with
AVStream.codecpar->nb_coded_side_data.
[1]: avcodec/codec_par: add side data to AVCodecParameters
https://github.com/FFmpeg/FFmpeg/commit/21d7cc6fa9a26e94965fa71b25655d07568450fe
---
deps/media-playback/media-playback/decode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/deps/media-playback/media-playback/decode.c b/deps/media-playback/media-playback/decode.c
index 55b91c140ace4..40853f171bde7 100644
--- a/deps/media-playback/media-playback/decode.c
+++ b/deps/media-playback/media-playback/decode.c
@@ -114,8 +114,14 @@ static uint16_t get_max_luminance(const AVStream *stream)
{
uint32_t max_luminance = 0;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
for (int i = 0; i < stream->nb_side_data; i++) {
const AVPacketSideData *const sd = &stream->side_data[i];
+#else
+ for (int i = 0; i < stream->codecpar->nb_coded_side_data; i++) {
+ const AVPacketSideData *const sd =
+ &stream->codecpar->coded_side_data[i];
+#endif
switch (sd->type) {
case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: {
const AVMasteringDisplayMetadata *mastering =
From 92fc9f69ccff2cb12bb8ef877e9238f5d46588a8 Mon Sep 17 00:00:00 2001
From: Stephen Seo <seo.disparate@gmail.com>
Date: Wed, 29 Nov 2023 22:08:42 +0900
Subject: [PATCH 2/4] deps/media-playback: In check for key-frame, use new
FFmpeg 6.1 API
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
AVFrame.key_frame was replaced with a flag in AVFrame.flags. The commit
adding the flag is [1] in FFmpeg's repository, and the deprecation is in
commit [2].
In summary of the "key_frame" change, AVFrame.key_frame is deprecated,
and AVFrame.flags indicates with a bit flag if it is a key frame (with
the enum/defined AV_FRAME_FLAG_KEY).
[1]: avutil/frame: add a keyframe flag to AVFrame
https://github.com/FFmpeg/FFmpeg/commit/cc11191fda0471017b03c1434d6d8cb79f6914e5
[2]: avutil/frame: deprecate key_frame
https://github.com/FFmpeg/FFmpeg/commit/3e06f6f04020bef32fa42bc9d7f96e76a46453aa
---
deps/media-playback/media-playback/media.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/deps/media-playback/media-playback/media.c b/deps/media-playback/media-playback/media.c
index 566eb9e35c9ef..07b040dd8235c 100644
--- a/deps/media-playback/media-playback/media.c
+++ b/deps/media-playback/media-playback/media.c
@@ -504,7 +504,12 @@ void mp_media_next_video(mp_media_t *m, bool preload)
}
if (!m->is_local_file && !d->got_first_keyframe) {
+
+#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 29, 100)
if (!f->key_frame)
+#else
+ if (!(f->flags & AV_FRAME_FLAG_KEY))
+#endif
return;
d->got_first_keyframe = true;
From ed1e0795acde8349ab18b631c545f56e5a3acb9d Mon Sep 17 00:00:00 2001
From: Stephen Seo <seo.disparate@gmail.com>
Date: Wed, 29 Nov 2023 20:07:10 +0900
Subject: [PATCH 3/4] libobs: Fence off unnecessary code due to FFmpeg v6.1
changes
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
This commit prevents obs from using the "fenced" code if using FFmpeg
6.1, since in FFmpeg commit [1] the "side_data" is added to
`AVCodecParameters`, and therefore the existing/following
`avcodec_parameters_copy(...)` will account for the metadata.
[1]: avcodec/codec_par: add side data to AVCodecParameters
https://github.com/FFmpeg/FFmpeg/commit/21d7cc6fa9a26e94965fa71b25655d07568450fe
---
libobs/media-io/media-remux.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libobs/media-io/media-remux.c b/libobs/media-io/media-remux.c
index 7d5eead200012..827d4e59b18ed 100644
--- a/libobs/media-io/media-remux.c
+++ b/libobs/media-io/media-remux.c
@@ -91,6 +91,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
return false;
}
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
#if FF_API_BUFFER_SIZE_T
int content_size;
#else
@@ -125,6 +126,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
mastering_size);
}
}
+#endif
ret = avcodec_parameters_copy(out_stream->codecpar,
in_stream->codecpar);
From 6d0381f98ce0a5624901b0042d624ea972a10c2b Mon Sep 17 00:00:00 2001
From: Stephen Seo <seo.disparate@gmail.com>
Date: Wed, 29 Nov 2023 20:09:08 +0900
Subject: [PATCH 4/4] obs-ffmpeg: Use new side-data FFmpeg 6.1 API
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
This commit replaces usage of `av_stream_add_side_data(...)` with
`av_packet_side_data_add(...)`, as the former was deprecated in favor of
the latter.
The FFmpeg commit that deprecated `av_stream_add_side_data(...)` is [1].
The FFmpeg commit that introduced `av_packet_side_data_add(...)` is [2].
Note that the deprecation commit is after the new API function. The
commit in between [3] appears to be changes that migrates to the usage
of the new API function.
[1]: avformat/avformat: use the side data from AVStream.codecpar
https://github.com/FFmpeg/FFmpeg/commit/5432d2aacad5fa7420fe2d9369ed061d521e92d6
[2]: avcodec/packet: add generic side data helpers
https://github.com/FFmpeg/FFmpeg/commit/74279227dd28d01b447edb8e617a545982171c2c
[3]: avcodec/codec_par: add side data to AVCodecParameters
https://github.com/FFmpeg/FFmpeg/commit/21d7cc6fa9a26e94965fa71b25655d07568450fe
---
plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c | 16 ++++++++++++++++
plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c | 16 ++++++++++++++++
plugins/obs-ffmpeg/obs-ffmpeg-output.c | 16 ++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
index 740b60e5bf46e..8fb84aa7c4e0b 100644
--- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
+++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
@@ -498,9 +498,17 @@ static void create_video_stream(struct ffmpeg_mux *ffm)
av_content_light_metadata_alloc(&content_size);
content->MaxCLL = max_luminance;
content->MaxFALL = max_luminance;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(ffm->video_stream,
AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
(uint8_t *)content, content_size);
+#else
+ av_packet_side_data_add(
+ &ffm->video_stream->codecpar->coded_side_data,
+ &ffm->video_stream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)content,
+ content_size, 0);
+#endif
AVMasteringDisplayMetadata *const mastering =
av_mastering_display_metadata_alloc();
@@ -516,10 +524,18 @@ static void create_video_stream(struct ffmpeg_mux *ffm)
mastering->max_luminance = av_make_q(max_luminance, 1);
mastering->has_primaries = 1;
mastering->has_luminance = 1;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(ffm->video_stream,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
(uint8_t *)mastering,
sizeof(*mastering));
+#else
+ av_packet_side_data_add(
+ &ffm->video_stream->codecpar->coded_side_data,
+ &ffm->video_stream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+ (uint8_t *)mastering, sizeof(*mastering), 0);
+#endif
}
if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER)
diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c
index f33ee77365274..a56dd91bcc38e 100644
--- a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c
+++ b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c
@@ -168,9 +168,17 @@ static bool create_video_stream(struct ffmpeg_output *stream,
av_content_light_metadata_alloc(&content_size);
content->MaxCLL = hdr_nominal_peak_level;
content->MaxFALL = hdr_nominal_peak_level;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(data->video,
AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
(uint8_t *)content, content_size);
+#else
+ av_packet_side_data_add(
+ &data->video->codecpar->coded_side_data,
+ &data->video->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)content,
+ content_size, 0);
+#endif
AVMasteringDisplayMetadata *const mastering =
av_mastering_display_metadata_alloc();
@@ -186,10 +194,18 @@ static bool create_video_stream(struct ffmpeg_output *stream,
mastering->max_luminance = av_make_q(hdr_nominal_peak_level, 1);
mastering->has_primaries = 1;
mastering->has_luminance = 1;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(data->video,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
(uint8_t *)mastering,
sizeof(*mastering));
+#else
+ av_packet_side_data_add(
+ &data->video->codecpar->coded_side_data,
+ &data->video->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+ (uint8_t *)mastering, sizeof(*mastering), 0);
+#endif
}
context = avcodec_alloc_context3(NULL);
context->codec_type = codec->type;
diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
index ec02b59cda9d8..c7786153392e5 100644
--- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c
+++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
@@ -213,9 +213,17 @@ static bool create_video_stream(struct ffmpeg_data *data)
av_content_light_metadata_alloc(&content_size);
content->MaxCLL = hdr_nominal_peak_level;
content->MaxFALL = hdr_nominal_peak_level;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(data->video,
AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
(uint8_t *)content, content_size);
+#else
+ av_packet_side_data_add(
+ &data->video->codecpar->coded_side_data,
+ &data->video->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)content,
+ content_size, 0);
+#endif
AVMasteringDisplayMetadata *const mastering =
av_mastering_display_metadata_alloc();
@@ -231,10 +239,18 @@ static bool create_video_stream(struct ffmpeg_data *data)
mastering->max_luminance = av_make_q(hdr_nominal_peak_level, 1);
mastering->has_primaries = 1;
mastering->has_luminance = 1;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 31, 102)
av_stream_add_side_data(data->video,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
(uint8_t *)mastering,
sizeof(*mastering));
+#else
+ av_packet_side_data_add(
+ &data->video->codecpar->coded_side_data,
+ &data->video->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+ (uint8_t *)mastering, sizeof(*mastering), 0);
+#endif
}
closest_format = data->config.format;

View File

@ -1,26 +0,0 @@
diff --git a/cmake/Modules/ObsDefaults_Linux.cmake b/cmake/Modules/ObsDefaults_Linux.cmake
index d1e58a083..a03c6b98e 100644
--- a/cmake/Modules/ObsDefaults_Linux.cmake
+++ b/cmake/Modules/ObsDefaults_Linux.cmake
@@ -76,7 +76,7 @@ macro(setup_obs_project)
set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}")
- set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${OBS_SCRIPT_PLUGIN_DESTINATION}")
+ set(OBS_SCRIPT_PLUGIN_PATH "${OBS_SCRIPT_PLUGIN_DESTINATION}")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}")
else()
set(OBS_EXECUTABLE_DESTINATION "bin/${_ARCH_SUFFIX}bit")
diff --git a/libobs/obs-nix.c b/libobs/obs-nix.c
index b006a5598..531655eb3 100644
--- a/libobs/obs-nix.c
+++ b/libobs/obs-nix.c
@@ -56,7 +56,7 @@ const char *get_module_extension(void)
#define FLATPAK_PLUGIN_PATH "/app/plugins"
static const char *module_bin[] = {
- OBS_INSTALL_PREFIX "/" OBS_PLUGIN_DESTINATION,
+ OBS_PLUGIN_DESTINATION,
"../../obs-plugins/" BIT_STRING,
FLATPAK_PLUGIN_PATH "/" OBS_PLUGIN_DESTINATION,
};

View File

@ -1,649 +0,0 @@
diff --git a/plugins/obs-ffmpeg/CMakeLists.txt b/plugins/obs-ffmpeg/CMakeLists.txt
index 04530ef39..51409f413 100644
--- a/plugins/obs-ffmpeg/CMakeLists.txt
+++ b/plugins/obs-ffmpeg/CMakeLists.txt
@@ -103,10 +103,12 @@ if(OS_WINDOWS)
target_sources(obs-ffmpeg PRIVATE obs-nvenc-helpers.c obs-nvenc.c obs-nvenc.h obs-ffmpeg.rc texture-amf-opts.hpp
texture-amf.cpp)
elseif(OS_LINUX OR OS_FREEBSD)
+ add_subdirectory(obs-amf-test)
+
find_package(Libva REQUIRED)
find_package(Libpci REQUIRED)
- target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c vaapi-utils.c vaapi-utils.h)
+ target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c vaapi-utils.c vaapi-utils.h texture-amf.cpp)
target_link_libraries(obs-ffmpeg PRIVATE Libva::va Libva::drm Libpci::pci)
endif()
diff --git a/plugins/obs-ffmpeg/cmake/legacy.cmake b/plugins/obs-ffmpeg/cmake/legacy.cmake
index 4cc75b341..3319e8039 100644
--- a/plugins/obs-ffmpeg/cmake/legacy.cmake
+++ b/plugins/obs-ffmpeg/cmake/legacy.cmake
@@ -107,9 +107,10 @@ if(OS_WINDOWS)
obs-ffmpeg.rc)
elseif(OS_POSIX AND NOT OS_MACOS)
+ add_subdirectory(obs-amf-test)
find_package(Libva REQUIRED)
find_package(Libpci REQUIRED)
- target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c vaapi-utils.c vaapi-utils.h)
+ target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c vaapi-utils.c vaapi-utils.h texture-amf.cpp)
target_link_libraries(obs-ffmpeg PRIVATE Libva::va Libva::drm LIBPCI::LIBPCI)
endif()
diff --git a/plugins/obs-ffmpeg/obs-amf-test/CMakeLists.txt b/plugins/obs-ffmpeg/obs-amf-test/CMakeLists.txt
index 6221c69df..13068f813 100644
--- a/plugins/obs-ffmpeg/obs-amf-test/CMakeLists.txt
+++ b/plugins/obs-ffmpeg/obs-amf-test/CMakeLists.txt
@@ -7,9 +7,14 @@ find_package(AMF 1.4.29 REQUIRED)
add_executable(obs-amf-test)
add_executable(OBS::amf-test ALIAS obs-amf-test)
-target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
-target_link_libraries(obs-amf-test PRIVATE OBS::COMutils AMF::AMF d3d11 dxgi dxguid)
-
+if(OS_WINDOWS)
+ target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
+ target_link_libraries(obs-amf-test PRIVATE OBS::COMutils AMF::AMF d3d11 dxgi dxguid)
+elseif(OS_POSIX AND NOT OS_MACOS)
+ find_package(Vulkan REQUIRED)
+ target_sources(obs-amf-test PRIVATE obs-amf-test-linux.cpp)
+ target_link_libraries(obs-amf-test dl Vulkan::Vulkan AMF::AMF)
+endif()
# cmake-format: off
set_target_properties_obs(obs-amf-test PROPERTIES FOLDER plugins/obs-ffmpeg)
# cmake-format: on
diff --git a/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake b/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
index e00cef1cf..6620e359d 100644
--- a/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
+++ b/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
@@ -6,9 +6,14 @@ find_package(AMF 1.4.29 REQUIRED)
target_include_directories(obs-amf-test PRIVATE ${CMAKE_SOURCE_DIR}/libobs)
-target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
-target_link_libraries(obs-amf-test d3d11 dxgi dxguid AMF::AMF)
-
+if(OS_WINDOWS)
+ target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
+ target_link_libraries(obs-amf-test d3d11 dxgi dxguid AMF::AMF)
+elseif(OS_POSIX AND NOT OS_MACOS)
+ find_package(Vulkan REQUIRED)
+ target_sources(obs-amf-test PRIVATE obs-amf-test-linux.cpp)
+ target_link_libraries(obs-amf-test dl Vulkan::Vulkan AMF::AMF)
+endif()
set_target_properties(obs-amf-test PROPERTIES FOLDER "plugins/obs-ffmpeg")
setup_binary_target(obs-amf-test)
diff --git a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test-linux.cpp b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test-linux.cpp
new file mode 100644
index 000000000..db437d851
--- /dev/null
+++ b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test-linux.cpp
@@ -0,0 +1,140 @@
+#include <AMF/core/Factory.h>
+#include <AMF/core/Trace.h>
+#include <AMF/components/VideoEncoderVCE.h>
+#include <AMF/components/VideoEncoderHEVC.h>
+#include <AMF/components/VideoEncoderAV1.h>
+
+#include <dlfcn.h>
+#include <vulkan/vulkan.hpp>
+
+#include <string>
+#include <map>
+
+using namespace amf;
+
+struct adapter_caps {
+ bool is_amd = false;
+ bool supports_avc = false;
+ bool supports_hevc = false;
+ bool supports_av1 = false;
+};
+
+static AMFFactory *amf_factory = nullptr;
+static std::map<uint32_t, adapter_caps> adapter_info;
+
+static bool has_encoder(AMFContextPtr &amf_context, const wchar_t *encoder_name)
+{
+ AMFComponentPtr encoder;
+ AMF_RESULT res = amf_factory->CreateComponent(amf_context, encoder_name,
+ &encoder);
+ return res == AMF_OK;
+}
+
+static bool get_adapter_caps(uint32_t adapter_idx)
+{
+ if (adapter_idx)
+ return false;
+
+ adapter_caps &caps = adapter_info[adapter_idx];
+
+ AMF_RESULT res;
+ AMFContextPtr amf_context;
+ res = amf_factory->CreateContext(&amf_context);
+ if (res != AMF_OK)
+ return true;
+
+ AMFContext1 *context1 = NULL;
+ res = amf_context->QueryInterface(AMFContext1::IID(),
+ (void **)&context1);
+ if (res != AMF_OK)
+ return false;
+ res = context1->InitVulkan(nullptr);
+ context1->Release();
+ if (res != AMF_OK)
+ return false;
+
+ caps.is_amd = true;
+ caps.supports_avc = has_encoder(amf_context, AMFVideoEncoderVCE_AVC);
+ caps.supports_hevc = has_encoder(amf_context, AMFVideoEncoder_HEVC);
+ caps.supports_av1 = has_encoder(amf_context, AMFVideoEncoder_AV1);
+
+ return true;
+}
+
+int main(void)
+try {
+ AMF_RESULT res;
+ VkResult vkres;
+
+ VkApplicationInfo app_info = {};
+ app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+ app_info.pApplicationName = "obs-amf-test";
+ app_info.apiVersion = VK_API_VERSION_1_2;
+
+ VkInstanceCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ info.pApplicationInfo = &app_info;
+
+ VkInstance instance;
+ vkres = vkCreateInstance(&info, nullptr, &instance);
+ if (vkres != VK_SUCCESS)
+ throw "Failed to initialize Vulkan";
+
+ uint32_t device_count;
+ vkres = vkEnumeratePhysicalDevices(instance, &device_count, nullptr);
+ if (vkres != VK_SUCCESS || !device_count)
+ throw "Failed to enumerate Vulkan devices";
+
+ VkPhysicalDevice *devices = new VkPhysicalDevice[device_count];
+ vkres = vkEnumeratePhysicalDevices(instance, &device_count, devices);
+ if (vkres != VK_SUCCESS)
+ throw "Failed to enumerate Vulkan devices";
+
+ VkPhysicalDeviceDriverProperties driver_props = {};
+ driver_props.sType =
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
+ VkPhysicalDeviceProperties2 device_props = {};
+ device_props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
+ device_props.pNext = &driver_props;
+ vkGetPhysicalDeviceProperties2(devices[0], &device_props);
+
+ if (strcmp(driver_props.driverName, "AMD proprietary driver"))
+ throw "Not running AMD proprietary driver";
+
+ vkDestroyInstance(instance, nullptr);
+
+ /* --------------------------------------------------------- */
+ /* try initializing amf, I guess */
+
+ void *amf_module = dlopen(AMF_DLL_NAMEA, RTLD_LAZY);
+ if (!amf_module)
+ throw "Failed to load AMF lib";
+
+ auto init = (AMFInit_Fn)dlsym(amf_module, AMF_INIT_FUNCTION_NAME);
+ if (!init)
+ throw "Failed to get init func";
+
+ res = init(AMF_FULL_VERSION, &amf_factory);
+ if (res != AMF_OK)
+ throw "AMFInit failed";
+
+ uint32_t idx = 0;
+ while (get_adapter_caps(idx++))
+ ;
+
+ for (auto &[idx, caps] : adapter_info) {
+ printf("[%u]\n", idx);
+ printf("is_amd=%s\n", caps.is_amd ? "true" : "false");
+ printf("supports_avc=%s\n",
+ caps.supports_avc ? "true" : "false");
+ printf("supports_hevc=%s\n",
+ caps.supports_hevc ? "true" : "false");
+ printf("supports_av1=%s\n",
+ caps.supports_av1 ? "true" : "false");
+ }
+
+ return 0;
+} catch (const char *text) {
+ printf("[error]\nstring=%s\n", text);
+ return 0;
+}
diff --git a/plugins/obs-ffmpeg/obs-ffmpeg.c b/plugins/obs-ffmpeg/obs-ffmpeg.c
index 7eb9a876d..7b5c9bdc9 100644
--- a/plugins/obs-ffmpeg/obs-ffmpeg.c
+++ b/plugins/obs-ffmpeg/obs-ffmpeg.c
@@ -355,6 +355,9 @@ static bool hevc_vaapi_supported(void)
#ifdef _WIN32
extern void obs_nvenc_load(bool h264, bool hevc, bool av1);
extern void obs_nvenc_unload(void);
+#endif
+
+#if defined(_WIN32) || defined(__linux__)
extern void amf_load(void);
extern void amf_unload(void);
#endif
@@ -429,7 +432,7 @@ bool obs_module_load(void)
#endif
}
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__linux__)
amf_load();
#endif
@@ -470,8 +473,11 @@ void obs_module_unload(void)
obs_ffmpeg_unload_logging();
#endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__linux__)
amf_unload();
+#endif
+
+#ifdef _WIN32
obs_nvenc_unload();
#endif
}
diff --git a/plugins/obs-ffmpeg/texture-amf-opts.hpp b/plugins/obs-ffmpeg/texture-amf-opts.hpp
index b1c37d200..d28e3f77e 100644
--- a/plugins/obs-ffmpeg/texture-amf-opts.hpp
+++ b/plugins/obs-ffmpeg/texture-amf-opts.hpp
@@ -321,7 +321,7 @@ static void amf_apply_opt(amf_base *enc, obs_option *opt)
val = atoi(opt->value);
}
- os_utf8_to_wcs(opt->name, 0, wname, _countof(wname));
+ os_utf8_to_wcs(opt->name, 0, wname, amf_countof(wname));
if (is_bool) {
bool bool_val = (bool)val;
set_amf_property(enc, wname, bool_val);
diff --git a/plugins/obs-ffmpeg/texture-amf.cpp b/plugins/obs-ffmpeg/texture-amf.cpp
index 7f45a8cc9..2c0b44c4e 100644
--- a/plugins/obs-ffmpeg/texture-amf.cpp
+++ b/plugins/obs-ffmpeg/texture-amf.cpp
@@ -11,6 +11,7 @@
#include <mutex>
#include <deque>
#include <map>
+#include <inttypes.h>
#include <AMF/components/VideoEncoderHEVC.h>
#include <AMF/components/VideoEncoderVCE.h>
@@ -18,6 +19,7 @@
#include <AMF/core/Factory.h>
#include <AMF/core/Trace.h>
+#ifdef _WIN32
#include <dxgi.h>
#include <d3d11.h>
#include <d3d11_1.h>
@@ -25,6 +27,8 @@
#include <util/windows/device-enum.h>
#include <util/windows/HRError.hpp>
#include <util/windows/ComPtr.hpp>
+#endif
+
#include <util/platform.h>
#include <util/util.hpp>
#include <util/pipe.h>
@@ -55,8 +59,10 @@ struct amf_error {
struct handle_tex {
uint32_t handle;
+#ifdef _WIN32
ComPtr<ID3D11Texture2D> tex;
ComPtr<IDXGIKeyedMutex> km;
+#endif
};
struct adapter_caps {
@@ -72,7 +78,7 @@ static std::map<uint32_t, adapter_caps> caps;
static bool h264_supported = false;
static AMFFactory *amf_factory = nullptr;
static AMFTrace *amf_trace = nullptr;
-static HMODULE amf_module = nullptr;
+static void *amf_module = nullptr;
static uint64_t amf_version = 0;
/* ========================================================================= */
@@ -121,9 +127,11 @@ struct amf_base {
virtual void init() = 0;
};
-using d3dtex_t = ComPtr<ID3D11Texture2D>;
using buf_t = std::vector<uint8_t>;
+#ifdef _WIN32
+using d3dtex_t = ComPtr<ID3D11Texture2D>;
+
struct amf_texencode : amf_base, public AMFSurfaceObserver {
volatile bool destroying = false;
@@ -160,6 +168,7 @@ struct amf_texencode : amf_base, public AMFSurfaceObserver {
throw amf_error("InitDX11 failed", res);
}
};
+#endif
struct amf_fallback : amf_base, public AMFSurfaceObserver {
volatile bool destroying = false;
@@ -187,9 +196,21 @@ struct amf_fallback : amf_base, public AMFSurfaceObserver {
void init() override
{
+#if defined(_WIN32)
AMF_RESULT res = amf_context->InitDX11(nullptr, AMF_DX11_1);
if (res != AMF_OK)
throw amf_error("InitDX11 failed", res);
+#elif defined(__linux__)
+ AMFContext1 *context1 = NULL;
+ AMF_RESULT res = amf_context->QueryInterface(
+ AMFContext1::IID(), (void **)&context1);
+ if (res != AMF_OK)
+ throw amf_error("CreateContext1 failed", res);
+ res = context1->InitVulkan(nullptr);
+ context1->Release();
+ if (res != AMF_OK)
+ throw amf_error("InitVulkan failed", res);
+#endif
}
};
@@ -231,13 +252,18 @@ static void set_amf_property(amf_base *enc, const wchar_t *name, const T &value)
: (enc->codec == amf_codec_type::HEVC) \
? AMF_VIDEO_ENCODER_HEVC_##name \
: AMF_VIDEO_ENCODER_AV1_##name)
+#define get_opt_name_enum(name) \
+ ((enc->codec == amf_codec_type::AVC) ? (int)AMF_VIDEO_ENCODER_##name \
+ : (enc->codec == amf_codec_type::HEVC) \
+ ? (int)AMF_VIDEO_ENCODER_HEVC_##name \
+ : (int)AMF_VIDEO_ENCODER_AV1_##name)
#define set_opt(name, value) set_amf_property(enc, get_opt_name(name), value)
#define get_opt(name, value) get_amf_property(enc, get_opt_name(name), value)
#define set_avc_opt(name, value) set_avc_property(enc, name, value)
#define set_hevc_opt(name, value) set_hevc_property(enc, name, value)
#define set_av1_opt(name, value) set_av1_property(enc, name, value)
#define set_enum_opt(name, value) \
- set_amf_property(enc, get_opt_name(name), get_opt_name(name##_##value))
+ set_amf_property(enc, get_opt_name(name), get_opt_name_enum(name##_##value))
#define set_avc_enum(name, value) \
set_avc_property(enc, name, AMF_VIDEO_ENCODER_##name##_##value)
#define set_hevc_enum(name, value) \
@@ -248,6 +274,7 @@ static void set_amf_property(amf_base *enc, const wchar_t *name, const T &value)
/* ------------------------------------------------------------------------- */
/* Implementation */
+#ifdef _WIN32
static HMODULE get_lib(const char *lib)
{
HMODULE mod = GetModuleHandleA(lib);
@@ -394,6 +421,7 @@ static void get_tex_from_handle(amf_texencode *enc, uint32_t handle,
*km_out = km.Detach();
*tex_out = tex.Detach();
}
+#endif
static constexpr amf_int64 macroblock_size = 16;
@@ -510,7 +538,7 @@ static void convert_to_encoder_packet(amf_base *enc, AMFDataPtr &data,
enc->packet_data = AMFBufferPtr(data);
data->GetProperty(L"PTS", &packet->pts);
- const wchar_t *get_output_type;
+ const wchar_t *get_output_type = NULL;
switch (enc->codec) {
case amf_codec_type::AVC:
get_output_type = AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE;
@@ -644,6 +672,7 @@ static void amf_encode_base(amf_base *enc, AMFSurface *amf_surf,
static bool amf_encode_tex(void *data, uint32_t handle, int64_t pts,
uint64_t lock_key, uint64_t *next_key,
encoder_packet *packet, bool *received_packet)
+#ifdef _WIN32
try {
amf_texencode *enc = (amf_texencode *)data;
ID3D11DeviceContext *context = enc->context;
@@ -720,6 +749,18 @@ try {
*received_packet = false;
return false;
}
+#else
+{
+ UNUSED_PARAMETER(data);
+ UNUSED_PARAMETER(handle);
+ UNUSED_PARAMETER(pts);
+ UNUSED_PARAMETER(lock_key);
+ UNUSED_PARAMETER(next_key);
+ UNUSED_PARAMETER(packet);
+ UNUSED_PARAMETER(received_packet);
+ return false;
+}
+#endif
static buf_t alloc_buf(amf_fallback *enc)
{
@@ -1184,6 +1225,7 @@ static const char *amf_avc_get_name(void *)
static inline int get_avc_preset(amf_base *enc, const char *preset)
{
+ UNUSED_PARAMETER(enc);
if (astrcmpi(preset, "quality") == 0)
return AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY;
else if (astrcmpi(preset, "speed") == 0)
@@ -1298,7 +1340,7 @@ static bool amf_avc_init(void *data, obs_data_t *settings)
set_avc_property(enc, B_PIC_PATTERN, bf);
} else if (bf != 0) {
- warn("B-Frames set to %lld but b-frames are not "
+ warn("B-Frames set to %" PRId64 " but b-frames are not "
"supported by this device",
bf);
bf = 0;
@@ -1343,12 +1385,12 @@ static bool amf_avc_init(void *data, obs_data_t *settings)
info("settings:\n"
"\trate_control: %s\n"
- "\tbitrate: %d\n"
- "\tcqp: %d\n"
+ "\tbitrate: %" PRId64 "\n"
+ "\tcqp: %" PRId64 "\n"
"\tkeyint: %d\n"
"\tpreset: %s\n"
"\tprofile: %s\n"
- "\tb-frames: %d\n"
+ "\tb-frames: %" PRId64 "\n"
"\twidth: %d\n"
"\theight: %d\n"
"\tparams: %s",
@@ -1420,6 +1462,7 @@ static void amf_avc_create_internal(amf_base *enc, obs_data_t *settings)
static void *amf_avc_create_texencode(obs_data_t *settings,
obs_encoder_t *encoder)
+#ifdef _WIN32
try {
check_texture_encode_capability(encoder, amf_codec_type::AVC);
@@ -1442,6 +1485,12 @@ try {
blog(LOG_ERROR, "[texture-amf-h264] %s: %s", __FUNCTION__, err);
return obs_encoder_create_rerouted(encoder, "h264_fallback_amf");
}
+#else
+{
+ UNUSED_PARAMETER(settings);
+ return obs_encoder_create_rerouted(encoder, "h264_fallback_amf");
+}
+#endif
static void *amf_avc_create_fallback(obs_data_t *settings,
obs_encoder_t *encoder)
@@ -1534,6 +1583,7 @@ static const char *amf_hevc_get_name(void *)
static inline int get_hevc_preset(amf_base *enc, const char *preset)
{
+ UNUSED_PARAMETER(enc);
if (astrcmpi(preset, "balanced") == 0)
return AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED;
else if (astrcmpi(preset, "speed") == 0)
@@ -1657,8 +1707,8 @@ static bool amf_hevc_init(void *data, obs_data_t *settings)
info("settings:\n"
"\trate_control: %s\n"
- "\tbitrate: %d\n"
- "\tcqp: %d\n"
+ "\tbitrate: %" PRId64 "\n"
+ "\tcqp: %" PRId64 "\n"
"\tkeyint: %d\n"
"\tpreset: %s\n"
"\tprofile: %s\n"
@@ -1778,6 +1828,7 @@ static void amf_hevc_create_internal(amf_base *enc, obs_data_t *settings)
static void *amf_hevc_create_texencode(obs_data_t *settings,
obs_encoder_t *encoder)
+#ifdef _WIN32
try {
check_texture_encode_capability(encoder, amf_codec_type::HEVC);
@@ -1800,6 +1851,12 @@ try {
blog(LOG_ERROR, "[texture-amf-h265] %s: %s", __FUNCTION__, err);
return obs_encoder_create_rerouted(encoder, "h265_fallback_amf");
}
+#else
+{
+ UNUSED_PARAMETER(settings);
+ return obs_encoder_create_rerouted(encoder, "h265_fallback_amf");
+}
+#endif
static void *amf_hevc_create_fallback(obs_data_t *settings,
obs_encoder_t *encoder)
@@ -1888,6 +1945,7 @@ static const char *amf_av1_get_name(void *)
static inline int get_av1_preset(amf_base *enc, const char *preset)
{
+ UNUSED_PARAMETER(enc);
if (astrcmpi(preset, "highquality") == 0)
return AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY;
else if (astrcmpi(preset, "quality") == 0)
@@ -2026,8 +2084,8 @@ static bool amf_av1_init(void *data, obs_data_t *settings)
info("settings:\n"
"\trate_control: %s\n"
- "\tbitrate: %d\n"
- "\tcqp: %d\n"
+ "\tbitrate: %" PRId64 "\n"
+ "\tcqp: %" PRId64 "\n"
"\tkeyint: %d\n"
"\tpreset: %s\n"
"\tprofile: %s\n"
@@ -2094,6 +2152,7 @@ static void amf_av1_create_internal(amf_base *enc, obs_data_t *settings)
static void *amf_av1_create_texencode(obs_data_t *settings,
obs_encoder_t *encoder)
+#ifdef _WIN32
try {
check_texture_encode_capability(encoder, amf_codec_type::AV1);
@@ -2116,6 +2175,12 @@ try {
blog(LOG_ERROR, "[texture-amf-av1] %s: %s", __FUNCTION__, err);
return obs_encoder_create_rerouted(encoder, "av1_fallback_amf");
}
+#else
+{
+ UNUSED_PARAMETER(settings);
+ return obs_encoder_create_rerouted(encoder, "av1_fallback_amf");
+}
+#endif
static void *amf_av1_create_fallback(obs_data_t *settings,
obs_encoder_t *encoder)
@@ -2213,9 +2278,16 @@ static bool enum_luids(void *param, uint32_t idx, uint64_t luid)
return true;
}
+#ifdef _WIN32
+#define OBS_AMF_TEST "obs-amf-test.exe"
+#else
+#define OBS_AMF_TEST "obs-amf-test"
+#endif
+
extern "C" void amf_load(void)
try {
AMF_RESULT res;
+#ifdef _WIN32
HMODULE amf_module_test;
/* Check if the DLL is present before running the more expensive */
@@ -2225,18 +2297,26 @@ try {
if (!amf_module_test)
throw "No AMF library";
FreeLibrary(amf_module_test);
+#else
+ void *amf_module_test = os_dlopen(AMF_DLL_NAMEA);
+ if (!amf_module_test)
+ throw "No AMF library";
+ os_dlclose(amf_module_test);
+#endif
/* ----------------------------------- */
/* Check for supported codecs */
- BPtr<char> test_exe = os_get_executable_path_ptr("obs-amf-test.exe");
+ BPtr<char> test_exe = os_get_executable_path_ptr(OBS_AMF_TEST);
std::stringstream cmd;
std::string caps_str;
cmd << '"';
cmd << test_exe;
cmd << '"';
+#ifdef _WIN32
enum_graphics_device_luids(enum_luids, &cmd);
+#endif
os_process_pipe_t *pp = os_process_pipe_create(cmd.str().c_str(), "r");
if (!pp)
@@ -2296,12 +2376,12 @@ try {
/* ----------------------------------- */
/* Init AMF */
- amf_module = LoadLibraryW(AMF_DLL_NAME);
+ amf_module = os_dlopen(AMF_DLL_NAMEA);
if (!amf_module)
throw "AMF library failed to load";
AMFInit_Fn init =
- (AMFInit_Fn)GetProcAddress(amf_module, AMF_INIT_FUNCTION_NAME);
+ (AMFInit_Fn)os_dlsym(amf_module, AMF_INIT_FUNCTION_NAME);
if (!init)
throw "Failed to get AMFInit address";
@@ -2313,7 +2393,7 @@ try {
if (res != AMF_OK)
throw amf_error("GetTrace failed", res);
- AMFQueryVersion_Fn get_ver = (AMFQueryVersion_Fn)GetProcAddress(
+ AMFQueryVersion_Fn get_ver = (AMFQueryVersion_Fn)os_dlsym(
amf_module, AMF_QUERY_VERSION_FUNCTION_NAME);
if (!get_ver)
throw "Failed to get AMFQueryVersion address";
@@ -2352,7 +2432,7 @@ try {
} catch (const amf_error &err) {
/* doing an error here because it means at least the library has loaded
* successfully, so they probably have AMD at this point */
- blog(LOG_ERROR, "%s: %s: 0x%lX", __FUNCTION__, err.str,
+ blog(LOG_ERROR, "%s: %s: 0x%uX", __FUNCTION__, err.str,
(uint32_t)err.res);
}

View File

@ -1,44 +0,0 @@
{ stdenv
, fetchFromGitHub
, wayland
, wayland-protocols
, xorg
, libva
, libdrm
, cmake
, pkg-config
}:
stdenv.mkDerivation rec {
pname = "onevpl";
version = "v2023.3.1";
src = fetchFromGitHub {
owner = "oneapi-src";
repo = "oneVPL";
rev = version;
hash = "sha256-kFW5n3uGTS+7ATKAuVff5fK3LwEKdCQVgGElgypmrG4=";
};
nativeBuildInputs = [
cmake
pkg-config
];
buildInputs = [
wayland
wayland-protocols
xorg.libxcb
xorg.libX11
xorg.libpciaccess
libva
libdrm
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DENABLE_DRI3=ON"
"-DENABLE_DRM=ON"
"-DENABLE_VA=ON"
"-DENABLE_WAYLAND=ON"
"-DENABLE_X11=ON"
];
}

View File

@ -1,27 +0,0 @@
{ lib
, stdenv
, qrcodegen
}:
stdenv.mkDerivation (finalAttrs: {
pname = "qrcodegencpp";
version = qrcodegen.version;
src = qrcodegen.src;
sourceRoot = "${finalAttrs.src.name}/cpp";
nativeBuildInputs = lib.optionals stdenv.cc.isClang [
stdenv.cc.cc.libllvm.out
];
makeFlags = lib.optionals stdenv.cc.isClang [ "AR=llvm-ar" ];
installPhase = ''
runHook preInstall
install -Dt $out/lib/ libqrcodegencpp.a
install -Dt $out/include/qrcodegen/ qrcodegen.hpp
runHook postInstall
'';
})

View File

@ -9,17 +9,7 @@ rec {
}; };
ffmpeg6-amf-full = (if pkgs.lib.versionOlder pkgs.ffmpeg-full.version "6.1" then ffmpeg_7-amf-full = (pkgs.ffmpeg_7-full.overrideAttrs (finalAttrs: previousAttrs: { configureFlags = previousAttrs.configureFlags ++ [ "--enable-amf" ]; buildInputs = previousAttrs.buildInputs ++ [ pkgs.amf-headers ]; }));
pkgs.callPackage ./apps/ffmpeg
{
inherit (pkgs.darwin.apple_sdk.frameworks)
Cocoa CoreServices CoreAudio CoreMedia AVFoundation MediaToolbox
VideoDecodeAcceleration VideoToolbox;
} else
(pkgs.ffmpeg-full.overrideAttrs (finalAttrs: previousAttrs: { configureFlags = previousAttrs.configureFlags ++ [ "--enable-amf" ]; buildInputs = previousAttrs.buildInputs ++ [ pkgs.amf-headers ]; }))
);
obs-amf = pkgs.qt6Packages.callPackage ./apps/obs { ffmpeg = ffmpeg6-amf-full; inherit libcef; };
polymc = pkgs.qt6Packages.callPackage ./apps/games/polymc { }; polymc = pkgs.qt6Packages.callPackage ./apps/games/polymc { };
polymc-qt5 = pkgs.libsForQt5.callPackage ./apps/games/polymc { }; polymc-qt5 = pkgs.libsForQt5.callPackage ./apps/games/polymc { };
@ -30,9 +20,5 @@ rec {
fbset = callPackage ./apps/fbset.nix { }; fbset = callPackage ./apps/fbset.nix { };
libcef = callPackage ./libs/libcef.nix { };
lh2ctrl = callPackage ./apps/lh2ctrl.nix { }; lh2ctrl = callPackage ./apps/lh2ctrl.nix { };
emacs-materus = (pkgs.emacs29.override { withSQLite3 = true; withWebP = true; withX = true; withGTK3 = true; withAlsaLib = true; withGconf = true; withImageMagick = true; withXwidgets = true; });
} }

View File

@ -1,130 +0,0 @@
{ lib
, stdenv
, fetchurl
, cmake
, glib
, nss
, nspr
, atk
, at-spi2-atk
, libdrm
, expat
, mesa
, gtk3
, pango
, cairo
, alsa-lib
, dbus
, at-spi2-core
, cups
, libcef
, libxkbcommon
, xorg
, zlib
, openssl
, wayland
, systemd
, pkgs
}:
let
vk_rpath = lib.makeLibraryPath [
stdenv.cc.cc.lib
xorg.libX11
];
gl_rpath = lib.makeLibraryPath [
stdenv.cc.cc.lib
];
rpath = lib.makeLibraryPath [
glib
nss
nspr
atk
at-spi2-atk
libdrm
expat
xorg.libxcb
libxkbcommon
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
mesa
gtk3
pango
cairo
alsa-lib
dbus
at-spi2-core
cups
xorg.libxshmfence
];
platforms = {
"aarch64-linux" = {
platformStr = "linuxarm64";
projectArch = "arm64";
};
"x86_64-linux" = {
platformStr = "linux64";
projectArch = "x86_64";
};
};
platforms."aarch64-linux".sha256 = "0c034h0hcsff4qmibizjn2ik5pq1jb4p6f0a4k6nrkank9m0x7ap";
platforms."x86_64-linux".sha256 = "02pj4dgfswpaglxkmbd9970znixlv82wna4xxhwjh7i5ps24a0n6";
platformInfo = builtins.getAttr stdenv.targetPlatform.system platforms;
in
stdenv.mkDerivation rec {
pname = "cef-binary";
version = pkgs.libcef.version;
src = pkgs.libcef.src;
nativeBuildInputs = [ cmake ];
cmakeFlags = [ "-DPROJECT_ARCH=${platformInfo.projectArch}" ];
makeFlags = [ "libcef_dll_wrapper" ];
dontStrip = true;
dontPatchELF = true;
installPhase = ''
mkdir -p $out/lib/ $out/share/cef/ $out/bin/
cp -r ../Release $out/share/cef/
cp -r ../Resources $out/share/cef/
cp -r ../include $out/share/cef/
cp -r libcef_dll_wrapper $out/share/cef/
patchelf --set-rpath "$out/share/cef/Release/:${rpath}" $out/share/cef/Release/libcef.so
patchelf --set-rpath "$out/share/cef/Release/:${gl_rpath}" $out/share/cef/Release/libEGL.so
patchelf --set-rpath "$out/share/cef/Release/:${gl_rpath}" $out/share/cef/Release/libGLESv2.so
patchelf --set-rpath "$out/share/cef/Release/:${vk_rpath}" $out/share/cef/Release/libvulkan.so.1
patchelf --set-rpath "$out/share/cef/Release/:${vk_rpath}" $out/share/cef/Release/libvk_swiftshader.so
patchelf --set-rpath "$out/share/cef/Release/:${vk_rpath}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/share/cef/Release/chrome-sandbox
ln -s $out/share/cef/Release/chrome-sandbox $out/bin
ln -s $out/share/cef/Release/libcef.so $out/lib
ln -s $out/share/cef/libcef_dll_wrapper/libcef_dll_wrapper.a $out/lib/
ln -s $out/share/cef/include $out/
sed -i "s#./libvk_swiftshader.so#$out/share/cef/Release/libvk_swiftshader.so#" $out/share/cef/Release/vk_swiftshader_icd.json
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "Simple framework for embedding Chromium-based browsers in other applications";
homepage = "https://cef-builds.spotifycdn.com/index.html";
maintainers = with maintainers; [];
sourceProvenance = with sourceTypes; [
fromSource
binaryNativeCode
];
license = licenses.bsd3;
platforms = [ "x86_64-linux" "aarch64-linux" ];
};
}