Revision 7df22143 libavformat/mov.c

View differences:

libavformat/mov.c
663 663
    return mov_read_default(c, pb, atom);
664 664
}
665 665

  
666
static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
667
{
668
    char buffer[32];
669
    if (time) {
670
        time -= 2082844800;  /* seconds between 1904-01-01 and Epoch */
671
        strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", gmtime(&time));
672
        av_metadata_set2(metadata, "creation_time", buffer, 0);
673
    }
674
}
675

  
666 676
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
667 677
{
668 678
    AVStream *st;
......
670 680
    int version;
671 681
    char language[4] = {0};
672 682
    unsigned lang;
683
    time_t creation_time;
673 684

  
674 685
    if (c->fc->nb_streams < 1)
675 686
        return 0;
......
682 693

  
683 694
    get_be24(pb); /* flags */
684 695
    if (version == 1) {
685
        get_be64(pb);
696
        creation_time = get_be64(pb);
686 697
        get_be64(pb);
687 698
    } else {
688
        get_be32(pb); /* creation time */
699
        creation_time = get_be32(pb);
689 700
        get_be32(pb); /* modification time */
690 701
    }
702
    mov_metadata_creation_time(&st->metadata, creation_time);
691 703

  
692 704
    sc->time_scale = get_be32(pb);
693 705
    st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
......
702 714

  
703 715
static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
704 716
{
717
    time_t creation_time;
705 718
    int version = get_byte(pb); /* version */
706 719
    get_be24(pb); /* flags */
707 720

  
708 721
    if (version == 1) {
709
        get_be64(pb);
722
        creation_time = get_be64(pb);
710 723
        get_be64(pb);
711 724
    } else {
712
        get_be32(pb); /* creation time */
725
        creation_time = get_be32(pb);
713 726
        get_be32(pb); /* modification time */
714 727
    }
728
    mov_metadata_creation_time(&c->fc->metadata, creation_time);
715 729
    c->time_scale = get_be32(pb); /* time scale */
716 730

  
717 731
    dprintf(c->fc, "time scale = %i\n", c->time_scale);

Also available in: Unified diff