From patchwork Mon May 10 08:22:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2788758iof; Mon, 10 May 2021 01:22:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiNPVE/O9POroolnW47PakKSSYeb4kAKUVZa8NduoikGRkMc1S5k8VpGfv0FARfcaFhdzH X-Received: by 2002:a17:906:f1d4:: with SMTP id gx20mr24196749ejb.108.1620634978528; Mon, 10 May 2021 01:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620634978; cv=none; d=google.com; s=arc-20160816; b=qbMyVEtdACicPJHMgnIUmc+8OEDVDEVZk+lGPpAIAsP2Pg2bQqzlUxZZSQjWHn25/W WBXk2WyCcd5oSf9QDENENMi8hHdwspD315RTLtogO0RmM4NuP9Whg/5rjIehwhJlUisw 00q1A8zia/IU5PoJThFMszHMibrp0SfDP0THeQd2+XTjlAGb5AVX0TC3MvP2yc7vczPR LPmxTtb8/40E2qMoRZc27bGcdDTFhcNYao7QeT9cj4OStdSwKuKBEUEkmFaozEL3oFeN crB7pLqkQjQ2RFRUiWa6OtDqMBttvBYuW6e8qw1AJPlDyjIkouBl/Gxc8nsVPo7R8rAS hrEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=E5nAIQK5mGswTytNRlSV7LZVjW6lYBV6J9mVsb5y/lQ=; b=c+rcnYVL4jXHvbUM9MuQFoSII+lD/6BGETNtZkjeQSNNk7ft2nIeigfPjfd0TEI5Qx mnwF0N8VEaqWwpC8sKxyKHKiJVBah2mBkIi8OCrUtavmm+1MZFSAN/8P8cwtzwONON4m NEghrDEDi+bzKHRKN+wMXOptztuQuNRleLgW9iQEDZ1wwSwaAooRJ2VncL+Vk/TxW4O8 IHlkt9MmqD5fx8XFrHX7DT4yhKmu90/4ds2FYHjwnyZCpERP9S3EgAxGjXqJEtDK2zNj o4Vv/fTEOp4tgpLSIKe9aM+B6I4aRS3ZnZ150G34FHN+f8Z8zxuQExCbNe8A1hDEQ0GO K4JQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z10si12958160eja.84.2021.05.10.01.22.57; Mon, 10 May 2021 01:22:58 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A1F86802DE; Mon, 10 May 2021 11:22:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C17D6803A7 for ; Mon, 10 May 2021 11:22:47 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AAA6E240476 for ; Mon, 10 May 2021 10:22:46 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jMszkL8QFQo7 for ; Mon, 10 May 2021 10:22:45 +0200 (CEST) Received: from libav.khirnov.net (unknown [IPv6:2a00:c500:561:201:fd30:eaa3:dabe:9b14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9C6B024042A for ; Mon, 10 May 2021 10:22:45 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id DF8F13A1203; Mon, 10 May 2021 10:22:40 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 May 2021 10:22:22 +0200 Message-Id: <20210510082222.16691-1-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavf/flvdec: normalize exporting date metadata 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: L4oWYF/SxJDk Export them in UTC, not the local timezone. This way the output is the same everywhere. The timezone information stored in the file is still ignored, since there seems to be no simple way to export it correctly. Format them according to ISO 8601, which we generally use for exporting dates. --- If anyone has practical suggestions for exporting the timezone, I would love to hear them. Don't see anything in the standard library for "express this UTC timestamp in a given timezone". Just adding the offset to the timestamp would AFAIU not be correct wrt leap seconds (and maybe something else? dates are hard). Also, the conversion of double to time_t is potentially UB if the source value is out of range, but there seems to be no standard way to check, since the range of time_t is not standard either. Anyone got any ideas? --- libavformat/flvdec.c | 7 +++++-- tests/ref/fate/flv-demux | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) -format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.000000|duration=210.209999|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332|tag:hasAudio=true|tag:audiodelay=0|tag:videosize=10176110|tag:metadatadate=Sun, 27 Feb 2011 12:00:33 +0100|tag:metadatacreator=inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2|tag:hasCuePoints=false +format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.000000|duration=210.209999|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332|tag:hasAudio=true|tag:audiodelay=0|tag:videosize=10176110|tag:metadatadate=2011-02-27T11:00:33Z|tag:metadatacreator=inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2|tag:hasCuePoints=false diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index e6c2877a74..ddaceaafe4 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -686,8 +686,11 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, struct tm t; char datestr[128]; time = date.milliseconds / 1000; // to seconds - localtime_r(&time, &t); - strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S %z", &t); + gmtime_r(&time, &t); + + // timezone is ignored, since there is no easy way to offset the UTC + // timestamp into the specified timezone + strftime(datestr, sizeof(datestr), "%Y-%m-%dT%H:%M:%SZ", &t); av_dict_set(&s->metadata, key, datestr, 0); } diff --git a/tests/ref/fate/flv-demux b/tests/ref/fate/flv-demux index 30435adeb9..827b56ea09 100644 --- a/tests/ref/fate/flv-demux +++ b/tests/ref/fate/flv-demux @@ -605,4 +605,4 @@ packet|codec_type=audio|stream_index=1|pts=11656|pts_time=11.656000|dts=11656|dt packet|codec_type=video|stream_index=0|pts=11678|pts_time=11.678000|dts=11678|dts_time=11.678000|duration=33|duration_time=0.033000|size=1190|pos=510794|flags=__|data_hash=CRC32:a0206c90 stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=426|height=240|coded_width=426|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=71:40|pix_fmt=yuv420p|level=21|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=30/1|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=393929|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=351|extradata_hash=CRC32:07b85ca9|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnail s=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 stream|index=1|codec_name=aac|profile=1|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=22050|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=67874|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=252|extradata_hash=CRC32:d039c029|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0