[FFmpeg-devel] [PATCH] lavf/flvdec: normalize exporting date metadata

Alexander Strasser eclipse7 at gmx.net
Wed May 12 02:04:28 EEST 2021


On 2021-05-11 17:51 +0200, Anton Khirnov wrote:
> Quoting Alexander Strasser (2021-05-10 15:35:02)
> > On 2021-05-10 10:22 +0200, Anton Khirnov wrote:
> > > 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).
> >
> > Surprisingly it seems best to ignore the timezone part on purpose!
> >
> > In 2.13 of Adobe's AMF 0 spec
> >   https://www.adobe.com/content/dam/acom/en/devnet/pdf/amf0-file-format-specification.pdf
> >
> > it is stated that the timezone part should not be filled, nor
> > used.
> >
> > So the commit message part about it and the comment in the
> > added by this patch should probably be removed.
> >
> > Though independent of this patch, one could maybe add a
> > check that states sample welcome if a file with a timezone
> > offset is found.
>
> I have no idea how FLV is related to AMF0,

FLV reuses AMF0 spec for serialization of the metadata we talk about?


> but the sample used in the
> test in question here does have a non-zero value of the tz offset. So
> the comment seems appropriate to me.

Interesting.

In case of that sample it is probably FLVTool2 that wrote that
wrote the metadata. Then this should be its Ruby code for handling
the AMF date type:

    def write__AMF_date(time)
      write__UI8 11
      write [(time.to_f * 1000.0)].pack('G')
      write__SI16( (Time.now.gmtoff / 60).to_i )
    end

    def read__AMF_date
      utc_time = Time.at((read__AMF_double / 1000).to_i)
      utc_time + (read__SI16 * 60) - Time.now.gmtoff
    end

I have a attached patch, that on top of your patch, adds output of
timezone information according to the quoted interpretation of
FLVTool2.


Best regards,
  Alexander

[...]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavf-flvdec-metadata-date-respect-timezone-informati.patch
Type: text/x-diff
Size: 1685 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210512/14be8e44/attachment.patch>


More information about the ffmpeg-devel mailing list