From patchwork Fri Feb 22 06:55:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joepadmiraal X-Patchwork-Id: 12139 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3D95944968A for ; Fri, 22 Feb 2019 08:55:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 27B7D689D2F; Fri, 22 Feb 2019 08:55:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D62F689D1A for ; Fri, 22 Feb 2019 08:55:34 +0200 (EET) Received: by mail-ed1-f53.google.com with SMTP id f2so863932edy.13 for ; Thu, 21 Feb 2019 22:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=exmachina-nl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k5HXWAVGfkbiYDzydGNi05UVo51FwyLMIsw8UYfgLOI=; b=IcJ1T6OB2PBcuf/awjAxXVb3zpr3qnTc+ej+GVTt2jKowcDmH5XH7N2mDINiReC26Z ZCzOrbnU4ZiRylhEWlPvttDVsvdSH9Qa2Djp4epp+J/iJ5PvBx35l02GDhGo0RSuKdk4 oCeno4918Kk9vGjHr/lpJqwryIQeKS1Kq/D7ScJH5nxX17b9QmOlt1HN7AnbuwKkIt5k jfclR4ADJt9TYHrN82/UmJJdvPV+htWQApnV/w6qJkcyRDC61nEIM/s99AMVwx8uA2vx wvPjct7RFC+zXPdAP91sOIJygNGYAkbN0Ut9sWVIs6e7AQuxHWFUy799nfYEyLhagV9D EK8w== 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:in-reply-to :references; bh=k5HXWAVGfkbiYDzydGNi05UVo51FwyLMIsw8UYfgLOI=; b=uVufFxE9Tj1nUPUAlceLW32/ed02hfe9YHWNUbk+Lf37JrkhrMqc+Yb8UG4TE9kS3A cLsGg2UzHXKyVyMwWPPEw5qIeOdpU0dsYiJProQHf1g8rOLb6JFQgLoieHeMCsFUhybc byPJssj23E965KLfSNq3qkdEzhJkJ6wpfxo3HtSQ86gdHYJaP+FZO14cFvch4p9KirU1 xamp4CtPNtsIO64ZGXiKkgdgAOzb7hrROjq9A/quH+RNlqBJANckArA72/EOKw5ZDg51 lNLjiPJ0YtzC7IDWACHIq90ofdsxayTAjFwmlbOrdAn7aQUC717aM8AH0IM4DHNglfdz kzbw== X-Gm-Message-State: AHQUAuaxRi0bzcWg24HSDkhdl318y+zBjYs7VeOcZHGyCwDaa6EL8sS1 YoC3RBnLc9gQ57NFS4HRXqo9sPCcwR8= X-Google-Smtp-Source: AHgI3IZNjhVm3y5a0y8kG+Ugcr4TakQwBspq1eKQ8Lk26OvoJkPGhgrBb6Sq7SiDZJqPXSOCrtW+Qg== X-Received: by 2002:a17:906:190f:: with SMTP id a15mr1755528eje.231.1550818533505; Thu, 21 Feb 2019 22:55:33 -0800 (PST) Received: from deepin-joep.localdomain (mail.lemz.net. [89.255.38.58]) by smtp.gmail.com with ESMTPSA id t9sm178415edd.25.2019.02.21.22.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 22:55:32 -0800 (PST) From: joepadmiraal To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Feb 2019 07:55:20 +0100 Message-Id: <20190222065520.30427-2-joep@exmachina.nl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190222065520.30427-1-joep@exmachina.nl> References: <20190222065520.30427-1-joep@exmachina.nl> Subject: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists 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 Cc: joepadmiraal MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: joepadmiraal --- libavformat/dashenc.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 37a7547b12..d0d0d6f030 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -122,6 +122,7 @@ typedef struct DASHContext { int64_t last_duration; int64_t total_duration; char availability_start_time[100]; + int64_t start_time_ms; char dirname[1024]; const char *single_file_name; /* file names as specified in options */ const char *init_seg_name; @@ -432,6 +433,8 @@ static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, const char *proto = avio_find_protocol_name(c->dirname); int use_rename = proto && !strcmp(proto, "file"); int i, start_index, start_number; + time_t start_time_s = c->start_time_ms / 1000; + double prog_date_time = start_time_s; get_start_index_number(os, c, &start_index, &start_number); @@ -464,16 +467,21 @@ static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, ff_hls_write_init_file(c->m3u8_out, os->initfile, c->single_file, os->init_range_length, os->init_start_pos); - for (i = start_index; i < os->nb_segments; i++) { + for (i = 0; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; - ret = ff_hls_write_file_entry(c->m3u8_out, 0, c->single_file, - (double) seg->duration / timescale, 0, - seg->range_length, seg->start_pos, NULL, - c->single_file ? os->initfile : seg->file, - NULL); - if (ret < 0) { - av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n"); + double duration = (double) seg->duration / timescale; + if (i >= start_index) { + double prog_date_time_copy = prog_date_time; + ret = ff_hls_write_file_entry(c->m3u8_out, 0, c->single_file, + duration, 0, + seg->range_length, seg->start_pos, NULL, + c->single_file ? os->initfile : seg->file, + &prog_date_time_copy); + if (ret < 0) { + av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n"); + } } + prog_date_time += duration; } if (prefetch_url) @@ -1583,9 +1591,12 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) os->first_pts = pkt->pts; os->last_pts = pkt->pts; - if (!c->availability_start_time[0]) + if (!c->availability_start_time[0]) { + int64_t start_time_us = av_gettime(); + c->start_time_ms = start_time_us / 1000; format_date_now(c->availability_start_time, sizeof(c->availability_start_time)); + } if (!os->availability_time_offset && pkt->duration) { int64_t frame_duration = av_rescale_q(pkt->duration, st->time_base,