Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Black Magic Design Decklink support to FFMPEG Preset #543

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
23 changes: 23 additions & 0 deletions ffmpeg/LICENSE.DeckLinkAPI
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2016 Blackmagic Design

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
7 changes: 7 additions & 0 deletions ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ENABLE="--enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable
# DISABLE="--disable-iconv --disable-libxcb --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-everything"
# ENABLE="--enable-shared --enable-runtime-cpudetect --enable-libopenh264 --enable-encoder=libopenh264 --enable-encoder=aac --enable-encoder=mjpeg --enable-decoder=h264 --enable-decoder=aac --enable-decoder=mjpeg --enable-parser=h264 --enable-parser=aac --enable-parser=mjpeg --enable-muxer=mp4 --enable-muxer=rtsp --enable-muxer=mjpeg --enable-demuxer=mov --enable-demuxer=rtsp --enable-demuxer=mjpeg --enable-protocol=file --enable-protocol=http --enable-protocol=rtp --enable-protocol=rtmp"

BLACK_MAGIC=10.9.11
NASM_VERSION=2.13.03
ZLIB=zlib-1.2.11
LAME=lame-3.100
Expand Down Expand Up @@ -875,6 +876,9 @@ case $PLATFORM in
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../ffmpeg-$FFMPEG_VERSION
cp -R $INSTALL_PATH/../../src/main/resources/decklink/windows/* $INSTALL_PATH/include
ENABLE="$ENABLE --enable-decklink"
patch -Np1 < ../../../decklink.patch
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic"
make -j $MAKEJ
make install
Expand Down Expand Up @@ -933,6 +937,9 @@ case $PLATFORM in
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../ffmpeg-$FFMPEG_VERSION
cp -R $INSTALL_PATH/../../src/main/resources/decklink/windows/* $INSTALL_PATH/include
ENABLE="$ENABLE --enable-decklink"
patch -Np1 < ../../../decklink.patch
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic"
make -j $MAKEJ
make install
Expand Down
61 changes: 61 additions & 0 deletions ffmpeg/decklink.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
unchanged:
--- ffmpeg-4.0/configure 2018-05-06 22:22:05.446265900 -0400
+++ ffmpeg-4.0/configure2 2018-05-06 22:22:27.712484600 -0400
@@ -3185,9 +3185,9 @@
caca_outdev_deps="libcaca"
decklink_deps_any="libdl LoadLibrary"
decklink_indev_deps="decklink threads"
-decklink_indev_extralibs="-lstdc++"
+decklink_indev_extralibs="-static-libstdc++"
decklink_outdev_deps="decklink threads"
-decklink_outdev_extralibs="-lstdc++"
+decklink_outdev_extralibs="-static-libstdc++"
libndi_newtek_indev_deps="libndi_newtek"
libndi_newtek_indev_extralibs="-lndi"
libndi_newtek_outdev_deps="libndi_newtek"
@@ -5953,8 +5953,7 @@
# these are off by default, so fail if requested and not available
enabled cuda_sdk && require cuda_sdk cuda.h cuCtxCreate -lcuda
enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
-enabled decklink && { require_header DeckLinkAPI.h &&
- { test_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } }
+enabled decklink && require_header DeckLinkAPI.h
enabled libndi_newtek && require_header Processing.NDI.Lib.h
enabled frei0r && require_header frei0r.h
enabled gmp && require gmp gmp.h mpz_export -lgmp
unchanged:
--- ffmpeg-4.0/libavdevice/decklink_common.h 2018-04-20 06:02:57.000000000 -0400
+++ ffmpeg-4.0/libavdevice/decklink_common2.h 2018-05-06 11:19:43.873596700 -0400
@@ -23,8 +23,6 @@
#ifndef AVDEVICE_DECKLINK_COMMON_H
#define AVDEVICE_DECKLINK_COMMON_H

-#include <DeckLinkAPIVersion.h>
-
#include "libavutil/thread.h"
#include "decklink_common_c.h"

@@ -110,11 +108,7 @@
typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;

#ifdef _WIN32
-#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
-typedef unsigned long buffercount_type;
-#else
typedef unsigned int buffercount_type;
-#endif
IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
#else
typedef uint32_t buffercount_type;
only in patch2:
unchanged:
--- ffmpeg-4.0/libavdevice/decklink_dec.cpp 2018-04-20 06:02:57.000000000 -0400
+++ ffmpeg-4.0/libavdevice/decklink_dec2.cpp 2018-05-06 11:23:41.688285100 -0400
@@ -707,6 +707,7 @@
"- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped);
}
no_video = 1;
+ pkt.flags |= AV_PKT_FLAG_DISCARD;
} else {
if (no_video) {
av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - Input returned "
17 changes: 17 additions & 0 deletions ffmpeg/src/main/resources/decklink/decklink.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Instructions on how to create headers for Windows:

https://github.com/jb-alvarado/media-autobuild_suite/wiki/Getting-Decklink-headers

Special thanks to Ricardo Constantino. 1) Download latest Desktop SDK from https://www.blackmagicdesign.com/support
2) Install pacman -S mingw-w64-{i686,x86_64}-tools-git dos2unix
** This is in addition to the normal packages.

=== Instructions for Compiling on Windows ===
https://github.com/jb-alvarado/media-autobuild_suite/wiki/Getting-Decklink-headers

cd <extracted sdk dir>/Win/include
widl -I/mingw64/x86_64-w64-mingw32/include -h -u DeckLinkAPI.idl
dos2unix DeckLinkAPI{,version}.h DecklinkAPI_i.c
Get license from DeckLinkAPI.idl and paste it to the beginning of each resulting file or to a separate LICENSE file
sed -n '2,24 s/^\*\*//p' DeckLinkAPI.idl > DeckLinkAPI.LICENSE
Copy DeckLinkAPI.h, DeckLinkAPIVersion.h and DeckLinkAPI_i.c to your /include dir or add their dir path to CFLAGS
Loading