Alexander Strasser wrote on 21.03.2019 at 23:34:

> 3. Return zero-sized packets => This works and is consistent with how
>    we handle frames flagged to be corrupted (V4L2_BUF_FLAG_ERROR).
>    See commit 28f20d2ff487aa589643d8f70eaf614b78839685 .

I posted a patch for this on Sat, 25 Aug 2018. It seems to have been
forgotten, attached again.
From 0af8515acca4d598570d03450656adc0ed7ac2d7 Mon Sep 17 00:00:00 2001
From: Stephan Hilb <step...@ecshi.net>
Date: Sun, 10 Jun 2018 21:07:52 +0200
Subject: [PATCH] lavd/v4l2: skip buffers not matching frame_size

By adopting the same behaviour as if there was corrupted data in the
buffer (see the check for V4L2_BUF_FLAG_ERROR) the resulting rawvideo
now at least contains valid data (the previous frame being duplicated).
Fixes video capturing for some stk1160 devices.
---
 libavdevice/v4l2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 10a0ff0dd6..ab903bbcee 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -534,11 +534,10 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
             s->frame_size = buf.bytesused;
 
         if (s->frame_size > 0 && buf.bytesused != s->frame_size) {
-            av_log(ctx, AV_LOG_ERROR,
+            av_log(ctx, AV_LOG_WARNING,
                    "Dequeued v4l2 buffer contains %d bytes, but %d were expected. Flags: 0x%08X.\n",
                    buf.bytesused, s->frame_size, buf.flags);
-            enqueue_buffer(s, &buf);
-            return AVERROR_INVALIDDATA;
+            buf.bytesused = 0;
         }
     }
 
-- 
2.18.0

Attachment: pgpNOj7I3nYx7.pgp
Description: OpenPGP digital signature

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to