[FFmpeg-devel] [PATCH v2 4/8] ffmpeg: remove sub-frame warning

Michael Niedermayer michael at niedermayer.cc
Fri Apr 1 22:10:21 CEST 2016


On Fri, Apr 01, 2016 at 06:52:53PM +0200, wm4 wrote:
> On Fri, 1 Apr 2016 17:47:45 +0200
> Michael Niedermayer <michael at niedermayer.cc> wrote:
> 
> > On Fri, Apr 01, 2016 at 05:27:11PM +0200, Michael Niedermayer wrote:
> > > On Fri, Apr 01, 2016 at 04:53:55PM +0200, wm4 wrote:  
> > > > On Fri, 1 Apr 2016 16:44:42 +0200
> > > > Paul B Mahol <onemda at gmail.com> wrote:
> > > >   
> > > > > It should set it because it is not sane format.  
> > > > 
> > > > I mean, why do we want to keep this message, if it obviously didn't
> > > > help with anything?  
> > > 
> > > it is useful for debuging and to prevent invalid files from being
> > > created  
> > 
> > to elaborate on this
> > If a demuxer returns an AVPacket with multiple frames in it and that
> > gets stored in a output file then the output file is invalid with
> > no indication that it is. Such file would likely play fine on some
> > players and fail on others. Thats a really serious problem for the
> > user as even if he tests the output file by playing it he possibly
> > wont notice a problem
> > 
> > With the multiple subframes message decoding both the original file
> > with the buggy demuxer as well as playing the newly created output
> > file would likely show warnings that would point at the problem
> > (which might be a forgotten needs_parsing in the demuxer)
> > 
> > I belive its important to keep some means to detect this kind of
> > problem. Also as it is easy to set the parsing stuff up wrongly
> > a reverse engeneered container might appear to store 1 mp3 frame per
> > packet but that might then turn out false on analysis of a wider
> > range of files ...
> > 
> > [...]
> > 
> 
> Anyway, the attached patch probably works. I didn't bother with
> silencing subsequent warnings. Spams log messages when playing shorten.

please add the diff below (LGTM with it)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index ac17196..8491647 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -173,6 +173,7 @@ typedef struct AVCodecInternal {
     int buffer_pkt_valid; // encoding: packet without data can be valid
     AVFrame *buffer_frame;
     int draining_done;
+    int showed_multi_packet_warning;
 } AVCodecInternal;

 struct AVCodecDefault {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e5033d5..f97921d 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2416,8 +2416,11 @@ fail:
             av_frame_unref(frame);
     }

-    if (ret >= 0 && ret != avpkt->size && !(avctx->codec->capabilities & AV_CODEC_CAP_SUBFRAMES))
+    if (!avci->showed_multi_packet_warning &&
+        ret >= 0 && ret != avpkt->size && !(avctx->codec->capabilities & AV_CODEC_CAP_SUBFRAMES)) {
         av_log(avctx, AV_LOG_WARNING, "Multiple frames in a packet.\n");
+        avci->showed_multi_packet_warning = 1;
+    }

     return ret;
 }

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160401/f3136992/attachment.sig>


More information about the ffmpeg-devel mailing list