From patchwork Sun Aug 15 15:07:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arzet Ro X-Patchwork-Id: 29537 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1289058iov; Sun, 15 Aug 2021 08:07:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcS02OQJcG71K6rHyLN/5UcCGsBrlx+oKe72mvaJ6hup/Xy9A/bnOb7Lb9DBhIyF6dlsRP X-Received: by 2002:a05:6402:27d1:: with SMTP id c17mr14792883ede.178.1629040076733; Sun, 15 Aug 2021 08:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629040076; cv=none; d=google.com; s=arc-20160816; b=w01l8/fH0W8dqYHYbGDZ/ua+MeG777VB8FKlIoW2qtDH0Isze3R/0P0SOoPpq67DGq wsJMDWJzEgOgfvYQh6TX8Gycq/9sebkOPFlheYTpNpxYS0n6u5fTx6uk4CDGJjXrUHCo PefBt9M5pyZWtXuVIHdOW1R6/s9gUvHGtiJFFoIQ0j9illyXrcnwYGhgB4GS9Aj8qHY8 doaCrX//vclKJo4feWtKXOT2HqDP9GKm7UlX/g/KGkmgMEfRu2E3MQazW9fzN7ptAcg2 uGteSC8ljCSy3vbka1Limw6q+VkV33ZMKvtWTimfLD5Hsx/dKBSCl5dTh7r/o0yhPtlC fYXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=iEh95y2JGzShktu20lBV7rSd1jzK1/S0AUkHa1BbIfE=; b=kof2pXYOEPHCkPdJDodM77C5EHSLOHmJbUoGFfhd1Fe7AFso17nn827NgRCMbDxgey 2/rMkZ8HogD4pF3QQDctEp3MDYsD6EIu0fE5VdeapfWcKBRlgZkv9JDLyzEQL/x3Hui+ XFina846UQCSUIZUk3Z+opUO86KB388qN+KJUzH52AAnL3jbCDNbUBGXsA6N3mFeP6DN +u6KRkGWjz5PxGQI7W8+lzXNa+EkYeQecvOzNVW2RbeGZwU+Nt/EKnYOU2UcpHu/gVpZ JNiIvervJlFUBEcPDWuh5tSsT+g4IYmek227VjyNa3Kz/FkwDRIFfKBn07yCoRmPqlrI 27DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="fJ/fNCOo"; 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 g5si1940098ejo.390.2021.08.15.08.07.55; Sun, 15 Aug 2021 08:07:56 -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="fJ/fNCOo"; 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 EA84268A2C6; Sun, 15 Aug 2021 18:07:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E093E6808A0 for ; Sun, 15 Aug 2021 18:07:45 +0300 (EEST) Received: by mail-lj1-f173.google.com with SMTP id n6so23301138ljp.9 for ; Sun, 15 Aug 2021 08:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n0xgUPZekAN+LOPF/0XDwppq5nyuzJCsgrvExTEiMRs=; b=fJ/fNCOo1WMAUdbOXBFi3AUQCQBAPplW6ba/eEuD9cI9xJAakxr2ftjTeaCf0wXEL0 WM+WPL6Up9KJsg8y5jn0AKyONiqEw62yPLhFYqBAKMrjMQ2XpacCHQ9rG0I1+iCYE8Pf vY/mz8o1TOt1iVySWvYs/r7hZGo0aF9HrHpqcqnliGr3at64Yx7vykd508wrQdHDsYs+ +5h6vK3vyUcJWFZgqLqe4TAKhFRH20PWqwsoo7w2JMFw/KWjcdHg7Ri8wIA3zpYnspRa sCwgx+ZW4INdhVVdECDbl7M0H5xJShN1tduGIGUjsM4ncc5VzqO6pHSGgfFiTfLAh2wL Ny+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n0xgUPZekAN+LOPF/0XDwppq5nyuzJCsgrvExTEiMRs=; b=jzd5PXQ5q24pdWo4InekPTNhNzUxLo5sASMDGhr3pyspHI6+YL62P8VgiPU1pvzEbi wvMEcQwJZfLFigiilaERivE2yDKEds0CMt/h7Qi/+6JGnrDStqBv6PH/e95CYbdCwRvH n3RNnE2YcM4MCIdv01M8IpuKrGW81LpcsigRcmyUAgJXDB+/08r408a2BRLseiBStShh V+TI24ItEHFwZrZFbRSrqW/+mlJOW6MHo1Rk64b9CrGkNjTkph1LcdYXNYBJMdIp5K4+ HxZ6+yPiFnDRCK4aSWVpFnuP9RXVypK3i2wYuvMzTlSdHPsoiWxcFyYZD6qC3mNFcPMD Mfug== X-Gm-Message-State: AOAM532fnYdK4hYScYgQxDuyszE5LhahNWfERO/5Xt7Xoje+I8guV+KA yPphZFQmxEgfkrGYrLRWd/KcaHelAFg= X-Received: by 2002:a2e:7814:: with SMTP id t20mr726633ljc.13.1629040065043; Sun, 15 Aug 2021 08:07:45 -0700 (PDT) Received: from localhost.localdomain ([2a01:540:22cf:3400:ae89:c945:165:32a]) by smtp.googlemail.com with ESMTPSA id q26sm284850lfn.149.2021.08.15.08.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 08:07:44 -0700 (PDT) From: Arzet Ro To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Aug 2021 20:07:11 +0500 Message-Id: <20210815150711.1152650-1-arzeth0@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] avformat/hlsplaylist: Support FRAME-RATE attribute 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 Cc: Arzet Ro Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kTA0e9kwF54/ https://datatracker.ietf.org/doc/html/rfc8216#page-31 Signed-off-by: Arzet Ro --- libavformat/hlsplaylist.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c index 0e1dcc087f..c3ec86f2ab 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -81,9 +81,32 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, } avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth); - if (st && st->codecpar->width > 0 && st->codecpar->height > 0) + if (st && st->codecpar->width > 0 && st->codecpar->height > 0) { avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width, st->codecpar->height); + if (st->avg_frame_rate.num > 0) { + // In an ideal world #EXT-X-VERSION should be >=7 if we want FRAME-RATE + // according to + // https://developer.apple.com/documentation/http_live_streaming/about_the_ext-x-version_tag + // But we can ignore that because: + // https://datatracker.ietf.org/doc/html/rfc8216#section-6.3.1 + // "To support forward compatibility, when parsing Playlists, + // clients MUST ignore any attribute/value pair + // with an unrecognized AttributeName.". + + + // https://datatracker.ietf.org/doc/html/rfc8216#page-31 + // "The value is a decimal-floating-point describing the maximum frame + // rate for all the video in the Variant Stream, rounded to three + // decimal places." + + // Also, iOS and tvOS refuse to play the content if VIDEO-RANGE is + // present but FRAME-RATE is missing. + // Although at this moment + // VIDEO-RANGE attribute is not implemented in FFmpeg. + avio_printf(out, ",FRAME-RATE=%.3f", av_q2d(st->avg_frame_rate)); + } + } if (codecs && codecs[0]) avio_printf(out, ",CODECS=\"%s\"", codecs); if (agroup && agroup[0])