mirror of
https://github.com/mpv-player/mpv
synced 2025-01-21 23:23:19 +00:00
demux_lavf: get updated metadata from a packet if available
The side_data type is brand new in ffmpeg.
This commit is contained in:
parent
e6861ca51f
commit
ef68cfcc8a
@ -518,6 +518,23 @@ static void add_metadata(demuxer_t *demuxer, AVDictionary *metadata)
|
||||
demux_info_add(demuxer, t->key, t->value);
|
||||
}
|
||||
|
||||
static void update_metadata(demuxer_t *demuxer, AVPacket *pkt)
|
||||
{
|
||||
#if HAVE_AVCODEC_METADATA_UPDATE_SIDE_DATA
|
||||
int md_size;
|
||||
const uint8_t *md;
|
||||
md = av_packet_get_side_data(pkt, AV_PKT_DATA_METADATA_UPDATE, &md_size);
|
||||
if (md) {
|
||||
AVDictionary *dict = NULL;
|
||||
av_packet_unpack_dictionary(md, md_size, &dict);
|
||||
if (dict) {
|
||||
add_metadata(demuxer, dict);
|
||||
av_dict_free(&dict);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
{
|
||||
struct MPOpts *opts = demuxer->opts;
|
||||
@ -542,6 +559,12 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
avfc->flags |= AVFMT_FLAG_GENPTS;
|
||||
if (opts->index_mode == 0)
|
||||
avfc->flags |= AVFMT_FLAG_IGNIDX;
|
||||
/* Keep side data as side data instead of mashing it into the packet
|
||||
* stream. */
|
||||
if (av_opt_set(avfc, "fflags", "+keepside", 0) < 0) {
|
||||
MP_WARN(demuxer, "demux_lavf, couldn't set option keepdata; "
|
||||
"in-stream metadata updates will be ignored\n");
|
||||
}
|
||||
|
||||
if (lavfdopts->probesize) {
|
||||
if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0)
|
||||
@ -705,6 +728,8 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
||||
if (av_dup_packet(pkt) < 0)
|
||||
abort();
|
||||
|
||||
update_metadata(demux, pkt);
|
||||
|
||||
dp = new_demux_packet_fromdata(pkt->data, pkt->size);
|
||||
dp->avpacket = talloc_steal(dp, pkt);
|
||||
|
||||
|
@ -2750,6 +2750,17 @@ fi
|
||||
echores "$_avcodec_has_chroma_pos_api"
|
||||
|
||||
|
||||
echocheck "libavcodec metadata update side data"
|
||||
_avcodec_has_metadata_update_side_data=no
|
||||
statement_check libavcodec/avcodec.h 'enum AVPacketSideDataType type = AV_PKT_DATA_METADATA_UPDATE' && _avcodec_has_metadata_update_side_data=yes
|
||||
if test "$_avcodec_has_metadata_update_side_data" = yes ; then
|
||||
def_avcodec_has_metadata_update_side_data='#define HAVE_AVCODEC_METADATA_UPDATE_SIDE_DATA 1'
|
||||
else
|
||||
def_avcodec_has_metadata_update_side_data='#define HAVE_AVCODEC_METADATA_UPDATE_SIDE_DATA 0'
|
||||
fi
|
||||
echores "$_avcodec_has_metadata_update_side_data"
|
||||
|
||||
|
||||
echocheck "libavutil QP API"
|
||||
_avutil_has_qp_api=no
|
||||
statement_check libavutil/frame.h 'av_frame_get_qp_table(NULL, NULL, NULL)' && _avutil_has_qp_api=yes
|
||||
@ -3454,6 +3465,7 @@ $def_avutil_has_refcounting
|
||||
$def_avutil_has_qp_api
|
||||
$def_avcodec_new_vdpau_api
|
||||
$def_avcodec_has_chroma_pos_api
|
||||
$def_avcodec_has_metadata_update_side_data
|
||||
$def_libpostproc
|
||||
$def_libavdevice
|
||||
$def_libavfilter
|
||||
|
6
wscript
6
wscript
@ -396,6 +396,12 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks))
|
||||
'name': '--libpostproc',
|
||||
'desc': 'libpostproc',
|
||||
'func': check_pkg_config('libpostproc', '>= 52.0.0'),
|
||||
}, {
|
||||
'name': 'avcodec-metadata-update-side-data',
|
||||
'desc': 'libavcodec AV_PKT_DATA_METADATA_UPDATE side data type',
|
||||
'func': check_statement('libavcodec/avcodec.h',
|
||||
'enum AVPacketSideDataType type = AV_PKT_DATA_METADATA_UPDATE',
|
||||
use='libav')
|
||||
}
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user