diff --git a/src/video/drivers/ffmpeg.cpp b/src/video/drivers/ffmpeg.cpp
index 435225d..ff30349 100644
--- a/src/video/drivers/ffmpeg.cpp
+++ b/src/video/drivers/ffmpeg.cpp
@@ -34,6 +34,8 @@ extern "C"
 #include <libavutil/mathematics.h>
 }
 
+#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
+
 namespace pangolin
 {
 
@@ -74,8 +76,10 @@ std::string FfmpegFmtToString(const AVPixelFormat fmt)
     TEST_PIX_FMT_RETURN(YUVJ420P);
     TEST_PIX_FMT_RETURN(YUVJ422P);
     TEST_PIX_FMT_RETURN(YUVJ444P);
+#ifdef FF_API_XVMC
     TEST_PIX_FMT_RETURN(XVMC_MPEG2_MC);
     TEST_PIX_FMT_RETURN(XVMC_MPEG2_IDCT);
+#endif
     TEST_PIX_FMT_RETURN(UYVY422);
     TEST_PIX_FMT_RETURN(UYYVYY411);
     TEST_PIX_FMT_RETURN(BGR8);
@@ -95,11 +99,13 @@ std::string FfmpegFmtToString(const AVPixelFormat fmt)
     TEST_PIX_FMT_RETURN(YUV440P);
     TEST_PIX_FMT_RETURN(YUVJ440P);
     TEST_PIX_FMT_RETURN(YUVA420P);
+#ifdef FF_API_VDPAU
     TEST_PIX_FMT_RETURN(VDPAU_H264);
     TEST_PIX_FMT_RETURN(VDPAU_MPEG1);
     TEST_PIX_FMT_RETURN(VDPAU_MPEG2);
     TEST_PIX_FMT_RETURN(VDPAU_WMV3);
     TEST_PIX_FMT_RETURN(VDPAU_VC1);
+#endif
     TEST_PIX_FMT_RETURN(RGB48BE );
     TEST_PIX_FMT_RETURN(RGB48LE );
     TEST_PIX_FMT_RETURN(RGB565BE);
@@ -119,7 +125,9 @@ std::string FfmpegFmtToString(const AVPixelFormat fmt)
     TEST_PIX_FMT_RETURN(YUV422P16BE);
     TEST_PIX_FMT_RETURN(YUV444P16LE);
     TEST_PIX_FMT_RETURN(YUV444P16BE);
+#ifdef FF_API_VDPAU
     TEST_PIX_FMT_RETURN(VDPAU_MPEG4);
+#endif
     TEST_PIX_FMT_RETURN(DXVA2_VLD);
     TEST_PIX_FMT_RETURN(RGB444BE);
     TEST_PIX_FMT_RETURN(RGB444LE);
@@ -559,7 +567,8 @@ void FfmpegVideoOutputStream::WriteFrame(AVFrame* frame)
 
     int ret;
     int got_packet = 1;
-
+	
+#if FF_API_LAVF_FMT_RAWPICTURE
     // Setup AVPacket
     if (recorder.oc->oformat->flags & AVFMT_RAWPICTURE) {
         /* Raw video case - directly store the picture in the packet */
@@ -569,6 +578,10 @@ void FfmpegVideoOutputStream::WriteFrame(AVFrame* frame)
         pkt.pts           = frame->pts;
         ret = 0;
     } else {
+#else
+    {
+#endif
+
         /* encode the image */
 #if (LIBAVFORMAT_VERSION_MAJOR >= 54)
         ret = avcodec_encode_video2(stream->codec, &pkt, frame, &got_packet);
