diff --git a/hs-ffmpeg.cabal b/hs-ffmpeg.cabal
--- a/hs-ffmpeg.cabal
+++ b/hs-ffmpeg.cabal
@@ -1,5 +1,5 @@
 name:           hs-ffmpeg
-version:        0.3.3
+version:        0.3.4
 cabal-version:  >= 1.6
 license:        BSD3
 author:         Vasyl Pasternak
diff --git a/src/Media/FFMpeg/Codec.hsc b/src/Media/FFMpeg/Codec.hsc
--- a/src/Media/FFMpeg/Codec.hsc
+++ b/src/Media/FFMpeg/Codec.hsc
@@ -183,6 +183,23 @@
 -- |decodeVideo -- decodes video frame, returns True if
 -- complete picture is decompressed
 --
+#if LIBAVCODEC_VERSION_MAJOR < 53
+foreign import ccall "avcodec_decode_video" _avcodec_decode_video :: 
+    Ptr () -> Ptr () -> (Ptr CInt) -> Ptr () -> CInt -> IO CInt
+
+decodeVideo :: CodecContext -> Frame -> Packet -> IO Bool
+decodeVideo ctx frm pkt =
+    withThis ctx $ \ctx' -> 
+    withThis frm $ \frm' -> 
+    let obuf = packetGetBuffer pkt
+    in withThis obuf $ \obuf' ->
+    alloca $ \gotPic' -> do
+      throwIf (<0)
+              (printf "decodeVideo: failed to decode video packet: %d" . cToInt)
+              (_avcodec_decode_video ctx' frm' gotPic' obuf' 
+               (cFromInt (bufferSize obuf)))
+      liftM (>0) (peek gotPic')
+#else
 foreign import ccall "avcodec_decode_video2" _avcodec_decode_video :: 
     Ptr () -> Ptr () -> (Ptr CInt) -> Ptr () -> IO CInt
 
@@ -196,12 +213,29 @@
               (printf "decodeVideo: failed to decode video packet: %d" . cToInt)
               (_avcodec_decode_video ctx' frm' gotPic' pkt')
       liftM (>0) (peek gotPic')
-
+#endif
 
 --
 -- |decodeAudio - decodes audio frame to the existing buffer
 -- return (ReadBytes, DecodedBytes)
 --
+#if LIBAVCODEC_VERSION_MAJOR < 53      
+foreign import ccall "avcodec_decode_audio2" _avcodec_decode_audio :: 
+    Ptr () -> Ptr () -> (Ptr CInt) -> Ptr () -> CInt -> IO CInt
+
+decodeAudio :: CodecContext -> Buffer -> Packet -> IO (Int, Int)
+decodeAudio ctx buf pkt = 
+    withThis ctx $ \ctx' -> 
+    withThis buf $ \buf' -> 
+    let obuf = packetGetBuffer pkt 
+    in withThis obuf $ \obuf' -> 
+    with bufSize $ \frm_size -> do
+      result <- throwIf (<0)
+                (printf "decodeAudio: decode packet failed. Return value is %d" . cToInt)
+                (liftM cToInt $ _avcodec_decode_audio ctx' buf' frm_size obuf' (cFromInt (bufferSize obuf)))
+      liftM ((,) result . cToInt) $ peek frm_size
+    where bufSize = cFromInt $ bufferSize buf :: CInt
+#else
 foreign import ccall "avcodec_decode_audio3" _avcodec_decode_audio :: 
     Ptr () -> Ptr () -> (Ptr CInt) -> Ptr () -> IO CInt
 
@@ -216,7 +250,7 @@
                 (liftM cToInt $ _avcodec_decode_audio ctx' buf' frm_size pkt')
       liftM ((,) result . cToInt) $ peek frm_size
     where bufSize = cFromInt $ bufferSize buf :: CInt
-
+#endif
 
 --
 -- | decodeAudio is very complex to use, the another version of the 
@@ -328,7 +362,8 @@
 -- packet.data
 --
 
-foreign import ccall "av_init_packet" _av_init_packet :: Ptr () -> IO ()
+-- The 0.51.0 version of ffmpeg defines av_init_packet as inline
+foreign import ccall "b_init_packet" _av_init_packet :: Ptr () -> IO ()
 foreign import ccall "b_free_packet" _b_free_packet :: Ptr () -> IO ()
 
 
diff --git a/src/Media/FFMpeg/Format.hsc b/src/Media/FFMpeg/Format.hsc
--- a/src/Media/FFMpeg/Format.hsc
+++ b/src/Media/FFMpeg/Format.hsc
@@ -86,7 +86,11 @@
 --
 -- | newContext - allocates new FormatContext
 --
+#if LIBAVFORMAT_VERSION_MAJOR < 53
+foreign import ccall "av_alloc_format_context" _alloc_context :: IO (Ptr ())
+#else
 foreign import ccall "avformat_alloc_context" _alloc_context :: IO (Ptr ())
+#endif
 
 newContext :: IO FormatContext
 newContext = do 
diff --git a/src/Media/FFMpeg/_c_utils.c b/src/Media/FFMpeg/_c_utils.c
--- a/src/Media/FFMpeg/_c_utils.c
+++ b/src/Media/FFMpeg/_c_utils.c
@@ -1,6 +1,10 @@
 
-#include <libavcodec/avcodec.h>
+#include "ffmpeg.h"
 
 void b_free_packet (AVPacket * pkt){
   av_free_packet (pkt);
+}
+
+void b_init_packet (AVPacket * pkt){
+  av_init_packet (pkt);
 }
