Mercurial > libavformat.hg
comparison matroskaenc.c @ 2467:12ec768e5166 libavformat
Write the creation time
author | conrad |
---|---|
date | Wed, 05 Sep 2007 00:24:01 +0000 |
parents | 6395824043bd |
children | 9f5ae944ea07 |
comparison
equal
deleted
inserted
replaced
2466:6395824043bd | 2467:12ec768e5166 |
---|---|
125 static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const char *str) | 125 static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const char *str) |
126 { | 126 { |
127 put_ebml_binary(pb, elementid, str, strlen(str)); | 127 put_ebml_binary(pb, elementid, str, strlen(str)); |
128 } | 128 } |
129 | 129 |
130 // avtime is POSIX time, microseconds | |
131 static void put_ebml_date(ByteIOContext *pb, unsigned int elementid, int64_t avtime) | |
132 { | |
133 // midnight Jan 1, 1970 in UNIX epoch, microseconds | |
134 const int64_t ebmlDateStart = 978307200ULL * 1000000; | |
135 int64_t ebmlTime = (avtime - ebmlDateStart) * 1000; | |
136 | |
137 put_ebml_id(pb, elementid); | |
138 put_ebml_size(pb, 8, 0); | |
139 put_be64(pb, ebmlTime); | |
140 } | |
141 | |
130 // this reserves exactly the amount of space specified by size, which must be at least 2 | 142 // this reserves exactly the amount of space specified by size, which must be at least 2 |
131 static void put_ebml_void(ByteIOContext *pb, uint64_t size) | 143 static void put_ebml_void(ByteIOContext *pb, uint64_t size) |
132 { | 144 { |
133 offset_t currentpos = url_ftell(pb); | 145 offset_t currentpos = url_ftell(pb); |
134 | 146 |
524 if (strlen(s->title)) | 536 if (strlen(s->title)) |
525 put_ebml_string(pb, MATROSKA_ID_TITLE, s->title); | 537 put_ebml_string(pb, MATROSKA_ID_TITLE, s->title); |
526 if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { | 538 if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { |
527 put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT); | 539 put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT); |
528 put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT); | 540 put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT); |
541 put_ebml_date (pb, MATROSKA_ID_DATEUTC , av_gettime() ); | |
529 } | 542 } |
530 // XXX: segment UID | 543 // XXX: segment UID |
531 // reserve space for the duration | 544 // reserve space for the duration |
532 mkv->duration = 0; | 545 mkv->duration = 0; |
533 mkv->duration_offset = url_ftell(pb); | 546 mkv->duration_offset = url_ftell(pb); |