From patchwork Wed Jun 5 20:04:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Strasser X-Patchwork-Id: 13422 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A97B2449639 for ; Wed, 5 Jun 2019 23:10:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 884DA680A03; Wed, 5 Jun 2019 23:10:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 432C568034D for ; Wed, 5 Jun 2019 23:10:02 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1559765392; bh=gpakM/sFYXbBxjeTCVgtr5sLJbBla3sV99IC65b/5vs=; h=X-UI-Sender-Class:Date:From:To:Subject; b=av3m7c+zYelmacqC0Ej08dISf+OzQ++GEuy6yUoHUlBw6K5khI/5trG4A9c3QLYe3 93vz4fKC/NT/MjFmU7F/+knhcISNuV/z+na9sJbceNYkEDOkjEmq2QMPIhhnfl7fOV jj6mowKznL8l4Hmc3WU1RsnSS6ApJV16P2VKnmII= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from kappa.local ([91.55.13.48]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MNHqL-1hSJgc2NJp-006zsg; Wed, 05 Jun 2019 22:04:39 +0200 Date: Wed, 5 Jun 2019 22:04:38 +0200 From: Alexander Strasser To: ffmpeg-devel@ffmpeg.org Message-ID: <68fadf1cb959c4653e7d4b180f0edde67affd1f2.1559764198.git.eclipse7@gmx.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID: V03:K1:OnZtIN8kQDhJX8sZIsYLbZsH8VMEhR9l9xjxoMQWwplY5Oupvx1 PoZo95OYBDkyHKBvQfV5fNWzBYcUSGcSOWQeBkJ8kiPyYb1W1Kg9P4hs+gjOf2XM9uL7tSg /9mYCzLN9uBum8xNytJcArkfS83JccmIEzCXMiUV0rzft+H22V+/0mTXqA5i07CqrI0LKKN VMRPlfAutmV6HWSbi78yQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:oq1WTc+kTsM=:Pi0hK8zATMix1bkwSB52Mg ShDQgIOE0r7NtVlDnlutm+rtazcBMBSGiH6g6EvjnvGdWi7u+EGYDb1QKwYWLT0ZrMH+ueMe6 f/QlGpjBvSU/l++C7Bfve99wsMGkFk/+NW8HhgVzBq+JNsHxqz5kwbBLe5ZHFDyOi7Edmr0KU jxs5jJguzL12UR6/IvHiZO3nCuPPpaYq67aynU7WMUgpJf0+h5hp3Qbeel23/aYg0ADdxBrl3 sDCvaqktlVJuvi3+lGgoXYJPFGxg2Q1EHTEcqrTyStaXnYf7IU8/ztESgbDzs8+00DGlhe6Gb xtd+pem5uthV+OM+RPEu1XOIW7Mo9aeiu+I9dhtk22J+xU+NPSP+Fk1rRGlTAy6MIPqR5O3SQ USiwmgLTmgwmWNy/ySynTn629Mes3U487YynPmY/5JJZNWY6ewNa9dBm/vONeiMbGkVrBMuHG 3EZIQgLgGYsLPKEbggGMgK2aaBCyWV4tHylpoEdVpMbEOVKPIBe12SgINUcWb8krXNmPQQKCL bISnD+WsrdOQRO8qUfF7ESmhUGYeFfOtWk+alUtZZXPnbzJp0+/Lu/llM6LlAJbXiZsILaBID yNjzcY0gQhOw4JKmTianEiA3L8MKhvDx92rlShbf0e3RxbSj0Yl80VWmm/5gN4Cc5OE2TcPHR BI2Ho+5gDG0g6HSGwbvGXqxXwdtIDmFhTVnnQsXTJTwqBB5ojZlAxiY7UcLc1UBw9QApROtG7 3527UQB/Obx4cpMS8/H85gHC4/fOsrWBimj6b7rWh3ek3uCpO1liLMMRA1kGFkkwywCXECBy+ mnN3gl+v/RR0lcOHIMkkSsQXEH6P5eohip+1heAB4sVvs+SscXYidiC29PG/7940w3tLTXvwk ULXENUnAWc8FigVhX/y8PcSfGJ0ExrPyQ27lq7JlBT4/nkSzVb7UlZuB27bEW3ZnwiH9drI3E T66FWDd4u4G6qqb/haC8MAOZf7vkQWMo= Subject: [FFmpeg-devel] [PATCH] lavd/v4l2: produce a 0 byte packet when a dequeued buffer's size is unexpected X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Stephan Hilb Behave like we do for V4L2_BUF_FLAG_ERROR, implemented in commit 28f20d2ff4 . For some devices (probably also related to the V4L driver implementation) it happens that when invoking the ioctl DQBUF, the returned buffer is not of the expected size. Here are two examples for such occurrences: [video4linux2,v4l2 @ 0x258b440] Dequeued v4l2 buffer contains 609596 bytes, but 614400 were expected. Flags: 0x00000001. /dev/video1: Invalid data found when processing input [video4linux2,v4l2 @ 0x225f440] Dequeued v4l2 buffer contains 609508 bytes, but 614400 were expected. Flags: 0x00000001. /dev/video1: Invalid data found when processing input For the ffmpeg CLI tool this means it will stop capturing and exit. The described behaviour was observed at least with one OmniVision USB web cam and with some stk1160 devices. If you search the web for the error message, you will find quite a few instances of this problem. Some of them experienced on other devices. Probably fixes ticket #4795 Signed-off-by: Alexander Strasser --- This is exactly Stephan's patch except for the commit message. @Stephan: I hope you are OK with my wording in the new message. I contacted Giorgio off-list and also put him in Bcc for this email. He previously reacted, but he probably doesn't have enough time. So if there are no objections I intent to commit in roughly a week if no more issues are found and no objections are raised. libavdevice/v4l2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index a9a0ed324d..446a243cf8 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -538,11 +538,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; } }