Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ These options can be specified during CMake configuration. For example:
cmake -DBUILD_DECODER=ON -DBUILD_ENCODER=OFF -DBUILD_VIDEO_PARSER=ON ...
```

### FFmpeg Location

If FFmpeg is installed in a non-standard location, set `FFMPEG_ROOT` to its
install prefix (as a CMake variable or an environment variable).

## Building On Windows

### Windows Build Requirements
Expand Down
91 changes: 18 additions & 73 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,85 +59,30 @@ if(BUILD_DECODER OR USE_ENCODER_SHADERC)
include(FindShaderc)
endif()

############ VULKAN_FFMPEG_LIB_PATH ######################################
if (DEFINED ENV{VULKAN_FFMPEG_LIB_DIR_PATH})
MESSAGE(STATUS "VULKAN_FFMPEG_LIB_DIR_PATH ENV VAR is set to $ENV{VULKAN_FFMPEG_LIB_DIR_PATH}")
set(VULKAN_FFMPEG_LIB_PATH "$ENV{VULKAN_FFMPEG_LIB_DIR_PATH}" CACHE PATH "Path to FFMPEG library directory" FORCE)
else()
set(VULKAN_FFMPEG_LIB_PATH "${VULKAN_FFMPEG_LIB_PATH}" CACHE PATH "Path to FFMPEG library directory")
endif()

if (EXISTS "${VULKAN_FFMPEG_LIB_PATH}")
MESSAGE(STATUS "VULKAN_FFMPEG_LIB_PATH is set and valid ${VULKAN_FFMPEG_LIB_PATH}")
else()
if(WIN32)
if ((CMAKE_GENERATOR_PLATFORM MATCHES "^aarch64") OR (CMAKE_GENERATOR_PLATFORM MATCHES "^arm64") OR (CMAKE_GENERATOR_PLATFORM MATCHES "^ARM64"))
set(VULKAN_FFMPEG_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/winarm64/lib" CACHE PATH "Path to FFMPEG libs directory" FORCE)
message(STATUS "FFMPEG Windows ARM64 lib location ${VULKAN_FFMPEG_LIB_PATH}")
set(FFMPEG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/winarm64/include" CACHE PATH "Path to FFMPEG include directory" FORCE)
message(STATUS "FFMPEG Windows ARM64 include location ${FFMPEG_INCLUDE_DIR}")
elseif ((CMAKE_GENERATOR_PLATFORM MATCHES "^arm") OR (CMAKE_GENERATOR_PLATFORM MATCHES "^ARM"))
set(VULKAN_FFMPEG_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/winarm/lib" CACHE PATH "Path to FFMPEG libs directory" FORCE)
message(STATUS "FFMPEG Windows ARM64 lib location ${VULKAN_FFMPEG_LIB_PATH}")
set(FFMPEG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/winarm/include" CACHE PATH "Path to FFMPEG include directory" FORCE)
message(STATUS "FFMPEG Windows ARM64 include location ${FFMPEG_INCLUDE_DIR}")
else()
set(VULKAN_FFMPEG_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/win64/lib" CACHE PATH "Path to FFMPEG libs directory" FORCE)
message(STATUS "FFMPEG Windows x86_64 lib location ${VULKAN_FFMPEG_LIB_PATH}")
set(FFMPEG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vk_video_decoder/bin/libs/ffmpeg/win64/include" CACHE PATH "Path to FFMPEG include directory" FORCE)
message(STATUS "FFMPEG Windows x86_64 include location ${FFMPEG_INCLUDE_DIR}")
endif()
else()
message( STATUS "The location of the FFMPEG Lib: ${VULKAN_FFMPEG_LIB_PATH} expected the library to be installed to the regular system libs location" )
endif()
endif()
############ VULKAN_FFMPEG_LIB_PATH ######################################

# find_package(FFmpeg REQUIRED)
include(FindFFmpeg)
find_package(FFmpeg)
set(FFMPEG_AVAILABLE OFF)

# FFMPEG_FOUND - system has ffmpeg or libav
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
# FFMPEG_LIBRARIES
# FFMPEG_LIBAVCODEC
# FFMPEG_LIBAVFORMAT
# FFMPEG_LIBAVUTIL
if(FFMPEG_FOUND)
message("Found FFMPEG/LibAV libraries")
include_directories(${FFMPEG_INCLUDE_DIR})
message(STATUS " libavcodec: ${FFMPEG_LIBAVCODEC_LIBRARIES}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use FFMPEG_LIBAVCODEC_LIBRARy

message(STATUS " libavformat: ${FFMPEG_LIBAVFORMAT_LIBRARIES}")
message(STATUS " libavutil: ${FFMPEG_LIBAVUTIL_LIBRARIES}")
include_directories(${FFMPEG_INCLUDE_DIRS})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is project wide maybe better to have it at target level with:

target_include_directories

set(FFMPEG_AVAILABLE ON)
else()

# Install Windows FFmpeg DLLs and libs
if(WIN32)
find_library(AVCODEC_LIB NAMES avcodec PATHS ${VULKAN_FFMPEG_LIB_PATH})
message(STATUS ${AVCODEC_LIB})
find_library(AVFORMAT_LIB NAMES avformat PATHS ${VULKAN_FFMPEG_LIB_PATH})
message(STATUS ${AVFORMAT_LIB})
find_library(AVUTIL_LIB NAMES avutil PATHS ${VULKAN_FFMPEG_LIB_PATH})
message(STATUS ${AVUTIL_LIB})

if(AVCODEC_LIB AND AVFORMAT_LIB AND AVUTIL_LIB)
message(STATUS "Found FFMPEG libraries manually")
set(FFMPEG_AVAILABLE ON)
include_directories(${FFMPEG_INCLUDE_DIR})

install(DIRECTORY "${VULKAN_FFMPEG_LIB_PATH}/../bin/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
PATTERN "*.def" EXCLUDE
PATTERN "*.a" EXCLUDE)

install(DIRECTORY "${VULKAN_FFMPEG_LIB_PATH}/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
else()
message(WARNING "Can't find libavcodec, libavformat, or libavutil on Windows!")
endif()
else()
message(WARNING "Can't find libavcodec, libavformat, or libavutil on Linux!")
get_filename_component(FFMPEG_BIN_DIR "${FFMPEG_LIB_DIR}/../bin" ABSOLUTE)
Comment thread
crmurillo marked this conversation as resolved.
install(DIRECTORY "${FFMPEG_BIN_DIR}/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
PATTERN "*.def" EXCLUDE
PATTERN "*.a" EXCLUDE)

install(DIRECTORY "${FFMPEG_LIB_DIR}/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
endif()
endif()

if (NOT FFMPEG_AVAILABLE)
message(WARNING "FFMPEG demuxing is not going to be supported.")
else()
message(WARNING "Can't find libavcodec, libavformat, or libavutil!\n"
"FFMPEG demuxing is not going to be supported.")
endif()

# Platform specific settings
Expand Down
Loading
Loading