浏览代码

Updated cmake files for ffmpeg plugin

Also, fixed an enum name issue.  No clue why visual
studio actually compiled that without warnings/errors
jp9000 11 年之前
父节点
当前提交
590a486343

+ 40 - 0
cmake/Modules/FindLibswscale.cmake

@@ -0,0 +1,40 @@
+# Once done these will be defined:
+#
+#  Libswscale_FOUND
+#  Libswscale_INCLUDE_DIR
+#  Libswscale_LIBRARIES
+#
+
+if(Libswscale_INCLUDE_DIR AND Libswscale_LIBRARIES)
+	set(Libswscale_FOUND TRUE)
+else()
+	find_package(PkgConfig QUIET)
+	if (PKG_CONFIG_FOUND)
+		pkg_check_modules(_SWSCALE QUIET libswscale)
+	endif()
+
+	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+		set(_lib_suffix 64)
+	else()
+		set(_lib_suffix 32)
+	endif()
+	
+	find_path(FFMPEG_INCLUDE_DIR
+		NAMES libswscale/swscale.h
+		HINTS
+			ENV FFmpegPath
+			${_SWSCALE_INCLUDE_DIRS}
+			/usr/include /usr/local/include /opt/local/include /sw/include
+		PATH_SUFFIXES ffmpeg libav)
+
+	find_library(SWSCALE_LIB
+		NAMES swscale
+		HINTS ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} ${_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
+
+	set(Libswscale_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libswscale include dir")
+	set(Libswscale_LIBRARIES ${SWSCALE_LIB} CACHE STRING "Libswscale libraries")
+
+	find_package_handle_standard_args(Libswscale DEFAULT_MSG SWSCALE_LIB FFMPEG_INCLUDE_DIR)
+	mark_as_advanced(FFMPEG_INCLUDE_DIR SWSCALE_LIB)
+endif()
+

+ 1 - 1
plugins/CMakeLists.txt

@@ -4,5 +4,5 @@ if(WIN32)
 	add_subdirectory(dshow)
 	add_subdirectory(dshow)
 endif()
 endif()
 
 
-#add_subdirectory(obs-ffmpeg)
+add_subdirectory(obs-ffmpeg)
 add_subdirectory(obs-outputs)
 add_subdirectory(obs-outputs)

+ 12 - 0
plugins/obs-ffmpeg/CMakeLists.txt

@@ -1,5 +1,13 @@
 project(obs-ffmpeg)
 project(obs-ffmpeg)
 
 
+find_package(Libavcodec REQUIRED)
+include_directories(${Libavcodec_INCLUDE_DIR})
+add_definitions(${Libavcodec_DEFINITIONS})
+
+find_package(Libswscale REQUIRED)
+include_directories(${Libswscale_INCLUDE_DIR})
+add_definitions(${Libswscale_DEFINITIONS})
+
 find_package(Libavformat REQUIRED)
 find_package(Libavformat REQUIRED)
 include_directories(${Libavformat_INCLUDE_DIR})
 include_directories(${Libavformat_INCLUDE_DIR})
 add_definitions(${Libavformat_DEFINITIONS})
 add_definitions(${Libavformat_DEFINITIONS})
@@ -20,10 +28,14 @@ add_library(obs-ffmpeg MODULE
 	${obs-ffmpeg_HEADERS})
 	${obs-ffmpeg_HEADERS})
 target_link_libraries(obs-ffmpeg
 target_link_libraries(obs-ffmpeg
 	libobs
 	libobs
+	${Libavcodec_LIBRARIES}
+	${Libswscale_LIBRARIES}
 	${Libavformat_LIBRARIES}
 	${Libavformat_LIBRARIES}
 	${Libswresample_LIBRARIES})
 	${Libswresample_LIBRARIES})
 
 
 install_obs_plugin(obs-ffmpeg)
 install_obs_plugin(obs-ffmpeg)
 
 
+obs_fixup_install_target(obs-ffmpeg PATH ${Libavcodec_LIBRARIES})
+obs_fixup_install_target(obs-ffmpeg PATH ${Libswscale_LIBRARIES})
 obs_fixup_install_target(obs-ffmpeg PATH ${Libavformat_LIBRARIES})
 obs_fixup_install_target(obs-ffmpeg PATH ${Libavformat_LIBRARIES})
 obs_fixup_install_target(obs-ffmpeg PATH ${Libswresample_LIBRARIES})
 obs_fixup_install_target(obs-ffmpeg PATH ${Libswresample_LIBRARIES})

+ 1 - 1
plugins/obs-ffmpeg/obs-ffmpeg-output.c

@@ -44,7 +44,7 @@ static inline enum AVPixelFormat obs_to_ffmpeg_video_format(
 }
 }
 
 
 static bool new_stream(struct ffmpeg_data *data, AVStream **stream,
 static bool new_stream(struct ffmpeg_data *data, AVStream **stream,
-		AVCodec **codec, enum AVCoecID id)
+		AVCodec **codec, enum AVCodecID id)
 {
 {
 	*codec = avcodec_find_encoder(id);
 	*codec = avcodec_find_encoder(id);
 	if (!*codec) {
 	if (!*codec) {