From patchwork Tue Jan 21 23:12:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17463 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C33A244BE68 for ; Wed, 22 Jan 2020 01:13:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9610268AE9B; Wed, 22 Jan 2020 01:13:00 +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 B7C8F6883C5 for ; Wed, 22 Jan 2020 01:12:54 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7EE9BE3AE1; Wed, 22 Jan 2020 00:12:54 +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 lSsQ4ro2eDHU; Wed, 22 Jan 2020 00:12:52 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 19E49E3A8A; Wed, 22 Jan 2020 00:12:52 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 00:12:43 +0100 Message-Id: <20200121231243.26529-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix hls_ts_options with mpegts 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" Was broken since cdbf8847ea97a985dfd55432e1384bb7fe5d2d3b. Signed-off-by: Marton Balint --- libavformat/hlsenc.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 2b3d3742d9..87b861d437 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -764,6 +764,7 @@ static int hls_mux_init(AVFormatContext *s, VariantStream *vs) AVFormatContext *oc; AVFormatContext *vtt_oc = NULL; int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0); + int remaining_options; int i, ret; ret = avformat_alloc_output_context2(&vs->avf, vs->oformat, NULL, NULL); @@ -852,21 +853,25 @@ static int hls_mux_init(AVFormatContext *s, VariantStream *vs) return ret; } + av_dict_copy(&options, hls->format_options, 0); if (hls->segment_type == SEGMENT_TYPE_FMP4) { - int remaining_options; - - av_dict_copy(&options, hls->format_options, 0); av_dict_set(&options, "fflags", "-autobsf", 0); av_dict_set(&options, "movflags", "+frag_custom+dash+delay_moov", AV_DICT_APPEND); - ret = avformat_init_output(oc, &options); - remaining_options = av_dict_count(options); - av_dict_free(&options); - if (ret < 0) - return ret; - if (remaining_options) { - av_log(s, AV_LOG_ERROR, "Some of the provided format options are not recognized\n"); - return AVERROR(EINVAL); - } + } else { + /* We only require one PAT/PMT per segment. */ + char period[21]; + snprintf(period, sizeof(period), "%d", (INT_MAX / 2) - 1); + av_dict_set(&options, "sdt_period", period, 0); + av_dict_set(&options, "pat_period", period, 0); + } + ret = avformat_init_output(oc, &options); + remaining_options = av_dict_count(options); + av_dict_free(&options); + if (ret < 0) + return ret; + if (remaining_options) { + av_log(s, AV_LOG_ERROR, "Some of the provided format options are not recognized\n"); + return AVERROR(EINVAL); } avio_flush(oc->pb); return 0; @@ -1683,15 +1688,8 @@ static int hls_start(AVFormatContext *s, VariantStream *vs) } } if (c->segment_type != SEGMENT_TYPE_FMP4) { - /* We only require one PAT/PMT per segment. */ if (oc->oformat->priv_class && oc->priv_data) { - char period[21]; - - snprintf(period, sizeof(period), "%d", (INT_MAX / 2) - 1); - av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0); - av_opt_set(oc->priv_data, "sdt_period", period, 0); - av_opt_set(oc->priv_data, "pat_period", period, 0); } if (c->flags & HLS_SINGLE_FILE) { set_http_options(s, &options, c);