From patchwork Sat Mar 24 21:31:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8143 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1905045jad; Sat, 24 Mar 2018 14:31:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELu6/tfbSp+hpgxHj4glTL9IP/1M40HqTtCLl2RHSsVHEumYFzTmN7hBV2p8h82KRMJ09FtN X-Received: by 10.28.191.12 with SMTP id p12mr7656780wmf.99.1521927078319; Sat, 24 Mar 2018 14:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521927078; cv=none; d=google.com; s=arc-20160816; b=IQ8RdsCp0Hv1w/ziugCzlLHB1ir9ST4cmxoydR882CYdPimtuPBHOtbUcxL7IkKnYt iQeHYdwv0xQyzps833TIR4K1yFG1wMEdGJlZR37n2do3lTjSmdLBDv+XTPLGBNdXLNph R7XOYuv25u+Un+McxAjj/1FEg7ut79+eRFxgauwIB2OpI8W5zOwagEn350FZvZZCRhbd 7Zf5vnyeHFZ5/k3WgKGmJ+JGI7E/c/3K8TAdkm7jtdzlE/tgA4VenDZ+KdkI6LhSavE7 8V3ouys9uh696dhaa1uAni6K/PDLnt/lE66ce+79GF/cUo0pRsW5swEs3co0tP7+yGWi TvQA== 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:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=lzXIKhZe0hph/z2qeUhG9TUWgcJBxcOhkJ70et5z+O4=; b=sMC3E9QtDf9epQFJoqLLySvPtHetwKfwHCh08Hk+R1IGmEyVRL2WeuFJktrpWU7eCq qNDU7P6X+f1HqtfPyHBV9tZYqthO0Zqr1ItrLsE06NYX/V7Nh8p8sqgJFPI2oWPCIco3 YljK+XfBr6O08MCboJNcnKJ6uzgQjePC7pqOqGdVdmnXFqHWBwXI2ZT9yKfrmnLU/6Ly VSg2SAiXeJTr6FjOPN7CSGLcd1sqSaVT+OOQemezTr8NQIWudif33MKsGHw9t65RMTDI G0swuushgASjZ+AlNataNotHiNZBaWo88bIoT0vQ4Hjv4vlB2Wt2ch09Tph+N1Cnh4qy p6/A== 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 r13si9118454wrb.17.2018.03.24.14.31.17; Sat, 24 Mar 2018 14:31:18 -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 BA3F2689CB7; Sat, 24 Mar 2018 23:30:59 +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 73A77689C3F for ; Sat, 24 Mar 2018 23:30:53 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E92E7E1082; Sat, 24 Mar 2018 22:31:09 +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 31bHN7ESm8bv; Sat, 24 Mar 2018 22:31:09 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1EEBFE0E0C; Sat, 24 Mar 2018 22:31:09 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Mar 2018 22:31:03 +0100 Message-Id: <20180324213103.6619-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCHv2 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, 21 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1b2e37b8d8..b72884673d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1829,6 +1829,19 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti print_final_stats(total_size); } +static void ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par) +{ + // 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; +} + static void flush_encoders(void) { int i, ret; @@ -1855,18 +1868,8 @@ static void flush_encoders(void) 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->format < 0) + ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar); } if (!ifilter_has_all_input_formats(fg)) @@ -2196,6 +2199,12 @@ static int ifilter_send_eof(InputFilter *ifilter, int64_t pts) } else { // the filtergraph was never configured FilterGraph *fg = ifilter->graph; + if (ifilter->format < 0) + ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar); + 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 stream %d:%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;