Re: [Hls-interest] Reducing latency when TARGETDURATION is conservative

Roger Pantos <rpantos@apple.com> Sat, 10 April 2021 00:27 UTC

Return-Path: <rpantos@apple.com>
X-Original-To: hls-interest@ietfa.amsl.com
Delivered-To: hls-interest@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 002193A1913 for <hls-interest@ietfa.amsl.com>; Fri, 9 Apr 2021 17:27:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.1
X-Spam-Level:
X-Spam-Status: No, score=-2.1 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=apple.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8XjlGLtp2UQL for <hls-interest@ietfa.amsl.com>; Fri, 9 Apr 2021 17:27:27 -0700 (PDT)
Received: from rn-mailsvcp-ppex-lapp35.apple.com (rn-mailsvcp-ppex-lapp35.rno.apple.com [17.179.253.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 003603A1914 for <hls-interest@ietf.org>; Fri, 9 Apr 2021 17:27:26 -0700 (PDT)
Received: from pps.filterd (rn-mailsvcp-ppex-lapp35.rno.apple.com [127.0.0.1]) by rn-mailsvcp-ppex-lapp35.rno.apple.com (8.16.1.2/8.16.1.2) with SMTP id 13A06lOC016034; Fri, 9 Apr 2021 17:27:24 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : message-id : content-type : mime-version : subject : date : in-reply-to : cc : to : references; s=20180706; bh=TW6tfFTj3Kb52x5J2OVPjw+Yu/rERxPi21jiK6c5npM=; b=ejlLVYv5AayayY54FwB28MYugHnxd9BJHwTb9oG0QCu5cNopjwgIsYv0/llN2+vvd07N VcewXNZ0c9RMwc6heQE8zAgGgqSc6/Kk45McnrphDsVIgebo+qz+N5mEwTkhf3RZqm8h TXUw85NQZKT3XwXuQ6gqEtlZnFwZeOqyBxeUe6dwdNdIBraQwcjcExmEwQfqo6GecTia 4oAg/oXDwMXAUdNWFgP1+4Y9dFQlqXfHzGgNh517ayDWvkrdkCNBhjjrCez13stKJVan p2miYdkQw2D5Sw3+ybnKaX/BqCQTFBMdum+pkQdYAcwryHzd/4cppEtypwmH/kkKh5Gt Vg==
Received: from rn-mailsvcp-mta-lapp01.rno.apple.com (rn-mailsvcp-mta-lapp01.rno.apple.com [10.225.203.149]) by rn-mailsvcp-ppex-lapp35.rno.apple.com with ESMTP id 37rvckrab2-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 09 Apr 2021 17:27:24 -0700
Received: from rn-mailsvcp-mmp-lapp03.rno.apple.com (rn-mailsvcp-mmp-lapp03.rno.apple.com [17.179.253.16]) by rn-mailsvcp-mta-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.7.20201203 64bit (built Dec 3 2020)) with ESMTPS id <0QRB00X70NXOJJ70@rn-mailsvcp-mta-lapp01.rno.apple.com>; Fri, 09 Apr 2021 17:27:24 -0700 (PDT)
Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp03.rno.apple.com by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.7.20201203 64bit (built Dec 3 2020)) id <0QRB00D00NMDZN00@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Fri, 09 Apr 2021 17:27:24 -0700 (PDT)
X-Va-A:
X-Va-T-CD: 8e2e2c6928f764e550980fed99e76b0a
X-Va-E-CD: 26951850e86656e8232e616d865a77a6
X-Va-R-CD: ebc469ce6da71928ed46b0fe03f7815c
X-Va-CD: 0
X-Va-ID: 8fad81dd-d2cd-40b3-a145-122142845227
X-V-A:
X-V-T-CD: 8e2e2c6928f764e550980fed99e76b0a
X-V-E-CD: 26951850e86656e8232e616d865a77a6
X-V-R-CD: ebc469ce6da71928ed46b0fe03f7815c
X-V-CD: 0
X-V-ID: 0a3a8a72-c696-4e1c-b8d8-33eef60a08f8
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-09_08:2021-04-09, 2021-04-09 signatures=0
Received: from smtpclient.apple (unknown [17.149.226.25]) by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.7.20201203 64bit (built Dec 3 2020)) with ESMTPSA id <0QRB00EA0NXKBI00@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Fri, 09 Apr 2021 17:27:23 -0700 (PDT)
From: Roger Pantos <rpantos@apple.com>
Message-id: <6751F9A9-CD3C-4655-BE4E-F74C7B1D7637@apple.com>
Content-type: multipart/alternative; boundary="Apple-Mail=_62547B25-1A41-4677-B534-1308B86F026E"
MIME-version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\))
Date: Fri, 09 Apr 2021 17:27:20 -0700
In-reply-to: <CAHVo=Zk_ew_jE98+1_XZQb_yi0N5az0aHHDqcuPunRFsPXMmMw@mail.gmail.com>
Cc: hls-interest@ietf.org
To: Luke Curley <kixelated@gmail.com>
References: <CAHVo=Zk_ew_jE98+1_XZQb_yi0N5az0aHHDqcuPunRFsPXMmMw@mail.gmail.com>
X-Mailer: Apple Mail (2.3654.80.0.2.43)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-09_08:2021-04-09, 2021-04-09 signatures=0
Archived-At: <https://mailarchive.ietf.org/arch/msg/hls-interest/w-COv4zsEN4XL7RjEWbOlXavKKI>
Subject: Re: [Hls-interest] Reducing latency when TARGETDURATION is conservative
X-BeenThere: hls-interest@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Discussions about HTTP Live Streaming \(HLS\)." <hls-interest.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/hls-interest>, <mailto:hls-interest-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/hls-interest/>
List-Post: <mailto:hls-interest@ietf.org>
List-Help: <mailto:hls-interest-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hls-interest>, <mailto:hls-interest-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 10 Apr 2021 00:27:29 -0000

Hello Luke,

> On Apr 6, 2021, at 1:19 PM, Luke Curley <kixelated@gmail.com> wrote:
> 
> Hey folks,
> 
> We're trying to reduce HLS latency for iOS users (AVPlayer) but we're running into a few issues. 
> 
> We don't transcode all streams, so the broadcaster is often responsible for setting the size of GOPs. While most broadcasting software will use a fixed GOP interval, like 2s for OBS, it's not a guarantee. We set a conservative value of 6s for TARGETDURATION just in case.
> 
> From our testing, 2s segments and 6s TARGETDURATION results in 18s+ latency with AVPlayer. The player seems to choose 3 * TARGETDURATION as the initial latency, which is quite excessive for our use-case.
> 
> The latest HLS RFC adds the HOLD-BACK attribute <https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-08#section-4.4.3.8>, allowing the server to choose the initial latency. Unfortunately, this attribute "MUST be at least three times the Target Duration" so it only confirms the AVPlayer behavior. I think this requirement could be relaxed without any negative impact.
> 
> There's still quite a lot of work remaining on our end to support LL-HLS. It would be great if we could reduce HLS latency while working on adding full LL-HLS support (ex. sub-segments, HTTP/2, etc).

The are some good reasons why we chose 3 * target duration as the limit for how close to play to live in a (regular-latency) HLS stream. There are a number of edge cases around joining and switching bit rates (once you’ve put your stake in the ground about how far from live you want to play). But in general, you can think of it like this: consider a stream in which all segments are the same duration as the target duration. On a continuous basis, the client must discover new segments and load those segments, subject to network variability. When joining or switching (video) streams, it must also chew through the segment to find an IDR; it’s not always at the start of the segment.

Regular HLS uses a polling mechanism to discover new segments. In the best case it discovers the new segment shortly after it is published, but in the worst case new segment discovery can be delayed by up to a target duration. It gets even worse if a caching proxy (like a CDN) is involved. Similarly, the worst case for segment download is when the segment bit rate is nearly equivalent to the network bandwidth. In that case it takes about a target duration to download the segment. 

The good news is that LL-HLS replaces polling with an event-based discovery mechanism for new (partial) segments. Blocking segment requests eliminate an extra round trip time from segment download. And the in-playlist identification of partial segments containing IDRs allows the client to make some new optimizations. These and other optimizations allow a LL-HLS player to pick a point closer to the live edge and still play reliably.

In your case, while you are working on your LL-HLS implementation, I would suggest reducing your regular EXT-X-TARGETDURATION value. (I would also encourage you to require your upstream broadcasters to commit to a GOP interval that they communicate to you.) The TARGETDURATION can be as low as the closest integer to the regular GOP duration. 

Note that it’s legal to create a segment without an IDR (as long as your playlists do not advertise EXT-X-INDEPENDENT-SEGMENTS). It’s not recommended, but in exceptional circumstances an occasional segment without an IDR will be tolerated. So you can split unusually long GOPs into multiple segments to comply with a less-conservative TARGETDURATION.


regards,

Roger Pantos
Apple Inc.