Add dependency on libavdevice when building with ffmpeg support, register in ffmpeg_init

pull/2712/head
Cameron Tenny 1 year ago committed by nick black
parent fd4b2d9db7
commit 04470f9532

@ -107,6 +107,7 @@ set_package_properties(terminfo PROPERTIES TYPE REQUIRED)
set(PKGCONF_REQ_PRIV "${TERMINFO_LIBRARIES}") set(PKGCONF_REQ_PRIV "${TERMINFO_LIBRARIES}")
if(${USE_FFMPEG}) if(${USE_FFMPEG})
pkg_check_modules(AVCODEC REQUIRED libavcodec>=57.0) pkg_check_modules(AVCODEC REQUIRED libavcodec>=57.0)
pkg_check_modules(AVDEVICE REQUIRED libavdevice>=57.0)
pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0) pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0)
pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0) pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0)
pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0) pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0)
@ -362,6 +363,7 @@ if(${USE_FFMPEG})
target_include_directories(notcurses target_include_directories(notcurses
PRIVATE PRIVATE
"${AVCODEC_INCLUDE_DIRS}" "${AVCODEC_INCLUDE_DIRS}"
"${AVDEVICE_INCLUDE_DIRS}"
"${AVFORMAT_INCLUDE_DIRS}" "${AVFORMAT_INCLUDE_DIRS}"
"${AVUTIL_INCLUDE_DIRS}" "${AVUTIL_INCLUDE_DIRS}"
"${SWSCALE_INCLUDE_DIRS}" "${SWSCALE_INCLUDE_DIRS}"
@ -369,6 +371,7 @@ target_include_directories(notcurses
target_include_directories(notcurses-static target_include_directories(notcurses-static
PRIVATE PRIVATE
"${AVCODEC_STATIC_INCLUDE_DIRS}" "${AVCODEC_STATIC_INCLUDE_DIRS}"
"${AVDEVICE_STATIC_INCLUDE_DIRS}"
"${AVFORMAT_STATIC_INCLUDE_DIRS}" "${AVFORMAT_STATIC_INCLUDE_DIRS}"
"${AVUTIL_STATIC_INCLUDE_DIRS}" "${AVUTIL_STATIC_INCLUDE_DIRS}"
"${SWSCALE_STATIC_INCLUDE_DIRS}" "${SWSCALE_STATIC_INCLUDE_DIRS}"
@ -376,6 +379,7 @@ target_include_directories(notcurses-static
target_link_libraries(notcurses target_link_libraries(notcurses
PRIVATE PRIVATE
"${AVCODEC_LIBRARIES}" "${AVCODEC_LIBRARIES}"
"${AVDEVICE_LIBRARIES}"
"${AVFORMAT_LIBRARIES}" "${AVFORMAT_LIBRARIES}"
"${SWSCALE_LIBRARIES}" "${SWSCALE_LIBRARIES}"
"${AVUTIL_LIBRARIES}" "${AVUTIL_LIBRARIES}"
@ -383,6 +387,7 @@ target_link_libraries(notcurses
target_link_libraries(notcurses-static target_link_libraries(notcurses-static
PRIVATE PRIVATE
"${AVCODEC_STATIC_LIBRARIES}" "${AVCODEC_STATIC_LIBRARIES}"
"${AVDEVICE_STATIC_LIBRARIES}"
"${AVFORMAT_STATIC_LIBRARIES}" "${AVFORMAT_STATIC_LIBRARIES}"
"${SWSCALE_STATIC_LIBRARIES}" "${SWSCALE_STATIC_LIBRARIES}"
"${AVUTIL_STATIC_LIBRARIES}" "${AVUTIL_STATIC_LIBRARIES}"
@ -390,6 +395,7 @@ target_link_libraries(notcurses-static
target_link_directories(notcurses target_link_directories(notcurses
PRIVATE PRIVATE
"${AVCODEC_LIBRARY_DIRS}" "${AVCODEC_LIBRARY_DIRS}"
"${AVDEVICE_LIBRARY_DIRS}"
"${AVFORMAT_LIBRARY_DIRS}" "${AVFORMAT_LIBRARY_DIRS}"
"${SWSCALE_LIBRARY_DIRS}" "${SWSCALE_LIBRARY_DIRS}"
"${AVUTIL_LIBRARY_DIRS}" "${AVUTIL_LIBRARY_DIRS}"
@ -397,6 +403,7 @@ target_link_directories(notcurses
target_link_directories(notcurses-static target_link_directories(notcurses-static
PRIVATE PRIVATE
"${AVCODEC_STATIC_LIBRARY_DIRS}" "${AVCODEC_STATIC_LIBRARY_DIRS}"
"${AVDEVICE_STATIC_LIBRARY_DIRS}"
"${AVFORMAT_STATIC_LIBRARY_DIRS}" "${AVFORMAT_STATIC_LIBRARY_DIRS}"
"${SWSCALE_STATIC_LIBRARY_DIRS}" "${SWSCALE_STATIC_LIBRARY_DIRS}"
"${AVUTIL_STATIC_LIBRARY_DIRS}" "${AVUTIL_STATIC_LIBRARY_DIRS}"

@ -16,13 +16,13 @@ There are no submodules. Dependencies are fairly minimal.
Install build dependencies: Install build dependencies:
`apt-get install build-essential cmake doctest-dev libavformat-dev libavutil-dev libdeflate-dev libgpm-dev libncurses-dev libqrcodegen-dev libswscale-dev libunistring-dev pandoc pkg-config` `apt-get install build-essential cmake doctest-dev libavformat-dev libavdevice-dev libavutil-dev libdeflate-dev libgpm-dev libncurses-dev libqrcodegen-dev libswscale-dev libunistring-dev pandoc pkg-config`
If you only intend to build core Notcurses (without multimedia support), you If you only intend to build core Notcurses (without multimedia support), you can
can omit `libavformat-dev`, `libavutil-dev`, and `libswscale-dev` from this omit `libavformat-dev`, `libavdevice-dev`, `libavutil-dev`, and `libswscale-dev`
list. `zlib1g-dev` can be substituted for `libdeflate-dev`; build with from this list. `zlib1g-dev` can be substituted for `libdeflate-dev`; build with
`-DUSE_DEFLATE=off` in this case. If you don't want to generate QR codes, you can `-DUSE_DEFLATE=off` in this case. If you don't want to generate QR codes, you
omit 'libqrcodegen-dev'. can omit 'libqrcodegen-dev'.
If you want to build the Python wrappers, you'll also need: If you want to build the Python wrappers, you'll also need:

@ -9,6 +9,7 @@
#include <libavutil/rational.h> #include <libavutil/rational.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
#include <libswscale/version.h> #include <libswscale/version.h>
#include <libavdevice/avdevice.h>
#include <libavformat/version.h> #include <libavformat/version.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include "lib/visual-details.h" #include "lib/visual-details.h"
@ -691,17 +692,19 @@ ffmpeg_log_level(int level){
static int static int
ffmpeg_init(int logl){ ffmpeg_init(int logl){
av_log_set_level(ffmpeg_log_level(logl)); av_log_set_level(ffmpeg_log_level(logl));
avdevice_register_all();
// FIXME could also use av_log_set_callback() and capture the message... // FIXME could also use av_log_set_callback() and capture the message...
return 0; return 0;
} }
static void static void
ffmpeg_printbanner(fbuf* f){ ffmpeg_printbanner(fbuf* f){
fbuf_printf(f, "avformat %u.%u.%u avutil %u.%u.%u swscale %u.%u.%u avcodec %u.%u.%u" NL, fbuf_printf(f, "avformat %u.%u.%u avutil %u.%u.%u swscale %u.%u.%u avcodec %u.%u.%u avdevice %u.%u.%u" NL,
LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO, LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO,
LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO, LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO,
LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO, LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO,
LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO,
LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO);
} }
static void static void

Loading…
Cancel
Save