From patchwork Wed Jul 25 23:51:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 9794 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1381622jad; Wed, 25 Jul 2018 16:58:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeCfnnODXGNrg60UBHGfKEqpZzRYiaThcye0IIlUDLwNq+mpZhvZWHm+7YQlxvtse+utpfb X-Received: by 2002:adf:8296:: with SMTP id 22-v6mr15471228wrc.252.1532563139090; Wed, 25 Jul 2018 16:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532563139; cv=none; d=google.com; s=arc-20160816; b=UEeooFIIE1cdsEXU0vzyoHlyk2lSadQCnNHJKrWCVVrSApxBYHBLeCbQmqpuYbywvY iH5BqJhAT+ncF8aoi3mpc78W9ziRGXnDCop/NLYXpWU2VbsskgBCxzXBQD2bT3byU3bN TIr++d0nJl5RErbSk13VF06EXg1vCJnzczBdyHelO4WI1O38KLHNru7K8kld1PsWD565 NujU7LRnJRMl8ihL/u0hQU6nOU2By9jle9uVYXGOUNcDaYkJqMCKR573LH1pQPb5/zH0 ULSca9w3X4Yd0zIG3V/pbLfJ7CcK/zD3UhzF2lna9L33ASjxFbxFKAX1gigoK1UGLemI MhiA== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=c/4aJjMw6AXvnAJRZlHJbivMYjgbSL5t/XlqtkBMq0k=; b=r2mExxsbGtui9OX1Eu+2dM6PfqfiCUIYBt0JHNL0lp+Bcj4Q2IXKpfIX7a1fJHO/43 rUD4YCp4GKCo3HoIHVmncV3fIaDzhPZHzHM6dA5yJWWF1aAdpQU6mQjimDp4YFLz6giP 9C/DlRav/QpOoAv6S9W4BJIrwKvaYTg3jB9/pUlY+ErGy8HcI4dK1gJ55nOh9nrloOXa k3yA55cWibgKx0tOetQg9VHL6cGQcw265h8+spmAuJvs2FXYwLqciv2zRzDYXi6vu5rs 3Y8Af9saRuMrT18P0z2LHzbw7On1oL6JYtRp6xyzIAJmGTC4i9kY5tKbomnl8IkclR5B /U8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="oZOYdM4/"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c5-v6si11576147wro.358.2018.07.25.16.58.58; Wed, 25 Jul 2018 16:58:59 -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=@gmail.com header.s=20161025 header.b="oZOYdM4/"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E32F68A3E2; Thu, 26 Jul 2018 02:58:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D3AD68A351 for ; Thu, 26 Jul 2018 02:58:40 +0300 (EEST) Received: by mail-lj1-f174.google.com with SMTP id v9-v6so8185515ljk.4 for ; Wed, 25 Jul 2018 16:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Y5cf3W2ilzbKTVRSYoMX8C1aNB/FA42Zc8cMfZzmodU=; b=oZOYdM4/SNoFrBy4JuEzyYU2PgJ1yiPAFQ4FQstVTenBkD77vyo/dq4bRiVPKfOxOI TlDbiv2FT8YIPYaTbOBR1xAYNMh2PQXsM33zeoVMexgdtKV21UkENZLklIqAnhduknFN ruhkfSYEshGq44e7eH3bvCeziDEXdM90ME1K8atTdEfEE80vuSe9sBbUDmh9FNvk/kN6 4sf6kLM+jmZGbPxcH/O3+hUkZU4BwXotjXwa0WDNnMhZZk7/EdYrSt+kZt5b2wS1fL9V IWMu92Mv7iTUfypHQa27Y0OpwCgRvck45yjxof50U3lcz4cb6I2nL3ot07P3Zk3b07Fh bCCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Y5cf3W2ilzbKTVRSYoMX8C1aNB/FA42Zc8cMfZzmodU=; b=Hx0Do3x5X10o8WL1tkByddWy6J2fE1wpzFIoBnUtg/+Cq3BBYAmo98KKOhRdnwDYLs qzGAH4r35AW53wcA5XCGcIJbhn8cx8UlTODlqb3LfGwxon8qvSnIS+FQ0FXWRF8iOui2 hlgmwoxzNyaRt+y5qDFwFbksX2S6zAIQ1EM7LUJFEs5Ruo5YL/j0CSEAD9n7tmSgQzI4 sZBc9Qe9bq4mfL7pa6iDT6fPOcCkwAQIHkxWunEkDdpNE/wz+B7K2Y5tAlLZj2H3bsKr eL5vhVgUZlwRRJVPGSPylrkJfWqVnTx7fbd9L/FmgIbG1UFQotrLfHlz+l3KLnvAZmkt 75qw== X-Gm-Message-State: AOUpUlHP8lEF27CwaHcrO2h5s8cOdYCH4qySvtojqmly8ZwPaLR4R7Jt sAHp60plL7gXNyYCKTAzgkBqh+u7 X-Received: by 2002:a2e:5bc8:: with SMTP id m69-v6mr17842756lje.115.1532562700962; Wed, 25 Jul 2018 16:51:40 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id h24-v6sm2994673ljg.55.2018.07.25.16.51.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 16:51:39 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Jul 2018 02:51:38 +0300 Message-Id: <20180725235138.27380-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avformat/movenc: implicitly enable negative CTS offsets for ismv 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ISMV lacks any sort of edit list support, as well as tfxd is effectively the PTS of the fragment for most intents and purposes. Thus, if b-frames are requested without negative CTS offsets you end up with N frames' worth of delay (tfxd PTS plus the CTS offset of the first sample). Negative CTS offsets enable the first sample to have CTS=DTS, and thus a/v desync due to b-frame reorder delay is avoided. --- doc/muxers.texi | 2 ++ libavformat/movenc.c | 2 +- tests/ref/fate/movenc | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 33f1f7bbaf..268c152023 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1344,6 +1344,8 @@ be negative. This enables the initial sample to have DTS/CTS of zero, and reduces the need for edit lists for some cases such as video tracks with B-frames. Additionally, eases conformance with the DASH-IF interoperability guidelines. + +This option is implicitly set when writing ismv (Smooth Streaming) files. @item -write_prft Write producer time reference box (PRFT) with a specified time source for the NTP field in the PRFT box. Set value as @samp{wallclock} to specify timesource diff --git a/libavformat/movenc.c b/libavformat/movenc.c index d530f40cab..14f85eb2a7 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6049,7 +6049,7 @@ static int mov_init(AVFormatContext *s) /* Set other implicit flags immediately */ if (mov->mode == MODE_ISM) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF | - FF_MOV_FLAG_FRAGMENT; + FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS; if (mov->flags & FF_MOV_FLAG_DASH) mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_DEFAULT_BASE_MOOF; diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 872796ebce..5e8f324ea3 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -17,10 +17,10 @@ write_data len 20, time nopts, type header atom ftyp write_data len 1171, time nopts, type header atom - write_data len 728, time 0, type sync atom moof write_data len 828, time nopts, type unknown atom - -write_data len 728, time 1013106, type sync atom moof +write_data len 728, time 1046439, type sync atom moof write_data len 812, time nopts, type unknown atom - write_data len 148, time nopts, type trailer atom - -1f37c1a8e01651e8bebcd66f00b6a226 4435 ismv +49bf122c4c732a344ef68b58acd19be5 4435 ismv write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 796, time 0, type sync atom moof