[FFmpeg-devel] [PATCH] avformat/mov: remove hack breaking creation time parsing

Bernd Dürrer Bernd.Duerrer at gmx.de
Tue Apr 11 14:46:31 EEST 2023


On Sun Apr 9 20:20:04 EEST 2023, Michael Niedermayer wrote: 

> what do you mean by intended creation time?
> the file format did not exist in 1946. and all the codecs also didnt exist
> so when you encounter a file that says its from that time it must be crafted
> later and backdated or that bug.

As defined in ISO/IEC 14496-12, clause 8.2, "creation_time is an integer that declares the creation time of the presentation (in seconds since midnight, Jan. 1, 1904, in UTC time)". This is the date when the content was created (which may have been on photographic film), and not when it was encoded as a digital file. As described in http://ffmpeg.org/pipermail/ffmpeg-user/2023-April/056265.html, the use case is to set the creation_time tag to this date of content creation as DLNA servers pass this date on to their clients. However, unlike the standard ISO/IEC 14496-12, ffmpeg does not support dates before 1970.

As far as I can see from the code, the reason for this behaviour is that the function ff_parse_creation_time_metadata in libavformat/mux_utils.c calls av_parse_time in libavutil/parseutils.c that converts the timestr to microseconds since 1st of January 1970. ff_parse_creation_time_metadata then converts microseconds back to seconds and sets the timestamp as seconds. To allow for dates before 1970 as defined in ISO/IEC 14496-12, either ff_parse_creation_time_metadata would have to parse the submitted timestamp itself and convert it to seconds since midnight, Jan. 1, 1904, in UTC time, or instruct av_parse_time to do so (e.g. by submitting a special value to av_parse_time's parameter duration).

In any case, it would be more gracious if ffmpeg either rejects a timestr outside the accepted date range or displays a warning message. In the example ffmpeg -i input.mp4 -map_metadata 0 -metadata creation_time="1965-01-01 12:00:00" -codec copy output.mp4, though the date is correctly displayed during the copy process, afterwards ffprobe yields a future date (in the example, ffprobe output.mp4 displays creation_time as 2036-01-01T23:59:59.000000Z).

Kind regards,

Bernd


More information about the ffmpeg-devel mailing list