Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/mov: remove hack breaking creation time parsing
@ 2023-04-08 18:37 Marton Balint
  2023-04-08 21:14 ` Michael Niedermayer
  0 siblings, 1 reply; 16+ messages in thread
From: Marton Balint @ 2023-04-08 18:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Commit 23eeffcd48a15e73fb2649b712870b6d101c5471 added a hack to support invalid
files where the creation date was encoded as a classic unix timestamp. This
broke however valid files having creation dates before the unix epoch.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mov.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 057fd872b1..7748bdc041 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1518,8 +1518,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx)
 {
     if (time) {
-        if (time >= 2082844800)
-            time -= 2082844800;  /* seconds between 1904-01-01 and Epoch */
+        time -= 2082844800;  /* seconds between 1904-01-01 and Epoch */
 
         if ((int64_t)(time * 1000000ULL) / 1000000 != time) {
             av_log(logctx, AV_LOG_DEBUG, "creation_time is not representable\n");
-- 
2.35.3

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: remove hack breaking creation time parsing
@ 2023-04-11 11:46 Bernd Dürrer
  2023-04-11 18:15 ` Marton Balint
  0 siblings, 1 reply; 16+ messages in thread
From: Bernd Dürrer @ 2023-04-11 11:46 UTC (permalink / raw)
  To: ffmpeg-devel

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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-04-13 10:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-08 18:37 [FFmpeg-devel] [PATCH] avformat/mov: remove hack breaking creation time parsing Marton Balint
2023-04-08 21:14 ` Michael Niedermayer
2023-04-09 13:49   ` Marton Balint
2023-04-09 14:06     ` Anton Khirnov
2023-04-09 17:20     ` Michael Niedermayer
2023-04-09 17:52       ` Marton Balint
2023-04-09 21:27         ` Michael Niedermayer
2023-04-10 19:11           ` Marton Balint
2023-04-10 22:34             ` Michael Niedermayer
2023-04-10  2:44       ` "zhilizhao(赵志立)"
2023-04-10 14:31         ` Michael Niedermayer
2023-04-11 11:46 Bernd Dürrer
2023-04-11 18:15 ` Marton Balint
2023-04-12  8:10   ` Bernd Dürrer
2023-04-12  8:38     ` "zhilizhao(赵志立)"
2023-04-13 10:13   ` Bernd Dürrer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git