From patchwork Sun Mar 18 19:09:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8029 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1872278jad; Sun, 18 Mar 2018 12:09:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELtMylN4O2eQtyU80Np/e6536oqAp9seqANXv6j+U5InMj382BfaP6WLbImq/FPgJDF1eSNK X-Received: by 10.223.199.71 with SMTP id b7mr7902180wrh.228.1521400163738; Sun, 18 Mar 2018 12:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521400163; cv=none; d=google.com; s=arc-20160816; b=guMOKN30WsTZWYhmf7+zZVWxsWuCHoaZIJsYsqgaygGevkOaulBX2LN/uS9i+ZHhzh q2+gkdZs3H+FqXpmXQc+3x4T6wu1MA2dZMw9mpmMic20PFrfJoTExQBNC/Zzapm45Mg/ 9ydLBaX8C9CWVkyii7opeSAAe/OtwDdSV98mzCZ9ljIXXd9FKo7qYZeYOHF2SIPkrDMa yqilzmSI+obTfa1YvW/FrT42o8Z+HUGkEyQE2WgNTqvi6yQedNrgAeq2zwFh3OcybUWE Cgj5zdPXdo7Ix8hbAGnSNyi+ADe4VZ00RCrOaBx2N5aFD8G+c9JYEh96yz4CDEhYU3P0 j3nQ== 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=BWTV1+bObf+UIURZr+X1NKibOLrpX4rnbvxqoMil670=; b=ZiTqRbc0xXcnGkIfoB8hK53aWfl9MwsTGcVkNVb/IgPSk9lHJCGWW9Rg37/9BqEozN ack29JrKeP4Sg5Gx5ggbalY/zpimefoMudkpko/BBGTyxvgNIzpPN6gLJUQc0OlhuIZT Ujo5DhpuQm6cN5iSRkIY6eHncrUqybQehTajrfEymSVW7DggKEVe7MglFrVfTpsC9WTr eoPSQQXpDiq0f74zu4HyfkpSMcSJ+2rB4jxQjeitqwiNllXYCT2LpZEJNNAnUs2Wg0XD QCoVC8u4p2AdVhcwIezXgu3p5F+yV/+rzfaTyNRDan5Dzw0ODupdG3x3dIWeQPw58jqU 2iug== 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 b17si9147630wrb.514.2018.03.18.12.09.23; Sun, 18 Mar 2018 12:09:23 -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 598C2689C79; Sun, 18 Mar 2018 21:09:08 +0200 (EET) 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 A3396689C79 for ; Sun, 18 Mar 2018 21:09:01 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2033BE11A7; Sun, 18 Mar 2018 20:09:15 +0100 (CET) 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 knvUcAFA7aJc; Sun, 18 Mar 2018 20:09:14 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 16799E119B; Sun, 18 Mar 2018 20:09:14 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Mar 2018 20:09:08 +0100 Message-Id: <20180318190909.31057-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: fallback to codecpar parameters on input filter eof 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" Fixes ticket #6854 and the following simpler case: ffmpeg -f lavfi -i testsrc=d=1 -f lavfi -i testsrc=d=0 -filter_complex overlay -f null none Signed-off-by: Marton Balint --- fftools/ffmpeg.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ee7258fcd1..8876c99560 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1855,23 +1855,6 @@ static void flush_encoders(void) ost->file_index, ost->st->index); if (ost->filter && !fg->graph) { - int x; - for (x = 0; x < fg->nb_inputs; x++) { - InputFilter *ifilter = fg->inputs[x]; - if (ifilter->format < 0) { - AVCodecParameters *par = ifilter->ist->st->codecpar; - // We never got any input. Set a fake format, which will - // come from libavformat. - ifilter->format = par->format; - ifilter->sample_rate = par->sample_rate; - ifilter->channels = par->channels; - ifilter->channel_layout = par->channel_layout; - ifilter->width = par->width; - ifilter->height = par->height; - ifilter->sample_aspect_ratio = par->sample_aspect_ratio; - } - } - if (!ifilter_has_all_input_formats(fg)) continue; @@ -2214,6 +2197,22 @@ static int ifilter_send_eof(InputFilter *ifilter, int64_t pts) } else { // the filtergraph was never configured FilterGraph *fg = ifilter->graph; + if (ifilter->format < 0) { + AVCodecParameters *par = ifilter->ist->st->codecpar; + // We never got any input. Set a fake format, which will + // come from libavformat. + ifilter->format = par->format; + ifilter->sample_rate = par->sample_rate; + ifilter->channels = par->channels; + ifilter->channel_layout = par->channel_layout; + ifilter->width = par->width; + ifilter->height = par->height; + ifilter->sample_aspect_ratio = par->sample_aspect_ratio; + } + if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) { + av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input %d, stream %d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index); + return AVERROR_INVALIDDATA; + } for (i = 0; i < fg->nb_inputs; i++) if (!fg->inputs[i]->eof) break;