From patchwork Wed Sep 28 18:29:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Toohill X-Patchwork-Id: 767 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp563099vsd; Wed, 28 Sep 2016 11:29:48 -0700 (PDT) X-Received: by 10.194.148.225 with SMTP id tv1mr29397085wjb.121.1475087388131; Wed, 28 Sep 2016 11:29:48 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bi8si10004894wjb.3.2016.09.28.11.29.47; Wed, 28 Sep 2016 11:29:48 -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; dkim=neutral (body hash did not verify) header.i=@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 5A814689A3F; Wed, 28 Sep 2016 21:29:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9679268991F for ; Wed, 28 Sep 2016 21:29:11 +0300 (EEST) Received: by mail-pa0-f48.google.com with SMTP id dw4so5440734pac.1 for ; Wed, 28 Sep 2016 11:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oCfu+bXt+XSxpyMgctvGZfaXImnQG+nJe2xbQ3nxR+w=; b=BCsf1P9ZvGgYKzIwztNoVBzZ9jyI7UBWq8mLzVVku1xh/cSz05YHFn+NFOjUPD2IKv ax2GnL1rra/YFpkrbqbGoN3Zn+HLvTIo9+AEn5dcLqUvKyQBrnpKwfM3Ump6RC4Inqz4 DI10FC/a3Hh5WEXQKrbRfGdiWyrNhmOZi+gsE8gw2ZLeTbP8TyFlIa0VReOzdonUNZxS isvIwEBYe65ArI7dZys4CzNQ5HPBcscdNz7DrayU7o/R7sNJi4GT3xqTTaqX8gchkvW4 6eyrt4RwdeW5ZAptXxr6hG02T8wuq1Kf894V5JX8Z1N4Q7EqhFXCmSgnfNMjO0hHEMG0 10pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oCfu+bXt+XSxpyMgctvGZfaXImnQG+nJe2xbQ3nxR+w=; b=kw6o1CUX5UT/cAiSqAntEcX6QQ4BjWyI8mcXq+AOq79Ltn64Au2AQKb3sEixneRLHq MxFjS6sU4DfVAwrr1i616/x2nnJ9BEYlR80HFnpyN8mmYyGqp+8Sm+Q8kUCfRy5j0Al0 a8DsQGRAZqCCFT4JH0Y2XnT27aR7Rtakw+IuZu9GxFhnjSEqXsGeHPRLgIFSv03W1uhb eOw06cMMVegB1uckVyc1edFedwuXtK3OzsmOFg8KOXr7V9IC9U9zA9vbge4WdFgmt4O7 z7zwUIuu8xS/+0dSvl4TtJx5RoWOVPgSGISnm1u6L7oCwnS4NAfaJndnsfQrGf8cYDXp +xTw== X-Gm-Message-State: AA6/9Rl8U1LeLAH2NfQ51FlJMy6rD4yGucyhyJa9bAv0AX8PjERQIlbC93SQ53EFb3D9Hev5 X-Received: by 10.66.192.226 with SMTP id hj2mr11907282pac.102.1475087361961; Wed, 28 Sep 2016 11:29:21 -0700 (PDT) Received: from mungolini.mtv.corp.google.com ([100.96.2.73]) by smtp.gmail.com with ESMTPSA id wa9sm14248493pac.35.2016.09.28.11.29.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 11:29:21 -0700 (PDT) From: Jon Toohill To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2016 11:29:00 -0700 Message-Id: <1475087343-29745-3-git-send-email-jtoohill@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1475087343-29745-1-git-send-email-jtoohill@google.com> References: <1475087343-29745-1-git-send-email-jtoohill@google.com> Subject: [FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec parameters after encoding 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: Jon Toohill MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This preserves changes to fields of AVCodecParameters that get updated during encoding, such as trailing_padding (which may not be known until encoding is complete). --- ffmpeg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index d0f247e..0cdc762 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4255,6 +4255,21 @@ static int transcode(void) term_exit(); + /* update output codec parameters after encoding */ + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + if (ost->encoding_needed) { + ret = avcodec_parameters_from_context( + output_files[ost->file_index]->ctx->streams[ost->index]->codecpar, + ost->enc_ctx); + if (ret < 0) { + av_log(ost, AV_LOG_ERROR, "Error copying final codec context: %s\n", av_err2str(ret)); + if (exit_on_error) + exit_program(1); + } + } + } + /* write the trailer if needed and close file */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx;