diff --git a/conda/ffmpeg/build.sh b/conda/ffmpeg/build.sh
index f6e8ad1b0dbf9253d4f7d552a1d410638eb63b24..78a474db4463f16f34323fcbe449d1e92a551ef7 100755
--- a/conda/ffmpeg/build.sh
+++ b/conda/ffmpeg/build.sh
@@ -5,22 +5,25 @@ unset SUBDIR
 
 ./configure \
         --prefix="${PREFIX}" \
+        --cc=${CC} \
         --disable-doc \
         --enable-shared \
-        --extra-cflags="-fPIC `pkg-config --cflags zlib`" \
-        --extra-cxxflags=="-fPIC" \
-        --extra-libs="`pkg-config --libs zlib`" \
+        --enable-static \
+        --enable-zlib \
         --enable-pic \
-        --disable-static \
-        --disable-gpl \
+        --enable-gpl \
+        --enable-version3 \
         --disable-nonfree \
+        --enable-hardcoded-tables \
+        --enable-avresample \
+        --enable-libfreetype \
         --disable-openssl \
+        --disable-gnutls \
         --enable-libvpx \
         --enable-libopenh264 \
-        --pkg-config=${BUILD_PREFIX}/bin/pkg-config \
-        --cc=${CC}      \
-        --cxx=${CXX}      \
-        --enable-libopus
+        --enable-libopus \
+        --enable-pthreads \
+        --enable-postproc
 
-make -j${CPU_COUNT}
-make install
+make -j${CPU_COUNT} ${VERBOSE_AT}
+make install -j${CPU_COUNT} ${VERBOSE_AT}
diff --git a/conda/ffmpeg/meta.yaml b/conda/ffmpeg/meta.yaml
index 0d6fbb5a93c641a177643b73e49636daddf87d83..d2b67f93e3db2a47a082a63d5527419ccb507501 100644
--- a/conda/ffmpeg/meta.yaml
+++ b/conda/ffmpeg/meta.yaml
@@ -1,4 +1,4 @@
-{% set version = "3.4" %}
+{% set version = "4.0" %}
 
 package:
   name: ffmpeg
@@ -6,16 +6,31 @@ package:
 
 source:
   url: https://ffmpeg.org/releases/ffmpeg-{{ version }}.tar.gz
-  sha256: 6ed03b00404a3923e3c2f560248a9c9ad79fbaaee26d723f74aae6b31fe2bae6
+  sha256: dc4b1c622baa34fc68d763cd2818e419d1af90271e0506604905f25a46ea8273
+  # This patch is required to fix https://trac.macports.org/ticket/55746
+  # with Xcode < 7.0, where _Nullable attribues are not supported.
+  # Can probably be removed once the compiler infrastructure is updated.
+  patches:  # [osx]
+    - patch-libavcodec-videotoolboxenc.c-drop-Nullable.patch  # [osx]
+
+  fn: ffmpeg-{{ version }}-win32-shared.zip  # [win32]
+  url: https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-{{ version }}-win32-shared.zip  # [win32]
+  sha256: 530c92df0ca14c35901b4b681847d62da3c50a0cc9b7ced37b04968f6b5c243d  # [win32]
+
+  fn: ffmpeg-{{ version }}-win64-shared.zip  # [win64]
+  url: https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-{{ version }}-win64-shared.zip  # [win64]
+  sha256: 8fe2d344463dbefc2db4239a4203a55ed0324faceaae57276a40c4fabda84c37  # [win64]
 
 build:
-  number: 1
+  number: 0
   # The windows build is repacking binaries rather than building from source
   skip: True  # [win]
   run_exports:
     # seems to be minor version compatibility
     # https://abi-laboratory.pro/tracker/timeline/ffmpeg/
     - {{ pin_subpackage('ffmpeg', max_pin='x.x') }}
+  missing_dso_whitelist:  # [osx]
+    - /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox  # [osx]
 
 requirements:
   build:
@@ -24,10 +39,13 @@ requirements:
     - pkg-config
     - libtool
     - yasm
+    - make
+
   host:
     - bzip2
     - zlib
-    - libiconv    # [osx]
+    - libiconv  # [osx]
+    - freetype
     - libvpx
     - libopus
     - openh264
@@ -36,16 +54,22 @@ test:
   commands:
     - ffmpeg --help
     - ffmpeg -codecs | grep "DEVI.S zlib"  # [unix]
+    # macOS h264 support comes from the VideoToolbox Framework I guess?
+    - ffmpeg -codecs | grep "DEV.LS h264"  # [osx]
+    # It is unclear to me why this is supported on macOS. Hmm.
+    - ffmpeg -protocols | grep "https"     # [osx]
     # Verify dynamic libraries on all systems
     {% set ffmpeg_libs = [
         "avcodec",
         "avdevice",
         "swresample",
+        "postproc",
         "avfilter",
         "swresample",
         "avcodec",
         "avformat",
         "swscale",
+        "avresample"
     ] %}
     {% for each_ffmpeg_lib in ffmpeg_libs %}
     - test -f $PREFIX/lib/lib{{ each_ffmpeg_lib }}.dylib  # [osx]
@@ -56,10 +80,9 @@ test:
 
 about:
   home: http://www.ffmpeg.org/
-  license: LGPL 2.1
-  license_family: LGPL
-  license_file: COPYING.LGPLv2.1
-  summary: Solution to record, convert and stream audio and video
+  license: GPL 3
+  license_file: COPYING.GPLv3  # [unix]
+  summary: Cross-platform solution to record, convert and stream audio and video.
   dev_url: https://ffmpeg.org/developer.html
   doc_url: https://ffmpeg.org/documentation.html
 
diff --git a/conda/ffmpeg/patch-libavcodec-videotoolboxenc.c-drop-Nullable.patch b/conda/ffmpeg/patch-libavcodec-videotoolboxenc.c-drop-Nullable.patch
new file mode 100644
index 0000000000000000000000000000000000000000..5a7bfb52316239e5dee41573a99413deab18fd0d
--- /dev/null
+++ b/conda/ffmpeg/patch-libavcodec-videotoolboxenc.c-drop-Nullable.patch
@@ -0,0 +1,11 @@
+--- libavcodec/videotoolboxenc.c.old	2018-01-18 17:00:25.000000000 +0100
++++ libavcodec/videotoolboxenc.c	2018-01-24 18:51:02.000000000 +0100
+@@ -41,7 +41,7 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' }
+ 
+ typedef OSStatus (*getParameterSetAtIndex)(CMFormatDescriptionRef videoDesc,
+                                            size_t parameterSetIndex,
+-                                           const uint8_t * _Nullable *parameterSetPointerOut,
++                                           const uint8_t **parameterSetPointerOut,
+                                            size_t *parameterSetSizeOut,
+                                            size_t *parameterSetCountOut,
+                                            int *NALUnitHeaderLengthOut);