diff --git a/ffmpeg.c b/ffmpeg.c
index df06304c8c8dca9cd146a676b61054f734265b8a..65367948978df9fb68203b4aaeeddbc7d91d2efb 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1969,6 +1969,7 @@ static int av_encode(AVFormatContext **output_files,
     
     ret = 0;
  fail1:
+    av_freep(&bit_buffer);
     av_free(file_table);
 
     if (ist_table) {