Hi,

attached patch fixes ticket #4759 but I guess it is a bit too hasty to always abort transcoding if a single frame cannot be written. I guess it would be better to check for some "exit_on_error" like flag set but couldn't find out how to achieve that.

Any comments would be appreciated.

Regards,
Tobias
>From 7d6f8de2a411817c970a19d8766e69b6eb604132 Mon Sep 17 00:00:00 2001
From: Tobias Rapp <t.r...@noa-audio.com>
Date: Mon, 14 Sep 2015 12:06:22 +0200
Subject: [PATCH] avformat/mxfenc: stop encoding if unfilled video packet
 occurs

Fixes ticket #4759.
---
 libavformat/mxfenc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 84ce979..4eac812 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2262,7 +2262,7 @@ static void mxf_write_system_item(AVFormatContext *s)
     mxf_write_umid(s, 1);
 }
 
-static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
+static int mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
 {
     MXFContext *mxf = s->priv_data;
     AVIOContext *pb = s->pb;
@@ -2286,9 +2286,12 @@ static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacke
         ffio_fill(s->pb, 0, pad);
         av_assert1(!(avio_tell(s->pb) & (KAG_SIZE-1)));
     } else {
-        av_log(s, AV_LOG_WARNING, "cannot fill d-10 video packet\n");
+        av_log(s, AV_LOG_ERROR, "cannot fill d-10 video packet\n");
         ffio_fill(s->pb, 0, pad);
+        return AVERROR(EIO);
     }
+
+    return 0;
 }
 
 static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
@@ -2459,9 +2462,10 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
     mxf_write_klv_fill(s);
     avio_write(pb, sc->track_essence_element_key, 16); // write key
     if (s->oformat == &ff_mxf_d10_muxer) {
-        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
-            mxf_write_d10_video_packet(s, st, pkt);
-        else
+        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+            if ((err = mxf_write_d10_video_packet(s, st, pkt)) < 0)
+                return err;
+        } else
             mxf_write_d10_audio_packet(s, st, pkt);
     } else {
         klv_encode_ber4_length(pb, pkt->size); // write length
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to