From patchwork Thu Aug 10 11:09:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Artem Skoretskiy X-Patchwork-Id: 4711 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp5857497vsu; Tue, 15 Aug 2017 11:17:01 -0700 (PDT) X-Received: by 10.28.229.197 with SMTP id c188mr2265871wmh.77.1502821021219; Tue, 15 Aug 2017 11:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502821021; cv=none; d=google.com; s=arc-20160816; b=go6m+y2Y7SM3PWjR6x4XQhcOdnecKV2lDS6b+OonZgR62cSK2rwxTCq3uPXCh5r0lJ hpqgYyPYesbwBu6B4dTRpjN3jidlv9KZd5PksSWoHiUr0IiIRLHlx6TU+fTDzw/Y8D5U +VaATzvzr2L0GM+O17fWub7PR316Ar1+b6Z5bYIQ8pAAjVM8Px2FNDvhkJ4CFOVSLoku R775ghG+o4tZTIzSxJWWCOxdQ0gcmXwFUE7IszurFZiIXk1f0f92b1t9JxC8LCK2colf qi18+UXqad+oCBgxt9lk4zvFohz10hnP27DQvDsiWed0pDlvs7y1mji15/anR/ZV4LfO 6hRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:date:message-id:mime-version:from :dkim-signature:delivered-to:arc-authentication-results; bh=OVBwGS8ZoeDM+GQckFDqnxSFSvxbhHKUROLon8t0jaQ=; b=wkFlxMWPrSyHipJ4xqdjM0RD9v9FYi17tagzKdgCHyoGXfriWhTA2IXDRVRXzWnJvn 533t1hzBlk0z12QVfI2TzboKjYNEvnVqAwuAcOwY8Nn+B+/XKt3/W6VbIqgGLXwCjwIv aiT6+tUx719m7Aezlv8xYKI2Lg0GMgAjE0GD+sC5/CM/kbaN94T10B8s1dRwbVAApEd0 6kWRzVza/Jq9O5V6kOjp+UjRnj+VCDkyXqdr7kTn8+XPvx8Nsavop9jkfMhWb2O2mkJa Q11eGV9caVGH89fRPX3/uAQIwkTex0FV0R1kgj4HH4VBIRxEAj7+/M0E5P8Dn4neXFsB rYPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Io/Z7lWT; 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=NONE 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 28si7761094wrz.143.2017.08.15.11.17.00; Tue, 15 Aug 2017 11:17:01 -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=Io/Z7lWT; 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=NONE 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 B5BCA689D6B; Tue, 15 Aug 2017 21:16:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB4E2689953 for ; Thu, 10 Aug 2017 14:09:17 +0300 (EEST) Received: by mail-wm0-f49.google.com with SMTP id f15so19336694wmg.1 for ; Thu, 10 Aug 2017 04:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=SJN/M7d969QQXtQCjon2OUIrtnl3WkOlBtLIDwpMXfA=; b=Io/Z7lWTPsFnoemmE5T14jDOFWl0qcxMzgQtW8Ts7CIK1dq2o7rwHwRJgetQfKXwxw slvFpW8+413He8E35ezw1MY6w5derTcE59cpeNhcVhU/GcSIx9CmG2ezF29COBC0qTNM Gap8Ma+WbEc+v8ML1XCzhw8REGXXA3u2fCR0vD9D9GwgLMG4rJWSs8aJL3iDaWoJk6t/ 5DZWiamMXddP3iKYvGoxYtLxEr9Hq932ccUD35Kdol0cAtASRSSSP5HDrjVIsG+rCgqy yL1EQ+q1FFhglG9QkbbalF8U9CbbLPpMGHrJR9bwXu/6Kb2iqUKamLyeySSv83D3tpjC qIiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=SJN/M7d969QQXtQCjon2OUIrtnl3WkOlBtLIDwpMXfA=; b=jFGY9qYX+QjsjH6+YCk6ozhvztHYfx1JZoQfWXhPNOJOvNVMFu3YRptw2FS2X5BAys NiSE1lThy0yokL8phaEoiaSJI/abGG9bi8256SXLI09LoV7eO4PKedGN1WordtueZY6G nuEOuTmry8yB6/yWGL6tj69Dlzpn98ymLUlVNssdnWSKSXGEGF4Op+Cik8rEfbrZnw5w xipNa7GpC7XIxEdb42T0JBrSXol5OwlE0+TVoOYbmAx6ztQmDM20ZU5lyu6iAGgsQyA2 aON61wVb6gsBFu5cfzfF7txWtN9vY+9e4+CZ6BBLb/dOT5jiHHeIXmTElVjMplltld1J UKoA== X-Gm-Message-State: AHYfb5j7fJH5PvKZtU5AwF/2t/vOqqs03yC/LbG1WSx7mYjzfH3lPAp5 d4Z1n+TzMU9ba6/Z48g= X-Received: by 10.28.139.144 with SMTP id n138mr7291130wmd.14.1502363359708; Thu, 10 Aug 2017 04:09:19 -0700 (PDT) Received: from ?IPv6:2a02:908:37a:7180:d083:1071:1bc9:bd3d? ([2a02:908:37a:7180:d083:1071:1bc9:bd3d]) by smtp.gmail.com with ESMTPSA id o82sm7028835wmg.34.2017.08.10.04.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Aug 2017 04:09:18 -0700 (PDT) From: Artem Skoretskiy Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Message-Id: Date: Thu, 10 Aug 2017 13:09:17 +0200 To: ffmpeg-devel@ffmpeg.org X-Mailer: Apple Mail (2.3273) X-Mailman-Approved-At: Tue, 15 Aug 2017 21:16:52 +0300 Subject: [FFmpeg-devel] [PATCH] Improved EXT-X-TARGETDURATION generation 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It improves EXT-X-TARGETDURATION when some chunk duration is bigger than requested -hls_time N In the current implementation, it is ceiling the value (if float part is bigger than 0.001) but it should be rounded. Specification ​https://tools.ietf.org/html/draft-pantos-http-live-streaming-22#page-49 allows both implementation, but rounding is more precise and better matches user needs (especially having in mind that HLS segmenter could generate slightly longer than requested). See conversation https://trac.ffmpeg.org/ticket/6533 --- libavformat/hlsenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 74a3249b73..1c36ae4a12 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1038,8 +1038,8 @@ static int hls_window(AVFormatContext *s, int last) goto fail; for (en = hls->segments; en; en = en->next) { - if (target_duration <= en->duration) - target_duration = get_int_from_double(en->duration); + if (target_duration < en->duration) + target_duration = (int)round(en->duration); } hls->discontinuity_set = 0;