From patchwork Mon Sep 26 17:13:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Toohill X-Patchwork-Id: 729 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp2026065vsd; Mon, 26 Sep 2016 10:14:11 -0700 (PDT) X-Received: by 10.194.59.116 with SMTP id y20mr21742894wjq.181.1474910051064; Mon, 26 Sep 2016 10:14:11 -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 x17si9343070wma.104.2016.09.26.10.14.07; Mon, 26 Sep 2016 10:14:11 -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 953BB689E85; Mon, 26 Sep 2016 20:13:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04741689E6C for ; Mon, 26 Sep 2016 20:13:38 +0300 (EEST) Received: by mail-pf0-f174.google.com with SMTP id 21so67789214pfy.0 for ; Mon, 26 Sep 2016 10:13:55 -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=4aJlHbyw8zNipWpThb6UJdCD6K5Z6kXwSKLSuqiE+FI=; b=GGWF2Y4/HbdRvmAx2fG1DdKlnfUOqCq3ZpxTT456lR+Fy7m28ZJCVF3+PouKGTZk3v cKbF/yV7DQmlFuFhrOSfzQga+0JA0/WoejSCgX+vI5KsXevmfuR6keqEe0KCj15Hg4sZ itzD9z9MauU5y0P+HcbGq9ukxwguTRZ7cqYpKCFzpFvHJfgXdzMX2DFnaXV8oOvG4/Wk PaIqCptbzeM5z/hCP+ev+Cq20IHiMA+JNDT6FC7iLnIpP7PFrBratmxKiPtbTcDCKjYC kdqRuKr6+bYWrO4xh3OB2wLYf3tgFdo63n9DxFGgybTMlrOwvZ5h0/YjX9mpN62PAY4u 6fSg== 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=4aJlHbyw8zNipWpThb6UJdCD6K5Z6kXwSKLSuqiE+FI=; b=Sj8T+l/HTR+6RMee50dS8n79j7G3tpPKVFLHx+SnV23dU9Sh3YMn8O6WTSJ/Fy47Z3 ZaQkWzqDY4VP/a/5wICKf5Xk0IwRVJF4AyREaNf4GuvfxoElFPBw3n9P+PRyupuJiXc2 DrnYovCZfr1/3Xf4GtzuADd4wd5idJNSonAlTii9166u0Da2XVtpvzslG5XN/WBzhTx1 5W9QzzlLcUWq44LgqMzq9lYr60udUCCFHGsS//WGG00UeeNSt/VHTJmFnHiD49Dfajac jrp7LC9+wy3xHV0FZwYOrLLs7gENQjpId59G/1jT7imzGxOlBvN+29FdnbY6XPTK0e63 96xA== X-Gm-Message-State: AE9vXwPuGhZjrBFfbLTCOaathfFAa+G7rrPeKS804z5///lsUJXRZq+yNNO3HX8WUSyFBG5Z X-Received: by 10.98.55.71 with SMTP id e68mr38370804pfa.147.1474910033912; Mon, 26 Sep 2016 10:13:53 -0700 (PDT) Received: from mungolini.mtv.corp.google.com ([100.96.2.73]) by smtp.gmail.com with ESMTPSA id c66sm32499223pfd.24.2016.09.26.10.13.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 10:13:52 -0700 (PDT) From: Jon Toohill To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Sep 2016 10:13:36 -0700 Message-Id: <1474910019-13882-2-git-send-email-jtoohill@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1474910019-13882-1-git-send-email-jtoohill@google.com> References: <1474910019-13882-1-git-send-email-jtoohill@google.com> Subject: [FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec contexts 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 AVCodecContext 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 df55a49..1e973f5 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4243,6 +4243,21 @@ static int transcode(void) term_exit(); + /* update output codec contexts after encoding */ + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + if (ost->encoding_needed) { + ret = avcodec_copy_context( + output_files[ost->file_index]->ctx->streams[ost->index]->codec, + 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;