[FFmpeg-devel,2/3] ffmpeg: warn users about demuxers producing zero sized packets

Submitted by Marton Balint on Sept. 30, 2016, 9:29 a.m.

Details

Message ID 1475227747-11938-2-git-send-email-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint Sept. 30, 2016, 9:29 a.m.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 ffmpeg.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

wm4 Sept. 30, 2016, 9:43 a.m.
On Fri, 30 Sep 2016 11:29:06 +0200
Marton Balint <cus@passwd.hu> wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  ffmpeg.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 9a8e65a..2296df8 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -3865,10 +3865,19 @@ static int process_input(int file_index)
>      int ret, i, j;
>      int64_t duration;
>      int64_t pkt_dts;
> +    static int warned_zero_sized_packet_bug = 0;
>  
>      is  = ifile->ctx;
>      ret = get_input_packet(ifile, &pkt);
>  
> +    if (ret >= 0 && pkt.size == 0) {
> +        if (!warned_zero_sized_packet_bug) {
> +            av_log(is, AV_LOG_ERROR, "Demuxer is generating zero sized packets, report this bug!\n");
> +            warned_zero_sized_packet_bug = 1;
> +        }
> +        ret = AVERROR(EAGAIN);
> +    }
> +
>      if (ret == AVERROR(EAGAIN)) {
>          ifile->eagain = 1;
>          return ret;

Also fine with me. I think there are a bunch of situations where
demuxers still do this, and they should all be gradually fixed.

Should this be in libavformat?

Patch hide | download patch | download mbox

diff --git a/ffmpeg.c b/ffmpeg.c
index 9a8e65a..2296df8 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3865,10 +3865,19 @@  static int process_input(int file_index)
     int ret, i, j;
     int64_t duration;
     int64_t pkt_dts;
+    static int warned_zero_sized_packet_bug = 0;
 
     is  = ifile->ctx;
     ret = get_input_packet(ifile, &pkt);
 
+    if (ret >= 0 && pkt.size == 0) {
+        if (!warned_zero_sized_packet_bug) {
+            av_log(is, AV_LOG_ERROR, "Demuxer is generating zero sized packets, report this bug!\n");
+            warned_zero_sized_packet_bug = 1;
+        }
+        ret = AVERROR(EAGAIN);
+    }
+
     if (ret == AVERROR(EAGAIN)) {
         ifile->eagain = 1;
         return ret;