From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EDF694246C for ; Wed, 16 Mar 2022 14:35:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3488F68AE77; Wed, 16 Mar 2022 16:35:40 +0200 (EET) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C11C2680545 for ; Wed, 16 Mar 2022 16:35:33 +0200 (EET) Received: by mail-wr1-f52.google.com with SMTP id h23so2652305wrb.8 for ; Wed, 16 Mar 2022 07:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quanteec-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to :content-language:content-transfer-encoding; bh=djcMauL4xCBArPBIIP7dAqFs+7nPDKYGQHkH7BX2gjk=; b=F0D+3y1kRXnByWW74m6YLMA7XfKvL+EQ6BhTBvRkwFkuEfrOdBGHniBop3N5ME7diK iE/+DmiCMFwB5RlgK82cZ6ZGjhl92X8mSQfBDQSmIu5Ij1rZTFXndfQBQ4zwgWQ9q1yv rvz2WKl2qVRcBNkt1xObfDu2aJAWeGR1zHxtd+mKCKbtQ64cBO1slxVQrayJcrjcoOIy oOatGUJNBah9pKlAuLK/L/dcYheNV7u2bYTqWbdEDkk7hVZq1KQgOcgmZVM8pV/GgWBP s5lfrG6fklc2iOscptSBtROkN9vGsHPCTGqSHq2XwYbjP+uBGWH3W+/pykCZ1S/YFd5X VLBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:content-language:content-transfer-encoding; bh=djcMauL4xCBArPBIIP7dAqFs+7nPDKYGQHkH7BX2gjk=; b=bPBwnmAJNYkYFQvEaxLjt6KXsZQ3Ohuiq0wKNWCO3CtEdXj/NyDkE5D63XIjiIgB9B WoJ7aV10937JyZGzQG/U+rg8u7bkbtMaMA5jvD5UFy2BxRU2+/mwBwBUYZtUr9ZSRPN4 gn9HCUG4ZlKZ0QePD7QsbZiQ+gMgobzX5/hJy8a7deaYnQ2BhdNVGUMBzkRGktMFLstB qVy2+H+i0H3M8P1F/0Je1Yy1v9HaEa51ONLpvyzGsjcrVDOvk8wcR+97k4+6yXTFOvmm 9k/VoZU1Y3/l8vBfXcWiXumlHpFzNoMDYDYmFBuymsE+mps3eqaCvYW8Nyu+bBmW0TSq hYjA== X-Gm-Message-State: AOAM533TETiJj3IF3S7i2Ydk9eBPhe3mj7oykK92YEqnSrpfgtQTC/vb dFV2KFvpzhn+Pqv927oVj2xX+B2B2+ZC X-Google-Smtp-Source: ABdhPJwSb1bsUvm59RL3Ofw1UfVYLRy2FxWqHdSbSGC5kI4yL8/7vZIwSoaHIupgLLFwyTfbGnKvWQ== X-Received: by 2002:a05:6000:2a3:b0:203:77ad:dfa0 with SMTP id l3-20020a05600002a300b0020377addfa0mr178457wry.517.1647441329209; Wed, 16 Mar 2022 07:35:29 -0700 (PDT) Received: from [10.0.9.0] (fs-141-0-204-250.fullsave.info. [141.0.204.250]) by smtp.gmail.com with ESMTPSA id l18-20020adfe592000000b001f064ae9830sm1798464wrm.37.2022.03.16.07.35.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Mar 2022 07:35:28 -0700 (PDT) Message-ID: Date: Wed, 16 Mar 2022 15:35:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 From: Mathias Lacaud To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] libavformat/dashenc: add an option to the dash muxer to create smaller manifests during live streams X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Add an option 'live_window_size' which sets the maximum number of segments kept in the manifest during the transcoding. At the end, all of the segments are written in the manifest. Ignored if window_size is not set to 0. This option may be used to create smaller manifests during live streams and then get the full manifest at the end for offline replay. Signed-off-by: Mathias Lacaud (mlacaud) --- doc/muxers.texi | 2 ++ libavformat/dashenc.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 1af603b7f6..0153a069ff 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -277,6 +277,8 @@ Set the type of interval for fragmentation. Set the maximum number of segments kept in the manifest. @item extra_window_size @var{size} Set the maximum number of segments kept outside of the manifest before removing from disk. +@item live_window_size @var{size} +Set the maximum number of segments kept in the manifest during the transcoding. At the end, all of the segments are written in the manifest. Ignored if @var{window_size} is not set to 0. Use this option to create smaller manifests during live streams and then get the full manifest at the end for offline replay. @item remove_at_exit @var{remove} Enable (1) or disable (0) removal of all segments when finished. @item use_template @var{template} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 9a97838f5c..f381b47aab 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -148,6 +148,7 @@ typedef struct DASHContext { int nb_as; int window_size; int extra_window_size; + int live_window_size; int64_t seg_duration; int64_t frag_duration; int remove_at_exit; @@ -493,12 +494,15 @@ static void get_hls_playlist_name(char *playlist_name, int string_size, } static void get_start_index_number(OutputStream *os, DASHContext *c, - int *start_index, int *start_number) { + int *start_index, int *start_number, int final) { *start_index = 0; *start_number = 1; if (c->window_size) { *start_index = FFMAX(os->nb_segments - c->window_size, 0); *start_number = FFMAX(os->segment_index - c->window_size, 1); + } else if (c->live_window_size && !final) { + *start_index = FFMAX(os->nb_segments - c->live_window_size, 0); + *start_number = FFMAX(os->segment_index - c->live_window_size, 1); } } @@ -517,7 +521,7 @@ static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, int i, start_index, start_number; double prog_date_time = 0; - get_start_index_number(os, c, &start_index, &start_number); + get_start_index_number(os, c, &start_index, &start_number, final); if (!c->hls_playlist || start_index >= os->nb_segments || os->segment_type != SEGMENT_TYPE_MP4) @@ -645,7 +649,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatCont { DASHContext *c = s->priv_data; int i, start_index, start_number; - get_start_index_number(os, c, &start_index, &start_number); + get_start_index_number(os, c, &start_index, &start_number, final); if (c->use_template) { int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE; @@ -2010,7 +2014,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream) if (c->global_sidx) { int j, start_index, start_number; int64_t sidx_size = avio_tell(os->ctx->pb) - file_size; - get_start_index_number(os, c, &start_index, &start_number); + get_start_index_number(os, c, &start_index, &start_number, final); if (start_index >= os->nb_segments || os->segment_type != SEGMENT_TYPE_MP4) continue; @@ -2361,6 +2365,7 @@ static const AVOption options[] = { { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "window_size", "number of segments kept in the manifest", OFFSET(window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E }, { "extra_window_size", "number of segments kept outside of the manifest before removing from disk", OFFSET(extra_window_size), AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX, E }, + { "live_window_size", "number of segments kept in the live manifests (only if window_size is set to 0)", OFFSET(live_window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E }, { "seg_duration", "segment duration (in seconds, fractional value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 5000000 }, 0, INT_MAX, E }, { "frag_duration", "fragment duration (in seconds, fractional value can be set)", OFFSET(frag_duration), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E }, { "frag_type", "set type of interval for fragments", OFFSET(frag_type), AV_OPT_TYPE_INT, {.i64 = FRAG_TYPE_NONE }, 0, FRAG_TYPE_NB - 1, E, "frag_type"}, -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".