diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 202964e294c871e79c80b6469b4224553f5b673b..6310f84e17e0fa83f86f4f445ddf33cf9966df1b 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -507,9 +507,17 @@ static void Flush( decoder_t *p_dec )
     p_sys->i_pts = VLC_TS_INVALID; /* To make sure we recover properly */
     p_sys->i_late_frames = 0;
 
+    /* Abort pictures in order to unblock all avcodec workers threads waiting
+     * for a picture. This will avoid a deadlock between avcodec_flush_buffers
+     * and workers threads */
+    decoder_AbortPictures( p_dec, true );
+
     post_mt( p_sys );
     avcodec_flush_buffers( p_context );
     wait_mt( p_sys );
+
+    /* Reset cancel state to false */
+    decoder_AbortPictures( p_dec, false );
 }
 
 /*****************************************************************************