Skip to content

Instantly share code, notes, and snippets.

@RomainKurtz
Created August 9, 2018 14:54
Show Gist options
  • Save RomainKurtz/87f4eec6fac1e8408bfc09414ba1272a to your computer and use it in GitHub Desktop.
Save RomainKurtz/87f4eec6fac1e8408bfc09414ba1272a to your computer and use it in GitHub Desktop.
I was able to find a VERY QUICK AND DIRTY way to use the media-autobuild suite to compile my own 64-bit static FFmpeg for Windows with the NDI library.
Download it and extract to a place on your computer, and keep note of the path. I put it in "D:\ndi\media-autobuild_suite-master", so for the sake of these instructions when you see "<autobuild>", you need to substitute whatever path you've put it in.
During the initial setup process, request to use the static build and add whatever else you'd like to have in your ffmpeg, then pause what you're doing when the on-screen prompts tell you the ffmpeg_options file has been written, then go into <autobuild>\build\ffmpeg_options.txt and add somewhere a line with
Code:
--enable-libndi_newtek
Then, go to <autobuild>\build\media_suite_compile.sh and search for this line of code
Code:
do_print_progress "Compiling ${bold}static${reset} FFmpeg"
Then look down a few lines for...
Code:
CFLAGS="${ffmpeg_cflags:-$CFLAGS}" \
LDFLAGS+=" -L$LOCALDESTDIR/lib -L$MINGW_PREFIX/lib" \
and change it to look like...
Code:
CFLAGS="${ffmpeg_cflags:-$CFLAGS} -I/C/Progra~1/NewTek/NewTek~2/Include" \
LDFLAGS+=" -L$LOCALDESTDIR/lib -L$MINGW_PREFIX/lib -L/C/Progra~1/NewTek/NewTek~2/Include" \
The path seen there should be equivalent to C:\Program Files\NewTek\NewTek NDI SDK\Include. Note the use of windows short paths, you may need to change the ~1 or ~2 depending on your system. (I didn't want to try to figure out how to escape spaces in this shell script - backslash didn't work for me)
You will also need to copy the library file from C:\Program Files\NewTek\NewTek NDI SDK\Lib\x64\Processing.NDI.Lib.x64.lib to "<autobuild>\msys64\mingw64\lib\ndi.lib". Notice the file has been renamed.
Just run the script and wait a long time, it should succeed. If it fails it's probably not due to something NDI related. When it finishes, the compiled binaries are in local64\bin-video.
Running the program searching NDI sources gives a successful response ...
Code:
C:\ndi>ffmpeg.exe -f libndi_newtek -find_sources 1 -i dummy
NewTek NDI Copyright (C)2015-2017 NewTek, inc. v3.0.0.12
ffmpeg version N-91181-gcba167934b Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev2, Built by MSYS2 project)
configuration: --disable-debug --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid --enable-libaom --enable-libndi_newtek --enable-chromaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug --enable-libopenh264 --enable-libopenmpt --enable-librtmp --enable-librubberband --enable-libtesseract --enable-libxavs --enable-libzmq --enable-libzvbi --enable-opencl --enable-opengl --enable-libvmaf --enable-libcodec2 --enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-libs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cflags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB --enable-version3 --enable-nonfree
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.104 / 58. 19.104
libavformat 58. 17.100 / 58. 17.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
[libndi_newtek @ 000002d747f88040] Found 8 NDI sources:
[libndi_newtek @ 000002d747f88040] 'SYSTEM (CY3014 USB, Analog 01 Capture)' '192.168.0.103:5963'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (CY3014 USB, Analog 02 Capture)' '192.168.0.103:5965'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (CY3014 USB, Analog 03 Capture)' '192.168.0.103:5962'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (DeckLink Duo (1) 2)' '192.168.0.103:5964'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (DeckLink Duo (2) 3)' '192.168.0.103:5966'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (DeckLink Duo (3) 4)' '192.168.0.103:5967'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (DeckLink Duo (4) 5)' '192.168.0.103:5968'
[libndi_newtek @ 000002d747f88040] 'SYSTEM (vMix - Output 2)' '192.168.0.103:5961'
dummy: Immediate exit requested
C:\ndi>
I can successfully pull an NDI stream and push out to an RTMP server, for example...
Code:
C:\ndi>ffmpeg -f libndi_newtek -i "SYSTEM (vMix - Output 2)" -f flv -c:v libx264 -pix_fmt yuv420p -b:v 1.5M -r 29.97 -s 1280x720 -preset:v ultrafast -tune fastdecode -g 30 -t 02:00:00 -c:a aac -ar 44100 "rtmp://192.168.0.7/publish/ndi_test live=1 flashVer=FMLE/3.0\20(compatible;\20FMSc/1.0)"
NewTek NDI Copyright (C)2015-2017 NewTek, inc. v3.0.0.12
ffmpeg version N-91181-gcba167934b Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev2, Built by MSYS2 project)
configuration: --disable-debug --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid --enable-libaom --enable-libndi_newtek --enable-chromaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug --enable-libopenh264 --enable-libopenmpt --enable-librtmp --enable-librubberband --enable-libtesseract --enable-libxavs --enable-libzmq --enable-libzvbi --enable-opencl --enable-opengl --enable-libvmaf --enable-libcodec2 --enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-libs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cflags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB --enable-version3 --enable-nonfree
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.104 / 58. 19.104
libavformat 58. 17.100 / 58. 17.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, libndi_newtek, from 'SYSTEM (vMix - Output 2)':
Duration: N/A, start: 66977.656683, bitrate: 1990203 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1988667 kb/s, 59.94 tbr, 10000k tbn
Stream mapping:
Stream #0:1 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 000001c55d50ea40] using SAR=1/1
[libx264 @ 000001c55d50ea40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001c55d50ea40] profile Constrained Baseline, level 3.1
[libx264 @ 000001c55d50ea40] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=30 keyint_min=3 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, flv, to 'rtmp://192.168.0.7/publish/ndi_test live=1 flashVer=FMLE/3.0\20(compatible;\20FMSc/1.0)':
Metadata:
encoder : Lavf58.17.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1500 kb/s, 29.97 fps, 1k tbn, 29.97 tbc
Metadata:
encoder : Lavc58.19.104 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.19.104 aac
frame= 1600 fps= 30 q=34.0 size= 11358kB time=00:00:56.26 bitrate=1653.7kbits/s dup=0 drop=1594 speed=1.06x
For those who want to play with the build I made, you can download it by clicking here.
@mutant-industries
Copy link

You can also find detailed how-to on building FFmpeg with NewTek NDI I/O support here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment