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:
@@ -161,31 +161,6 @@ static int hw_device_setup_for_encode(Encoder *e, AVCodecContext *enc_ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_encoder_id(OutputFile *of, OutputStream *ost)
|
||||
{
|
||||
const char *cname = ost->enc_ctx->codec->name;
|
||||
uint8_t *encoder_string;
|
||||
int encoder_string_len;
|
||||
|
||||
if (av_dict_get(ost->st->metadata, "encoder", NULL, 0))
|
||||
return 0;
|
||||
|
||||
encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2;
|
||||
encoder_string = av_mallocz(encoder_string_len);
|
||||
if (!encoder_string)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (!of->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;
|
||||
}
|
||||
|
||||
int enc_open(void *opaque, const AVFrame *frame)
|
||||
{
|
||||
OutputStream *ost = opaque;
|
||||
@@ -224,10 +199,6 @@ int enc_open(void *opaque, const AVFrame *frame)
|
||||
}
|
||||
}
|
||||
|
||||
ret = set_encoder_id(of, ost);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ist)
|
||||
dec = ist->decoder;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user