You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
fftools/ffmpeg_enc: move set_encoder_id() to ffmpeg_mux_init
This code uses no encoder properties or state besides its name, and is mostly muxer logic, and thus belongs more properly into the muxer. The results of several test change due to different metadata tag order (the "encoder" tag is now set first).
This commit is contained in:
@@ -1140,6 +1140,28 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int set_encoder_id(OutputStream *ost, const AVCodec *codec)
|
||||
{
|
||||
const char *cname = codec->name;
|
||||
uint8_t *encoder_string;
|
||||
int encoder_string_len;
|
||||
|
||||
encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2;
|
||||
encoder_string = av_mallocz(encoder_string_len);
|
||||
if (!encoder_string)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (!ost->file->bitexact && !ost->bitexact)
|
||||
av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len);
|
||||
else
|
||||
av_strlcpy(encoder_string, "Lavc ", encoder_string_len);
|
||||
av_strlcat(encoder_string, cname, encoder_string_len);
|
||||
av_dict_set(&ost->st->metadata, "encoder", encoder_string,
|
||||
AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||
InputStream *ist, OutputFilter *ofilter, const ViewSpecifier *vs,
|
||||
OutputStream **post)
|
||||
@@ -1406,6 +1428,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||
ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT);
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
ret = set_encoder_id(ost, enc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
opt_match_per_stream_str(ost, &o->time_bases, oc, st, &time_base);
|
||||
if (time_base) {
|
||||
AVRational q;
|
||||
@@ -2981,9 +3009,6 @@ static int copy_meta(Muxer *mux, const OptionsContext *o)
|
||||
if (!ost->ist) /* this is true e.g. for attached files */
|
||||
continue;
|
||||
av_dict_copy(&ost->st->metadata, ost->ist->st->metadata, AV_DICT_DONT_OVERWRITE);
|
||||
if (ost->enc_ctx) {
|
||||
av_dict_set(&ost->st->metadata, "encoder", NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user