diff --git a/ffmpeg.c b/ffmpeg.c
index eb91de9d06360f0bb4edf8eb4fb68fb29dcf8d16..83fdb378db3111bdd9953c051ec995443b648635 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2231,6 +2231,7 @@ static int av_encode(AVFormatContext **output_files,
     }
 
     /* finished ! */
+    ret = 0;
 
  fail:
     av_freep(&bit_buffer);