From patchwork Thu Aug 30 06:56:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bunk X-Patchwork-Id: 10176 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp514222jap; Wed, 29 Aug 2018 23:57:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZUz/zDDf3lRhnU0vlNtFfeMWodUsDu7uEdkuYQ0plLX8ag+DHIiDR3XvUjUevfCgI2YFzr X-Received: by 2002:adf:83c6:: with SMTP id 64-v6mr6559138wre.5.1535612224617; Wed, 29 Aug 2018 23:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535612224; cv=none; d=google.com; s=arc-20160816; b=lKFjD8M4EJmwe29gAKFtBwjz2RS1fTGUeWB5pkZ/oMJpSzPE7rFHh0FUhQ7cHWFtsd PzDbbRRyJ1JRALlSxDlTY4e2sn/Zc6EaNYvWxXvEGhPk7vaeSR8ruDRLEfZZFLTbPeOc 1e/mG5mwSn1XdEBfi4DBrETiXrjAAsL6NFchdaU0BdqshwqWwfn9PGVbPvN30NCA9kBw A5ULVrUpWsVVBQ2Mmwrm1DfuoP6twnW0JxXkMNx/wMNHpOJxy627b4vdzVtyaGaYUJ83 fQHKLMTSm6tkXF6o/B8P0tnhpSXdk28MqqXbRysmt96tHdXv0eVz/NuTplYHh6uHDH5X dGIA== 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=D7HElpO3A69JULmV6OW6ojdQPG98po+SS3HeRliYJQc=; b=mYTrVLsuiIhWz2CksZccVaoudNo31kQlpbHtx9FzP+1+79wBdrJHXXWdS6wYKfsbLz Gbc1t4pNEFvCkUVdQ1Hjgrb1/k++Odk9+IglB3Y8o+9cR42r1/1kSO1PcUZ1/9s1b94R NShemMuuvoQpEJKh61rK47wmU9AgFP1O7Y5yYkNaEeGDG0DbD0hfvaLb43v3UMJTiiT/ /kQF1wgwZeWbD/W6PjC3LSQaVQvHFPyf4U72sPenKcwGGkEElRu363e4c/ZoOcMigXmI c0sgIAfPsSNrMF3W3BfucV1p2VueyTraI6Ouhi1u/pTdJsopd3LoxiHB1u4o76s9RAyl +dtQ== 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 s7-v6si5171452wrn.62.2018.08.29.23.57.04; Wed, 29 Aug 2018 23:57:04 -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 890B768015B; Thu, 30 Aug 2018 09:56:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from v1.rz.uni-leipzig.de (v1.rz.uni-leipzig.de [139.18.1.26]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 551ED689ED1 for ; Thu, 30 Aug 2018 09:56:42 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTP id 6244FE0002 for ; Thu, 30 Aug 2018 08:56:46 +0200 (CEST) X-Virus-Scanned: by amavisd-new at v1-ul Received: from v1.rz.uni-leipzig.de ([127.0.0.1]) by localhost (v1.rz.uni-leipzig.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MGxvPTkIhSFr for ; Thu, 30 Aug 2018 08:56:46 +0200 (CEST) Received: from server1.rz.uni-leipzig.de (server1.rz.uni-leipzig.de [139.18.1.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTPS id 4AC21B402B for ; Thu, 30 Aug 2018 08:56:46 +0200 (CEST) Received: from gg1.iat.uni-leipzig.de (gg1.iat.uni-leipzig.de [141.39.226.97]) by server1.rz.uni-leipzig.de (Postfix) with ESMTPS id 47CD3F2004 for ; Thu, 30 Aug 2018 08:56:46 +0200 (CEST) Received: from gg1.iat.uni-leipzig.de (localhost [127.0.0.1]) by gg1.iat.uni-leipzig.de (Postfix) with ESMTP id 2264F234998 for ; Thu, 30 Aug 2018 08:56:46 +0200 (CEST) Received: (from localhost) by gg1.iat.uni-leipzig.de (MSCAN) id 2/gg1.iat.uni-leipzig.de/smtp-gw/mscan; Thu Aug 30 08:56:46 2018 From: Michael Bunk To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Aug 2018 08:56:19 +0200 Message-Id: <1535612179-24393-2-git-send-email-bunk@iat.uni-leipzig.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535612179-24393-1-git-send-email-bunk@iat.uni-leipzig.de> References: <1535612179-24393-1-git-send-email-bunk@iat.uni-leipzig.de> Subject: [FFmpeg-devel] [PATCH 2/2] examples: Fix use of AV_CODEC_FLAG_GLOBAL_HEADER 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: Michael Bunk MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" AV_CODEC_FLAG_GLOBAL_HEADER should be set before calling avcodec_open2() to have any effect. --- doc/examples/transcoding.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index a83fa3a..e48837c 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -172,6 +172,9 @@ static int open_output_file(const char *filename) enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; } + if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) + enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + /* Third parameter can be used to pass settings to encoder */ ret = avcodec_open2(enc_ctx, encoder, NULL); if (ret < 0) { @@ -183,8 +186,6 @@ static int open_output_file(const char *filename) av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", i); return ret; } - if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; out_stream->time_base = enc_ctx->time_base; stream_ctx[i].enc_ctx = enc_ctx;