From patchwork Fri Oct 6 20:14:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 5445 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp343830jah; Fri, 6 Oct 2017 13:14:47 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD9Ah9alMgIJCYOzgGl3v3GpgRx8+xod6hOQ1e0TS2rx+K/X8sgbA+csjBrhU2H8NCx9a+n X-Received: by 10.28.14.138 with SMTP id 132mr2505658wmo.7.1507320887499; Fri, 06 Oct 2017 13:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507320887; cv=none; d=google.com; s=arc-20160816; b=faoOgZVy/qqBC5zqsV9rdA9KRUK7hcfaQeZs5j9SO28IRgmHkW67jmQW0+g49hvgli aiwK01iFXKdVZArU4OPkE7q8niwC0xDM1QnSZ92I1pskxk6+529Ujaia7/7L+tDL9/77 e1ehD4uqwzsW4YqHogIkJE0PLvZ/YIk6i0SCDSBs7BtHJ3tLYksz47qc+RFF3dM01wXh 79KJXw+LpM+oUJfb5JL+Ejt/Hipd2dYGe9fpT8qJVOnyx966bEmtTz6dBsTMiSvk8uYn PvI01Q/4Oyf5nxAoMdBBFtKj5J26M9JLryavf90f7iaPVrYC05+iUqGUEIb9vvCgx64k ETUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=M3KjrN+jRNWWrXzSeZrNTTwaHp44DdhFWHegQ4DHeXE=; b=meTmSYd2yNTGStQlXzUSD3o8edd79gqxM76eONCURZP1chgPzcyhfeIJuwTKPdak75 XS8LHA6Ea3mRz83Lm0Jv4cR3QbQA8lgpnpB8kzPvTg13w0xotAWtjSGZEKFsx1gAw2o6 oToi9Zj3rjQf1/XtodJwHvpn7+r4zyBNp6hqgQll00jjuGsrk1OfLlZJjpNf3yt+LxpL sNt0T42GuQQUmwvUqNkJD4P6gSQkFWOYSy9Pth4ZTYJKts0RH3lp34ztduE20O/c31U2 cw1SVlzVnnCYeoZ7DOQN7IN61rMFvnxPPdRTs+7phGKWKTokn9huS9bthDqrvmSs0mP4 uV1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 63si1940030wro.423.2017.10.06.13.14.46; Fri, 06 Oct 2017 13:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4992068A526; Fri, 6 Oct 2017 23:14:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 79C3068A23B for ; Fri, 6 Oct 2017 23:14:35 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 28979E1176; Fri, 6 Oct 2017 22:14:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P5_ctFm1vh_6; Fri, 6 Oct 2017 22:14:35 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0C92FE10B4; Fri, 6 Oct 2017 22:14:35 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Oct 2017 22:14:31 +0200 Message-Id: <20171006201431.15839-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.5 Subject: [FFmpeg-devel] [PATCH] ffmpeg: always use single threaded decoding for attached pictures 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 Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Since af1761f7b5b1b72197dc40934953b775c2d951cc ffmpeg waits for a frame in each stream before writing the output header. If we are using threaded decoding for attached pictures, we have to read till EOF to be able to finally flush the decoder and output the decoded frame. This essentially makes ffmpeg buffer all non-attached picture packets, which will cause a "Too many packets buffered for output stream" eventually. By forcing single threaded decoding, we get a frame from a single packet as well and we can avoid the error. Fixes part of ticket #6375: ffmpeg -i 46564100.mp3 -acodec libmp3lame -ab 128k -ac 2 out.mp3 Signed-off-by: Marton Balint --- fftools/ffmpeg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 5be8788ea8..6eb7bf9d84 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2909,6 +2909,9 @@ static int init_input_stream(int ist_index, char *error, int error_len) if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) av_dict_set(&ist->decoder_opts, "threads", "auto", 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding till EOF. */ + if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) + av_dict_set(&ist->decoder_opts, "threads", "1", 0); ret = hw_device_setup_for_decode(ist); if (ret < 0) {