[FFmpeg-devel] [PATCH] Check for avio fail in avformat_write_header, av_write_frame

Andrey Utkin andrey.krieger.utkin at gmail.com
Tue Aug 14 11:48:45 CEST 2012


---
 libavformat/utils.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7b45944..e76a015 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3369,7 +3369,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
 
     if(s->oformat->write_header){
         ret = s->oformat->write_header(s);
-        if (ret < 0)
+        if ((ret < 0) || (s->pb && s->pb->error))
             goto fail;
     }
 
@@ -3493,8 +3493,12 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     if (!pkt) {
-        if (s->oformat->flags & AVFMT_ALLOW_FLUSH)
-            return s->oformat->write_packet(s, pkt);
+        if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
+            ret = s->oformat->write_packet(s, pkt);
+            if (s->pb && s->pb->error)
+                return s->pb->error;
+            return ret;
+        }
         return 1;
     }
 
@@ -3504,6 +3508,8 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
         return ret;
 
     ret= s->oformat->write_packet(s, pkt);
+    if (s->pb && s->pb->error)
+        return s->pb->error;
 
     if (ret >= 0)
         s->streams[pkt->stream_index]->nb_frames++;
-- 
1.7.8.6



More information about the ffmpeg-devel mailing list