--- external/ffmpeg/CMakeLists.txt.orig	2026-10-31 16:02:03 UTC
+++ external/ffmpeg/CMakeLists.txt
@@ -3,7 +3,18 @@ add_library(${FFMPEG_CORE_NAME} INTERFACE)
 endif()
 
 add_library(${FFMPEG_CORE_NAME} INTERFACE)
+option(VITA3K_FORCE_SYSTEM_FFMPEG "Use the FFmpeg libraries installed on the system instead of the prebuilt binaries" OFF)
 
+if (VITA3K_FORCE_SYSTEM_FFMPEG)
+	# The bundled headers in include/ belong to the prebuilt binaries and would shadow
+	# the system ones, so they are not used in this mode.
+	find_package(PkgConfig REQUIRED)
+	pkg_check_modules(SYSTEM_FFMPEG REQUIRED IMPORTED_TARGET
+		libavformat libavcodec libswscale libavutil libavfilter libswresample)
+	target_link_libraries(${FFMPEG_CORE_NAME} INTERFACE PkgConfig::SYSTEM_FFMPEG)
+else ()
+
+
 target_include_directories(${FFMPEG_CORE_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
 
 # Detect OS
@@ -89,3 +100,4 @@ target_link_libraries(${FFMPEG_CORE_NAME} INTERFACE
 	"${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}avutil.${LIB_EXT}"
 	"${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}avfilter.${LIB_EXT}"
 	"${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}swresample.${LIB_EXT}")
+endif()
