Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
2e061130
Commit
2e061130
authored
Mar 05, 2012
by
Aaron Colwell
Committed by
Michael Niedermayer
Mar 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
matroska : Add support for reading/writing creation_time metadata.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
c7048036
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
matroskadec.c
libavformat/matroskadec.c
+16
-1
matroskaenc.c
libavformat/matroskaenc.c
+8
-0
No files found.
libavformat/matroskadec.c
View file @
2e061130
...
...
@@ -235,6 +235,7 @@ typedef struct {
uint64_t
time_scale
;
double
duration
;
char
*
title
;
EbmlBin
date_utc
;
EbmlList
tracks
;
EbmlList
attachments
;
EbmlList
chapters
;
...
...
@@ -294,7 +295,7 @@ static EbmlSyntax matroska_info[] = {
{
MATROSKA_ID_TITLE
,
EBML_UTF8
,
0
,
offsetof
(
MatroskaDemuxContext
,
title
)
},
{
MATROSKA_ID_WRITINGAPP
,
EBML_NONE
},
{
MATROSKA_ID_MUXINGAPP
,
EBML_NONE
},
{
MATROSKA_ID_DATEUTC
,
EBML_
NONE
},
{
MATROSKA_ID_DATEUTC
,
EBML_
BIN
,
0
,
offsetof
(
MatroskaDemuxContext
,
date_utc
)
},
{
MATROSKA_ID_SEGMENTUID
,
EBML_NONE
},
{
0
}
};
...
...
@@ -1346,6 +1347,17 @@ static int matroska_aac_sri(int samplerate)
return
sri
;
}
static
void
matroska_metadata_creation_time
(
AVDictionary
**
metadata
,
int64_t
date_utc
)
{
char
buffer
[
32
];
/* Convert to seconds and adjust by number of seconds between 2001-01-01 and Epoch */
time_t
creation_time
=
date_utc
/
1000000000
+
978307200
;
struct
tm
*
ptm
=
gmtime
(
&
creation_time
);
if
(
!
ptm
)
return
;
strftime
(
buffer
,
sizeof
(
buffer
),
"%Y-%m-%d %H:%M:%S"
,
ptm
);
av_dict_set
(
metadata
,
"creation_time"
,
buffer
,
0
);
}
static
int
matroska_read_header
(
AVFormatContext
*
s
)
{
MatroskaDemuxContext
*
matroska
=
s
->
priv_data
;
...
...
@@ -1406,6 +1418,9 @@ static int matroska_read_header(AVFormatContext *s)
*
1000
/
AV_TIME_BASE
;
av_dict_set
(
&
s
->
metadata
,
"title"
,
matroska
->
title
,
0
);
if
(
matroska
->
date_utc
.
size
==
8
)
matroska_metadata_creation_time
(
&
s
->
metadata
,
AV_RB64
(
matroska
->
date_utc
.
data
));
tracks
=
matroska
->
tracks
.
elem
;
for
(
i
=
0
;
i
<
matroska
->
tracks
.
nb_elem
;
i
++
)
{
MatroskaTrack
*
track
=
&
tracks
[
i
];
...
...
libavformat/matroskaenc.c
View file @
2e061130
...
...
@@ -940,6 +940,14 @@ static int mkv_write_header(AVFormatContext *s)
put_ebml_binary
(
pb
,
MATROSKA_ID_SEGMENTUID
,
segment_uid
,
16
);
}
if
(
tag
=
av_dict_get
(
s
->
metadata
,
"creation_time"
,
NULL
,
0
))
{
// Adjust time so it's relative to 2001-01-01 and convert to nanoseconds.
int64_t
date_utc
=
(
ff_iso8601_to_unix_time
(
tag
->
value
)
-
978307200
)
*
1000000000
;
uint8_t
date_utc_buf
[
8
];
AV_WB64
(
date_utc_buf
,
date_utc
);
put_ebml_binary
(
pb
,
MATROSKA_ID_DATEUTC
,
date_utc_buf
,
8
);
}
// reserve space for the duration
mkv
->
duration
=
0
;
mkv
->
duration_offset
=
avio_tell
(
pb
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment