[FFmpeg-devel] [PATCH] libavformat: Add poster_time and time_scale to quicktime metadata output

Michael Niedermayer michaelni at gmx.at
Mon Aug 18 23:26:02 CEST 2014


Hi

On Thu, Aug 14, 2014 at 01:24:37PM -0600, Graham Torn wrote:
> From: gt-sdi <gtorn at straylightdigital.com>
> 
> Extract poster_time and time_scale from quicktime mdhd atom
> and add to metadata for output by ffprobe.
> 
> Signed-off-by: gt-sdi <gtorn at straylightdigital.com>
> ---
>  libavformat/mov.c | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 767833e..b49592b 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -850,9 +850,28 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>      return 0;
>  }
>  
> +static void mov_metadata_time_scale(AVDictionary **metadata, int time)
> +{
> +    char buffer[32];
> +    if (time) {
> +        snprintf(buffer, sizeof(buffer), "%i", time);
> +        av_dict_set(metadata, "time_scale", buffer, 0);
> +    }
> +}
> +
> +static void mov_metadata_poster_time(AVDictionary **metadata, int64_t time)
> +{
> +    char buffer[32];
> +    if (time) {
> +        snprintf(buffer, sizeof(buffer), "%" PRId64, time);
> +        av_dict_set(metadata, "poster_time", buffer, 0);
> +    }
> +}

see av_dict_set_int()


> +
>  static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>  {
>      int64_t creation_time;
> +    int64_t poster_time;
>      int version = avio_r8(pb); /* version */
>      avio_rb24(pb); /* flags */
>  
> @@ -864,8 +883,9 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>          avio_rb32(pb); /* modification time */
>      }
>      mov_metadata_creation_time(&c->fc->metadata, creation_time);
> -    c->time_scale = avio_rb32(pb); /* time scale */
>  
> +    c->time_scale = avio_rb32(pb); /* time scale */
> +    mov_metadata_time_scale(&c->fc->metadata, c->time_scale);
>      av_dlog(c->fc, "time scale = %i\n", c->time_scale);
>  
>      c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */

when transcoding this can end up being stored in the destination
file. considering that could even be a mov file, this seems
sub optimal

note see, "duration" and "encoder" on other similar metadata that is
not just unconditionally copied

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140818/a53163b7/attachment.asc>


More information about the ffmpeg-devel mailing list