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
b72a7b96
Commit
b72a7b96
authored
Jun 29, 2016
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat: factorize iso 8601 timestamp writer to a dictionary avutil function
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
a810126f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
14 deletions
+29
-14
utils.c
libavformat/utils.c
+2
-14
dict.c
libavutil/dict.c
+17
-0
internal.h
libavutil/internal.h
+10
-0
No files found.
libavformat/utils.c
View file @
b72a7b96
...
...
@@ -5217,20 +5217,8 @@ int ff_standardize_creation_time(AVFormatContext *s)
{
int64_t
timestamp
;
int
ret
=
ff_parse_creation_time_metadata
(
s
,
&
timestamp
,
0
);
if
(
ret
==
1
)
{
time_t
seconds
=
timestamp
/
1000000
;
struct
tm
*
ptm
,
tmbuf
;
ptm
=
gmtime_r
(
&
seconds
,
&
tmbuf
);
if
(
ptm
)
{
char
buf
[
32
];
if
(
!
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%dT%H:%M:%S"
,
ptm
))
return
AVERROR_EXTERNAL
;
av_strlcatf
(
buf
,
sizeof
(
buf
),
".%06dZ"
,
(
int
)(
timestamp
%
1000000
));
av_dict_set
(
&
s
->
metadata
,
"creation_time"
,
buf
,
0
);
}
else
{
return
AVERROR_EXTERNAL
;
}
}
if
(
ret
==
1
)
return
avpriv_dict_set_timestamp
(
&
s
->
metadata
,
"creation_time"
,
timestamp
);
return
ret
;
}
...
...
libavutil/dict.c
View file @
b72a7b96
...
...
@@ -24,6 +24,7 @@
#include "dict.h"
#include "internal.h"
#include "mem.h"
#include "time_internal.h"
#include "bprint.h"
struct
AVDictionary
{
...
...
@@ -253,3 +254,19 @@ int av_dict_get_string(const AVDictionary *m, char **buffer,
}
return
av_bprint_finalize
(
&
bprint
,
buffer
);
}
int
avpriv_dict_set_timestamp
(
AVDictionary
**
dict
,
const
char
*
key
,
int64_t
timestamp
)
{
time_t
seconds
=
timestamp
/
1000000
;
struct
tm
*
ptm
,
tmbuf
;
ptm
=
gmtime_r
(
&
seconds
,
&
tmbuf
);
if
(
ptm
)
{
char
buf
[
32
];
if
(
!
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%dT%H:%M:%S"
,
ptm
))
return
AVERROR_EXTERNAL
;
av_strlcatf
(
buf
,
sizeof
(
buf
),
".%06dZ"
,
(
int
)(
timestamp
%
1000000
));
return
av_dict_set
(
dict
,
key
,
buf
,
0
);
}
else
{
return
AVERROR_EXTERNAL
;
}
}
libavutil/internal.h
View file @
b72a7b96
...
...
@@ -330,6 +330,16 @@ static av_always_inline av_const int avpriv_mirror(int x, int w)
void
ff_check_pixfmt_descriptors
(
void
);
/**
* Set a dictionary value to an ISO-8601 compliant timestamp string.
*
* @param s AVFormatContext
* @param key metadata key
* @param timestamp unix timestamp in microseconds
* @return <0 on error
*/
int
avpriv_dict_set_timestamp
(
AVDictionary
**
dict
,
const
char
*
key
,
int64_t
timestamp
);
extern
const
uint8_t
ff_reverse
[
256
];
#endif
/* AVUTIL_INTERNAL_H */
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