[FFmpeg-devel] [PATCH] lavf/flvdec: normalize exporting date metadata
Anton Khirnov
anton at khirnov.net
Fri May 14 11:09:56 EEST 2021
Quoting Alexander Strasser (2021-05-12 01:04:28)
> From 3fd6c8f81baacace49e0a6cc431295dc56a077bc Mon Sep 17 00:00:00 2001
> From: Alexander Strasser <eclipse7 at gmx.net>
> Date: Wed, 12 May 2021 00:46:54 +0200
> Subject: [PATCH] lavf/flvdec: metadata date: respect timezone information if
> present
>
> If the timezone data of an AMF 0 date type is non-zero, include that
> information as UTC offset in hours and minutes.
> ---
> libavformat/flvdec.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index ddaceaafe4..c941e62e23 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -688,9 +688,21 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
> time = date.milliseconds / 1000; // to seconds
> 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);
> + strftime(datestr, sizeof(datestr), "%Y-%m-%dT%H:%M:%S", &t);
> +
> + if (date.timezone) {
> + int off_tz = date.timezone; // offset in minutes
> + char ch_sign = '+';
> + if (off_tz < 0) {
> + off_tz = -off_tz;
> + ch_sign = '-';
> + }
> + if (off_tz > 99*60 + 59)
> + off_tz = 99*60 + 59;
> +
> + av_strlcatf(datestr, sizeof(datestr), "%c%02d%02d", ch_sign, off_tz / 60, off_tz % 60);
I still believe this is wrong, since the spec says the timestamp is in
UTC. The code you quoted seems to conform to that.
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list