DeckLink output --enable-decklink

Website, builds, or other suggestions.
iotzo
Posts: 35
Joined: Thu Jan 24, 2013 4:49 pm

DeckLink output --enable-decklink

Post by iotzo » Mon Feb 17, 2014 9:35 am

Hi!
I noticed these days decklink output support in ffmpeg git(Linux AND Windows)
http://git.videolan.org/?p=ffmpeg.git;a ... e1d2483764
, but it requires DeckLink SDK to compile and some widl magic(i suppose for .idl to .h and .dll conversion ) i don't know how to apply
http://www.ffmpeg.org/ffmpeg-all.html#decklink
To enable this output device, you need the Blackmagic DeckLink SDK and you need to configure with the appropriate --extra-cflags and --extra-ldflags. On Windows, you need to run the IDL files through widl.
It would be nice to have decklink output device support in Windows ffmpeg build.
Thanks!

JaySloat
Posts: 1
Joined: Tue Aug 05, 2014 6:00 am

Re: DeckLink output --enable-decklink

Post by JaySloat » Tue Aug 05, 2014 6:15 am

I also need to get FFmpeg or FFPlay to output to a DeckLink card but am not having luck following the extremely terse
DeckLink command docs. I'm wondering if you found a solution.

Looks like my recently downloaded static 64bit Windows version of FFMpeg has been compiled with the DeckLink option.
I have downloaded the newest BlackMagic SDK for the card, but I am not having any success with finding a "WIDL" tool to somehow process IDL files. It's not clear if I might need try and rebuild FFMpeg with different configurations or if there is some auxillary mechanism to enable DeckLink.

All I know is that when I attempt to follow the directions and get a listing of decklink -list_devices 1 dummy,
FFMpeg dies.


DeckLink output --enable-decklink

Is the above statement required ? Each time ? or is it some build option?


"To enable this output device, you need the Blackmagic DeckLink SDK and you need to configure with the appropriate --extra-cflags and --extra-ldflags. On Windows, you need to run the IDL files through widl."

Hopefully someone who has done this can enlighten me.

-Jay-

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DeckLink output --enable-decklink

Post by rogerdpack » Thu Aug 07, 2014 10:08 pm

I will ping Ramiro on it...

iotzo
Posts: 35
Joined: Thu Jan 24, 2013 4:49 pm

Re: DeckLink output --enable-decklink

Post by iotzo » Thu Oct 16, 2014 1:13 pm

Hi,
I've managed to build windows binary with decklink support:
https://drive.google.com/file/d/0By6-Py ... view?pli=1
This version is fixed to 1080i50 output mode only!

mark1st
Posts: 4
Joined: Wed Nov 12, 2014 6:32 pm

Re: DeckLink output --enable-decklink

Post by mark1st » Wed Nov 12, 2014 6:47 pm

Hi. I'm stuck in trying to build ffmpeg binary with --enable-decklink option... :oops:
Did someone manage to build ffmpeg (current git version) with decklink support?
I'm totally lost... :oops:

best regards,
mark

iotzo
Posts: 35
Joined: Thu Jan 24, 2013 4:49 pm

Re: DeckLink output --enable-decklink

Post by iotzo » Thu Nov 20, 2014 3:57 pm

mark1st wrote:Hi. I'm stuck in trying to build ffmpeg binary with --enable-decklink option... :oops:
Did someone manage to build ffmpeg (current git version) with decklink support?
I'm totally lost... :oops:

best regards,
mark
Hi Mark,
To build windows ffmpeg binary with decklink support you may want to get the latest Decklink SDK:
http://software.blackmagicdesign.com/SD ... 10.3.1.zip
Extract the archive for example to "D:\Blackmagic_DeckLink_SDK_10.3.1\Win\include", then use midl(Microsoft Interface Definition Language) compiler from Visual Studio to generate DeckLinkAPI.h file from DeckLinkAPI.idl like this:

Code: Select all

D:\Blackmagic_DeckLink_SDK_10.3.1\Win\include>midl /h DeckLinkAPI.h DeckLinkAPI.idl
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
64 bit Processing .\DeckLinkAPI.idl
DeckLinkAPI.idl
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.idl
unknwn.idl
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wtypes.idl
wtypes.idl
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\basetsd.h
basetsd.h
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\guiddef.h
guiddef.h
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.idl
oaidl.idl
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.idl
objidl.idl
64 bit Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.acf
oaidl.acf

D:\Blackmagic_DeckLink_SDK_10.3.1\Win\include>
You also may want to use this nice script - media-autobuild_suite-master(with little modifications - see the attachment) to build ffmpeg:
https://github.com/jb-alvarado/media-autobuild_suite
Download the .zip archive and extract it for example in "D:\media-autobuild_suite-master"
Now you may want to edit the attached/modified compile_localtools.sh file to replace extra-cflags include path with location of your Decklink SDK(line 1574 in compile_localtools.sh).
You may notice a little decklink_common.cpp patching incorporated in compile_localtools.sh - lines 1577 and 1578:

Code: Select all

sed -i "s/static char \*dup_wchar_to_utf8/extern char \*dup_wchar_to_utf8/g" libavdevice/decklink_common.cpp
sed -i "s/free((void \*) tmpDisplayName)\;//g" libavdevice/decklink_common.cpp
Replace original compile_localtools.sh with the modified version and run media-autobuild_suite.bat.
Select 64bit building environment and 64bit builds(the modified compile_localtools.sh reflects only 64bit ffmpeg build) when you prompted.
After some(about 15min.) time you should get mingw-w64 building environment and ffmpeg.exe in "build64\ffmpeg-git" subfolder.
That's it! Good luck!
Attachments
SDK_10.3.1_win_include.zip
win_include files after midl command
(111.49 KiB) Downloaded 368 times
DeckLinkAPI.zip
DeckLinkAPI.h header file, generated from .idl file with midl.exe(DeckLink_SDK_10.3.1 ).
Must go in "D:\Blackmagic_DeckLink_SDK_10.3.1\Win\include" for example.
(38.35 KiB) Downloaded 467 times
compile_localtools.zip
Modified version with decklink support
(10.4 KiB) Downloaded 485 times
Last edited by iotzo on Wed Nov 26, 2014 8:12 am, edited 1 time in total.

mark1st
Posts: 4
Joined: Wed Nov 12, 2014 6:32 pm

Re: DeckLink output --enable-decklink

Post by mark1st » Thu Nov 20, 2014 4:32 pm

Thank you very much!
8-)
mark

User avatar
Zeranoe
Site Admin
Posts: 703
Joined: Sat May 07, 2011 7:12 pm
Contact:

Re: DeckLink output --enable-decklink

Post by Zeranoe » Tue Nov 25, 2014 5:27 pm

DeckLink support is now included in the builds.

iotzo
Posts: 35
Joined: Thu Jan 24, 2013 4:49 pm

Re: DeckLink output --enable-decklink

Post by iotzo » Tue Nov 25, 2014 7:44 pm

Zeranoe wrote:DeckLink support is now included in the builds.
Thank You! :P
I have Decklink Intensity Pro and I just tested the new build, but it crashes with the following error(when debugged with MS debugger):

Code: Select all

Unhandled exception at 0x0000000076FA4102 (ntdll.dll) in ffmpeg_decklink_zeranoe.exe: 0xC0000374: A heap has been corrupted (parameters: 0x000000007701B4B0).
Further investigation of debugger output suggest that there is something wrong with the free() call in libavdevice/decklink_common.cpp(on line 85: "free((void *) tmpDisplayName);"):

Code: Select all

	ntdll.dll!RtlReportCriticalFailure()	Unknown
 	ntdll.dll!RtlpReportHeapFailure()	Unknown
 	ntdll.dll!RtlpHeapHandleError()	Unknown
 	ntdll.dll!RtlpLogHeapFailure()	Unknown
 	ntdll.dll!string "Enabling heap debug options\n"()	Unknown
 	AcXtrnal.dll!NS_FaultTolerantHeap::APIHook_RtlFreeHeap(void *,unsigned long,void *)	Unknown
 	msvcrt.dll!free()	Unknown
 	ffmpeg_decklink_zeranoe.exe!000000000042840f()	Unknown
 	ffmpeg_decklink_zeranoe.exe!00000000019dfe92()	Unknown
 	ffmpeg_decklink_zeranoe.exe!00000000004d8249()	Unknown
 	ffmpeg_decklink_zeranoe.exe!000000000041e718()	Unknown
 	ffmpeg_decklink_zeranoe.exe!00000000019de28f()	Unknown
 	ffmpeg_decklink_zeranoe.exe!00000000004013e8()	Unknown
 	ffmpeg_decklink_zeranoe.exe!000000000040151b()	Unknown
 	[External Code]	
If I remove or comment out line 85 to skip call of free() function and recompile ffmpeg, then it seems to work, as I mentioned in my previous post/attachment.
So the quick and dirty fix to get working ffmpeg windows binary with decklink support which does not causes heap corruption crash/error is to comment out the free() call (libavdevice/decklink_common.cpp line 85).
Sadly i can not post on ffmpeg-devel:(

ramiro
Posts: 157
Joined: Tue May 10, 2011 12:56 am

Re: DeckLink output --enable-decklink

Post by ramiro » Wed Nov 26, 2014 10:59 pm

Could you please test this (untested) patch:

Code: Select all

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 9a9e44b..4e98c41 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -69,9 +69,11 @@ static char *dup_wchar_to_utf8(wchar_t *w)
 }
 #define DECKLINK_STR    OLECHAR *
 #define DECKLINK_STRDUP dup_wchar_to_utf8
+#define DECKLINK_FREE   SysFreeString
 #else
 #define DECKLINK_STR    const char *
 #define DECKLINK_STRDUP av_strdup
+#define DECKLINK_FREE   free
 #endif
 
 HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName)
@@ -82,7 +84,7 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName)
         return hr;
     *displayName = DECKLINK_STRDUP(tmpDisplayName);
     /* free() is needed for a string returned by the DeckLink SDL. */
-    free((void *) tmpDisplayName);
+    DECKLINK_FREE((void *) tmpDisplayName);
     return hr;
 }
 

Post Reply
'