From patchwork Tue Mar 5 14:37:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joepadmiraal X-Patchwork-Id: 12198 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 A6DDA447965 for ; Tue, 5 Mar 2019 16:45:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 803B068A415; Tue, 5 Mar 2019 16:45:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51A7668A3FA for ; Tue, 5 Mar 2019 16:45:38 +0200 (EET) Received: by mail-ed1-f49.google.com with SMTP id f19so7412816eds.12 for ; Tue, 05 Mar 2019 06:45:38 -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=Zk4pOvL/CnVwXzkTVyXywVX5kpdmeFt3q2fn3rWWAiI=; b=S9ocZND/tSpcDA6gEQoL/QbKpcJUMz7da9B9RJqYqAh+DiPOsjLLTLzrA1rTKaDftU vP9QzFyFbMZ+AcPhGstwj0wnoQTDnECTRriwMOjtz3kH4ORtIK6m6dF5ls7pvwbryDHV Vp1ZP5y9UGbbhy5bf2IqXP4sQO9bgtNBtRldhqSN2Dx7YJPJK3WXMlMMvCIti7xxmcCX HHEgIcRGZghgSZipbjPN4Ip0D909UVFt6y99fhbdrFPeHWXyynCAPlEhoS5Zc203UtOH rOsalPYyUPwe+9Wfn5bhZc2/fQviDe+StCh/E/iydjXjwvomYJJg3sh0R3DDNwEDZgTs p4Ig== 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=Zk4pOvL/CnVwXzkTVyXywVX5kpdmeFt3q2fn3rWWAiI=; b=nWsceFLVrPf88dBiptuDPSAawY/eHZz1N/2xbq31buZXx+ihwGrjd6RWeNAn2uHefZ Dj7VC4vj9MwKbi+0gnCq/PZF9DohENPrv/zo/os017zGvyI6ILTCxNFhvQ1hAvZCzU6W zb8wg+DUGw9yxXUSMX61UPXCVVM2v3JhgsmN8uPiZV9DDwjfOv8qYZpfVxcI0zodqsJD gOsaLmYVVL7Bc8ksqwriM5cRQsAEaNJpl275HOsfy4n7k6bjRAG1y9b7y8WZa/4mpkkx aKmK6db9qAEZoATFfx7WtPG3oV0o1v1utaf9h+ZCvMAG7B1KNT12C0VKZquajdtZxzJr ZiBw== X-Gm-Message-State: APjAAAWXItFGkPXEhYh9sJW8TKOtUhaBDo5hDi4X8sGYE/dFs4Sa/uTG 6ZAC1XLtWWE79f+eDuKMgzsrpXUgj8EDMA== X-Google-Smtp-Source: APXvYqy78zMzHDbD1h4uYeB5Bh/PEzmkhbbFOoZLelxzXXDckZqx5/Xp+/TU5RzDGkhxEbPZf00KeQ== X-Received: by 2002:a50:9984:: with SMTP id m4mr20020293edb.279.1551796642139; Tue, 05 Mar 2019 06:37:22 -0800 (PST) Received: from deepin-joep.localdomain (546A2688.cm-12-3a.dynamic.ziggo.nl. [84.106.38.136]) by smtp.gmail.com with ESMTPSA id m13sm1503965ejb.17.2019.03.05.06.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 06:37:21 -0800 (PST) From: joepadmiraal To: ffmpeg-devel@ffmpeg.org Date: Tue, 5 Mar 2019 15:37:10 +0100 Message-Id: <20190305143710.31379-2-joep@exmachina.nl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190305143710.31379-1-joep@exmachina.nl> References: <20190305143710.31379-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" --- libavformat/dashenc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index c5e882f4ae..6bcdc9ba36 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -61,6 +61,7 @@ typedef struct Segment { int64_t start_pos; int range_length, index_length; int64_t time; + double prog_date_time; int64_t duration; int n; } Segment; @@ -122,6 +123,7 @@ typedef struct DASHContext { int64_t last_duration; int64_t total_duration; char availability_start_time[100]; + time_t start_time_s; char dirname[1024]; const char *single_file_name; /* file names as specified in options */ const char *init_seg_name; @@ -433,6 +435,7 @@ 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; + double prog_date_time = 0; get_start_index_number(os, c, &start_index, &start_number); @@ -467,11 +470,20 @@ static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; + + if (prog_date_time == 0) { + if (os->nb_segments == 1) + prog_date_time = c->start_time_s; + else + prog_date_time = seg->prog_date_time; + } + seg->prog_date_time = prog_date_time; + 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); + &prog_date_time); if (ret < 0) { av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n"); } @@ -1592,9 +1604,13 @@ 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(); + int64_t start_time_ms = start_time_us / 1000; + c->start_time_s = start_time_ms / 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,