movenc: Don't store a nonzero creation time if nothing was set by the caller

Message ID 1326195261-46607-1-git-send-email-martin@martin.st
State Committed
Commit a78dbada55d6b467dd560e0780f6bc50f72ba21a
Headers show

Commit Message

Martin Storsjö Jan. 10, 2012, 11:34 a.m.
If the creation time is stored in the file as a zero, the
mov demuxer skips exporting the creation time. Currently,
files muxed without a creation time get demuxed with a
Jan 1st 1970 creation timestamp.
---
 libavformat/movenc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Justin Ruggles Jan. 10, 2012, 12:56 p.m. | #1
On 01/10/2012 06:34 AM, Martin Storsjö wrote:

> If the creation time is stored in the file as a zero, the
> mov demuxer skips exporting the creation time. Currently,
> files muxed without a creation time get demuxed with a
> Jan 1st 1970 creation timestamp.
> ---
>  libavformat/movenc.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index ef3f5cc..eb508b7 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -2648,7 +2648,8 @@ static int mov_write_header(AVFormatContext *s)
>  #endif
>      if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
>          mov->time = ff_iso8601_to_unix_time(t->value);
> -    mov->time += 0x7C25B080; //1970 based -> 1904 based
> +    if (mov->time)
> +        mov->time += 0x7C25B080; // 1970 based -> 1904 based
>  
>      if (mov->chapter_track)
>          mov_create_chapter_track(s, mov->chapter_track);


lgtm. I always wondered why it did that, but I was never bothered enough
to investigate.

-Justin

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ef3f5cc..eb508b7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2648,7 +2648,8 @@  static int mov_write_header(AVFormatContext *s)
 #endif
     if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
         mov->time = ff_iso8601_to_unix_time(t->value);
-    mov->time += 0x7C25B080; //1970 based -> 1904 based
+    if (mov->time)
+        mov->time += 0x7C25B080; // 1970 based -> 1904 based
 
     if (mov->chapter_track)
         mov_create_chapter_track(s, mov->chapter_track);