mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-06 17:29:08 +08: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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user