From patchwork Wed Dec 5 06:18:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 11282 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 E21D944CF89 for ; Wed, 5 Dec 2018 08:19:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92D4F68A257; Wed, 5 Dec 2018 08:18:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i252.smtp2go.com (a2i252.smtp2go.com [103.47.204.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 97B0068A256 for ; Wed, 5 Dec 2018 08:18:45 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1543991639; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=Pg+vOHz4UKf9T+Xp2b+mrUxCc3C2JjFVXdDZ7xqgqV8=; b=U1vMzhOr ZUYqwVIFOiqzJ1xKebC3ZZ+BvxRHe+0Zhs1kA3mkJBoe8ekmJLjAdICnokApw10hRChgFjHuOZodP girSr5ecbjGtYCqKPu4Mp7qLRT94M4h8y7Ch3HPIo5YMLnqaAM736HY4LPbKWDQiLpqpSbO5+nvb+ p5yXzYOFIw3nRY1CBWuRSvBOAKyw0FRA1fEWQVjQhFxV/x4xXLridt3AekKcrselGrkSP1q8XfoSc 8to/Xrh1Qs7R78dkBcsswI8EasOt5PM6PVlmm5YQZBJYEww55TeWdznVnbKK33SjJTJMjwgvGg7CL jOOaGabedSWc2sfPZQbQu1aTVg==; Received: from [10.45.79.71] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gUQWJ-095Enm-LP; Wed, 05 Dec 2018 06:18:51 +0000 Received: from [10.63.208.195] (helo=blr-mp4tf.bangalore.corp.akamai.com) by smtpcorp.com with esmtpa (Exim 4.91) (envelope-from ) id 1gUQWI-DuugNu-7c; Wed, 05 Dec 2018 06:18:50 +0000 From: Karthick J To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Dec 2018 11:48:39 +0530 Message-Id: <20181205061840.26063-1-kjeyapal@akamai.com> X-Mailer: git-send-email 2.17.1 (Apple Git-112) In-Reply-To: References: X-Smtpcorp-Track: 1glQWmDIIgNI7c.Uy3LKe5F0 Feedback-ID: 337386m:337386asVRLGB:337386smV1eFlrkX X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/movenc: Added an option to disable SIDX atom 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: Karthick J MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- doc/muxers.texi | 4 ++++ libavformat/movenc.c | 12 ++++++++++-- libavformat/movenc.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index f1cc6f5fee..ca10741900 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1325,6 +1325,10 @@ more efficient), but with this option set, the muxer writes one moof/mdat pair for each track, making it easier to separate tracks. This option is implicitly set when writing ismv (Smooth Streaming) files. +@item -movflags skip_sidx +Skip writing of sidx atom. When bitrate overhead due to sidx atom is high, +this option could be used for cases where sidx atom is not mandatory. +When global_sidx flag is enabled, this option will be ignored. @item -movflags faststart Run a second pass moving the index (moov atom) to the beginning of the file. This operation can take a while, and will not work in various situations such diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 6dab5193b0..3781a32895 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -75,6 +75,7 @@ static const AVOption options[] = { { "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, @@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks, mov_write_moof_tag_internal(avio_buf, mov, tracks, 0); moof_size = ffio_close_null_buf(avio_buf); - if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) + if (mov->flags & FF_MOV_FLAG_DASH && + !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size); if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB) @@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) * the next fragment. This means the cts of the first sample must * be the same in all fragments, unless end_pts was updated by * the packet causing the fragment to be written. */ - if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) || + if ((mov->flags & FF_MOV_FLAG_DASH && + !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) || mov->mode == MODE_ISM) pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts; } else { @@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s) s->flags &= ~AVFMT_FLAG_AUTO_BSF; } + if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) { + av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n"); + s->flags &= ~FF_MOV_FLAG_SKIP_SIDX; + } + if (mov->flags & FF_MOV_FLAG_FASTSTART) { mov->reserved_moov_size = -1; } diff --git a/libavformat/movenc.h b/libavformat/movenc.h index fe605d1ad2..68d6f23a5a 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -257,6 +257,7 @@ typedef struct MOVMuxContext { #define FF_MOV_FLAG_SKIP_TRAILER (1 << 18) #define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19) #define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20) +#define FF_MOV_FLAG_SKIP_SIDX (1 << 21) int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);