mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avformat/utils: Move creation-time functions to mux_utils
Only used by muxers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
533836b8e0
commit
d78838414b
13 changed files with 60 additions and 51 deletions
|
|
@ -19,6 +19,11 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "avformat.h"
|
||||
#include "avio.h"
|
||||
#include "internal.h"
|
||||
|
|
@ -79,3 +84,29 @@ end:
|
|||
av_free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
|
||||
{
|
||||
AVDictionaryEntry *entry;
|
||||
int64_t parsed_timestamp;
|
||||
int ret;
|
||||
if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) {
|
||||
if ((ret = av_parse_time(&parsed_timestamp, entry->value, 0)) >= 0) {
|
||||
*timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
|
||||
return 1;
|
||||
} else {
|
||||
av_log(s, AV_LOG_WARNING, "Failed to parse creation_time %s\n", entry->value);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_standardize_creation_time(AVFormatContext *s)
|
||||
{
|
||||
int64_t timestamp;
|
||||
int ret = ff_parse_creation_time_metadata(s, ×tamp, 0);
|
||||
if (ret == 1)
|
||||
return avpriv_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue