From patchwork Tue Jun 8 19:03:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin LaFlamme X-Patchwork-Id: 28174 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp151674iol; Tue, 8 Jun 2021 12:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+D28925S60jTvcyP9RAMAu7j0nAu2N+r1Gszv1vjQ2euce1wFZz9BmKEa2CqMgPMKpNNp X-Received: by 2002:aa7:cd9a:: with SMTP id x26mr7768256edv.185.1623179225363; Tue, 08 Jun 2021 12:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623179225; cv=none; d=google.com; s=arc-20160816; b=Ah5oNH+i5tSYZL1y1wy+bt1wYTZwR+EkuicLiTJqPx4UPLUSxmS8MTm0ZeESQ+tH7i CC5olJvSR03THcVWSH9jSlJsFUVBdyn0ozXtikFAfrcOWSWpzQfUgvV6+3BNY1pzKmsP 6wY8hPe5lYEKZLX+95EB++ka4VZETLZZ09fKT0tPCUwIVMNfTKCMEprrDcSuyxxbIozq effSPI7V+oIB8xlLTNdQhLKps0ZW9qG97PmW/H49YWyDaoBwxX/O9bx5vZCLip7VE9qX +fM1QeTElmUYvIWILI5skE+fyheLO0OC+60aLEA4BkiuDxomHc8lHX13XHEmoaBUbzsU koXQ== 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=T2obsk2AVuV2Ibx0Z+jFuLQ7huI0YZN9SnLZcJkZtVA=; b=XHvRfBni1yfPGskrR3kXbq6eSz8xZVIbePCjgqE0AoxcIgl1MChmCt+9FI5JQt/r5I n5T40YatEOV+9otgoKlASegeoi+22tmfhILnoQMjLEkmbSr5Zl45CKVBwuG50nY+nk8g yaMex5zfsvLYQ5vwnEvgmcwyx1Rprk3gFRZ6QWCUPkU4QESSpp6NjPbPterq6Punm+uE QeoxKTuE5RTx3Dt6Vt+FaCTKovBD46YKRgqwhNXrMW7ChBv2adK+IoLFLwroWw61/5wR xI4IQnkaAXx9qizezEt5Y7ckuobwHHgIfYMDUChgYL2ALnQEZJhSGPqeA+iwtqfsy4Sp 78BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@aiera.com header.s=google header.b=B85mF1a+; 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=aiera.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o15si416784eju.373.2021.06.08.12.07.04; Tue, 08 Jun 2021 12:07:05 -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=@aiera.com header.s=google header.b=B85mF1a+; 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=aiera.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECC876802B3; Tue, 8 Jun 2021 22:07:01 +0300 (EEST) X-Original-To: FFmpeg-devel@ffmpeg.org Delivered-To: FFmpeg-devel@ffmpeg.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B74D9680157 for ; Tue, 8 Jun 2021 22:06:54 +0300 (EEST) Received: by mail-qt1-f175.google.com with SMTP id p21so4379869qtw.6 for ; Tue, 08 Jun 2021 12:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiera.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OcYzOc2SwahMLuiuhfEmqq/M0Mf7V4ppzo5rjDP9z+Q=; b=B85mF1a+D+X+weoRfC2Otbo1NxlQ9Ang+jMs5QLdVtcwV+H1bRkAFAmWVgO9n7CAXd eqKIOtO+PWS5ufmhPHxDyYhUwkOqVXS7D1/9IaCNEK0J9Rs9WTLNt8o1393ysEvWi5Ni eJ6cmLO0YRaNZOtyrd0eCMCdshoMpguiHu6q4= 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=OcYzOc2SwahMLuiuhfEmqq/M0Mf7V4ppzo5rjDP9z+Q=; b=TPmB9SYW9G7RRmO7Ssjpo3CUJ0aWPL3m320c4MGyVaZqoIT/0mIBRnlt6GSWEhBgGP l3HgZ2NvruI3jcBnZpTps+QIcuVsePeoLLRZy+GbMIJlsP/rdvt9z6x7vui7jmSNbxkB aP/DFkL9oWhvj+bBpC4Qpo9N1D488VQZO5YZ3WPaXWnmCLJ8fdKEtlFolKENX2Yi/f1r zm2J5azaTTNUisNKx3cn8c9WAtDkMy6OzA/nQwaH+ZgKsbSQ4zhVDfVKTmYZ4o5kYvHT RMQ+ppeyjxL6Lr/Mu2Foqs5YwLkJPYFwx+qgSDderrjF2jufG0Jyq0d6TpNWOlLOETpI NvAg== X-Gm-Message-State: AOAM532YK3k4IOGG+UdiPi2vPpuXUXJISKV0GPq3luCnbbS2o//Tkaz2 MRsyyvjD2K5cVtCRQXxv77/pkxUfQ5V6KA== X-Received: by 2002:ac8:4997:: with SMTP id f23mr4389524qtq.94.1623179212958; Tue, 08 Jun 2021 12:06:52 -0700 (PDT) Received: from localhost.localdomain (pool-173-48-224-94.bstnma.fios.verizon.net. [173.48.224.94]) by smtp.gmail.com with ESMTPSA id g15sm3399309qkl.53.2021.06.08.12.06.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:06:52 -0700 (PDT) From: Kevin LaFlamme To: FFmpeg-devel@ffmpeg.org Date: Tue, 8 Jun 2021 15:03:43 -0400 Message-Id: <20210608190343.74970-1-kevin@aiera.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] dashenc: Write out DASH manifest immediately in streaming mode 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: Kevin LaFlamme Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5lrk/YFxXi2B When streaming mode is enabled with fMP4/CMAF for DASH output, the segment files are available to read by players as soon as the first byte is written instead of only after the file is fully written. The DASH manifest currently only gets written when the final write to the segment file occurs. This means that players cannot stream the first segment while it is being written. When -lhls is enabled with MP4 segments the HLS manifest is written immediately to advertise the in-flight segments. This change adds the same behavior for the DASH manifest so players can stream it immediately. --- libavformat/dashenc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 810ab22416..ea3c76b802 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -2271,6 +2271,14 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) if (ret < 0) { return handle_io_open_error(s, ret, os->temp_path); } + + // in streaming mode, the segments are available for playing + // before fully written but the manifest is needed so that + // clients and discover the segment filenames. + if (c->streaming && os->segment_type == SEGMENT_TYPE_MP4) { + write_manifest(s, 0); + } + if (c->lhls) { char *prefetch_url = use_rename ? NULL : os->filename; write_hls_media_playlist(os, s, pkt->stream_index, 0, prefetch_url);