mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Introduce av_metadata_copy() to copy metadata from one struct to another.
Originally committed as revision 26330 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
ca32f7f208
commit
7f88a5bf9b
24
ffmpeg.c
24
ffmpeg.c
@ -1862,7 +1862,6 @@ static int copy_chapters(int infile, int outfile)
|
|||||||
|
|
||||||
for (i = 0; i < is->nb_chapters; i++) {
|
for (i = 0; i < is->nb_chapters; i++) {
|
||||||
AVChapter *in_ch = is->chapters[i], *out_ch;
|
AVChapter *in_ch = is->chapters[i], *out_ch;
|
||||||
AVMetadataTag *t = NULL;
|
|
||||||
int64_t ts_off = av_rescale_q(start_time - input_files_ts_offset[infile],
|
int64_t ts_off = av_rescale_q(start_time - input_files_ts_offset[infile],
|
||||||
AV_TIME_BASE_Q, in_ch->time_base);
|
AV_TIME_BASE_Q, in_ch->time_base);
|
||||||
int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX :
|
int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX :
|
||||||
@ -1884,8 +1883,7 @@ static int copy_chapters(int infile, int outfile)
|
|||||||
out_ch->end = FFMIN(rt, in_ch->end - ts_off);
|
out_ch->end = FFMIN(rt, in_ch->end - ts_off);
|
||||||
|
|
||||||
if (metadata_chapters_autocopy)
|
if (metadata_chapters_autocopy)
|
||||||
while ((t = av_metadata_get(in_ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
|
av_metadata_copy(&out_ch->metadata, in_ch->metadata, 0);
|
||||||
av_metadata_set2(&out_ch->metadata, t->key, t->value, 0);
|
|
||||||
|
|
||||||
os->nb_chapters++;
|
os->nb_chapters++;
|
||||||
os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
|
os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
|
||||||
@ -2105,7 +2103,6 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
|
|
||||||
/* for each output stream, we compute the right encoding parameters */
|
/* for each output stream, we compute the right encoding parameters */
|
||||||
for(i=0;i<nb_ostreams;i++) {
|
for(i=0;i<nb_ostreams;i++) {
|
||||||
AVMetadataTag *t = NULL;
|
|
||||||
ost = ost_table[i];
|
ost = ost_table[i];
|
||||||
os = output_files[ost->file_index];
|
os = output_files[ost->file_index];
|
||||||
ist = ist_table[ost->source_index];
|
ist = ist_table[ost->source_index];
|
||||||
@ -2114,9 +2111,8 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
icodec = ist->st->codec;
|
icodec = ist->st->codec;
|
||||||
|
|
||||||
if (metadata_streams_autocopy)
|
if (metadata_streams_autocopy)
|
||||||
while ((t = av_metadata_get(ist->st->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
|
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
|
||||||
av_metadata_set2(&ost->st->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
|
AV_METADATA_DONT_OVERWRITE);
|
||||||
}
|
|
||||||
|
|
||||||
ost->st->disposition = ist->st->disposition;
|
ost->st->disposition = ist->st->disposition;
|
||||||
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
|
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
|
||||||
@ -2368,7 +2364,6 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
for (i=0;i<nb_meta_data_maps;i++) {
|
for (i=0;i<nb_meta_data_maps;i++) {
|
||||||
AVFormatContext *files[2];
|
AVFormatContext *files[2];
|
||||||
AVMetadata **meta[2];
|
AVMetadata **meta[2];
|
||||||
AVMetadataTag *mtag;
|
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
|
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
|
||||||
@ -2411,18 +2406,15 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mtag=NULL;
|
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
|
||||||
while((mtag=av_metadata_get(*meta[1], "", mtag, AV_METADATA_IGNORE_SUFFIX)))
|
|
||||||
av_metadata_set2(meta[0], mtag->key, mtag->value, AV_METADATA_DONT_OVERWRITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy global metadata by default */
|
/* copy global metadata by default */
|
||||||
if (metadata_global_autocopy) {
|
if (metadata_global_autocopy) {
|
||||||
AVMetadataTag *t = NULL;
|
|
||||||
|
|
||||||
while ((t = av_metadata_get(input_files[0]->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
|
|
||||||
for (i = 0; i < nb_output_files; i++)
|
for (i = 0; i < nb_output_files; i++)
|
||||||
av_metadata_set2(&output_files[i]->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
|
av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata,
|
||||||
|
AV_METADATA_DONT_OVERWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy chapters according to chapter maps */
|
/* copy chapters according to chapter maps */
|
||||||
@ -3692,7 +3684,6 @@ static void opt_output_file(const char *filename)
|
|||||||
int input_has_video, input_has_audio, input_has_subtitle;
|
int input_has_video, input_has_audio, input_has_subtitle;
|
||||||
AVFormatParameters params, *ap = ¶ms;
|
AVFormatParameters params, *ap = ¶ms;
|
||||||
AVOutputFormat *file_oformat;
|
AVOutputFormat *file_oformat;
|
||||||
AVMetadataTag *tag = NULL;
|
|
||||||
|
|
||||||
if (!strcmp(filename, "-"))
|
if (!strcmp(filename, "-"))
|
||||||
filename = "pipe:";
|
filename = "pipe:";
|
||||||
@ -3760,8 +3751,7 @@ static void opt_output_file(const char *filename)
|
|||||||
|
|
||||||
oc->timestamp = recording_timestamp;
|
oc->timestamp = recording_timestamp;
|
||||||
|
|
||||||
while ((tag = av_metadata_get(metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
|
av_metadata_copy(&oc->metadata, metadata, 0);
|
||||||
av_metadata_set2(&oc->metadata, tag->key, tag->value, 0);
|
|
||||||
av_metadata_free(&metadata);
|
av_metadata_free(&metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define AVFORMAT_AVFORMAT_H
|
#define AVFORMAT_AVFORMAT_H
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 52
|
#define LIBAVFORMAT_VERSION_MAJOR 52
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 92
|
#define LIBAVFORMAT_VERSION_MINOR 93
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 0
|
#define LIBAVFORMAT_VERSION_MICRO 0
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
@ -226,6 +226,16 @@ attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AV
|
|||||||
const AVMetadataConv *s_conv);
|
const AVMetadataConv *s_conv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy metadata from one AVMetadata struct into another.
|
||||||
|
* @param dst pointer to a pointer to a AVMetadata struct. If *dst is NULL,
|
||||||
|
* this function will allocate a struct for you and put it in *dst
|
||||||
|
* @param src pointer to source AVMetadata struct
|
||||||
|
* @param flags flags to use when setting metadata in *dst
|
||||||
|
* @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
|
||||||
|
*/
|
||||||
|
void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free all the memory allocated for an AVMetadata struct.
|
* Free all the memory allocated for an AVMetadata struct.
|
||||||
*/
|
*/
|
||||||
|
@ -158,3 +158,11 @@ void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
|
|||||||
for (i=0; i<ctx->nb_programs; i++)
|
for (i=0; i<ctx->nb_programs; i++)
|
||||||
ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
|
ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags)
|
||||||
|
{
|
||||||
|
AVMetadataTag *t = NULL;
|
||||||
|
|
||||||
|
while ((t = av_metadata_get(src, "", t, AV_METADATA_IGNORE_SUFFIX)))
|
||||||
|
av_metadata_set2(dst, t->key, t->value, flags);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user