[FFmpeg-cvslog] avformat/mov: restrict unix timestamp hack to version 0 mdhd/mvhd

Marton Balint git at videolan.org
Tue Apr 25 00:06:13 EEST 2023


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Apr 15 18:25:30 2023 +0200| [5cdbf817c978a75b1d840325727ed314b4f886a7] | committer: Marton Balint

avformat/mov: restrict unix timestamp hack to version 0 mdhd/mvhd

Commit 23eeffcd48a15e73fb2649b712870b6d101c5471 added a hack to support invalid
files where the creation date was encoded as a classic unix timestamp. Let's
reduce the scope of the hack by only applying it to version 0 mdhd/mvhd atoms.
Also warn the user of such possibly broken files.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5cdbf817c978a75b1d840325727ed314b4f886a7
---

 libavformat/mov.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5d00ff6e8b..1b3c1d7683 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1524,10 +1524,13 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
     } else {
         time = avio_rb32(pb);
         avio_rb32(pb); /* modification time */
+        if (time > 0 && time < 2082844800) {
+            av_log(c->fc, AV_LOG_WARNING, "Detected creation time before 1970, parsing as unix timestamp.\n");
+            time += 2082844800;
+        }
     }
     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(c->fc, AV_LOG_DEBUG, "creation_time is not representable\n");



More information about the ffmpeg-cvslog mailing list