mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
avcodec/libx265: add pass and x265-stats option
Add support for standard -pass and -passlogfile options, matching the behavior of libx264. Add the -x265-stats option to specify the stats filename. Update documentation. Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
This commit is contained in:
committed by
Gyan Doshi
parent
d244d438c3
commit
d25d133df3
@@ -3083,6 +3083,10 @@ Quantizer curve compression factor
|
||||
Normally, when forcing a I-frame type, the encoder can select any type
|
||||
of I-frame. This option forces it to choose an IDR-frame.
|
||||
|
||||
@item x265-stats
|
||||
Specify the file name for 2-pass stats. This is set automatically when using
|
||||
the @option{-passlogfile} option.
|
||||
|
||||
@item udu_sei @var{boolean}
|
||||
Import user data unregistered SEI if available into output. Default is 0 (off).
|
||||
|
||||
|
||||
@@ -730,6 +730,11 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
||||
AV_OPT_SEARCH_CHILDREN) > 0)
|
||||
av_opt_set(video_enc, "stats", logfilename,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
} else if (!strcmp(video_enc->codec->name, "libx265")) {
|
||||
if (av_opt_is_set_to_default_by_name(video_enc, "x265-stats",
|
||||
AV_OPT_SEARCH_CHILDREN) > 0)
|
||||
av_opt_set(video_enc, "x265-stats", logfilename,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
} else {
|
||||
if (video_enc->flags & AV_CODEC_FLAG_PASS2) {
|
||||
char *logbuffer = read_file_to_string(logfilename);
|
||||
|
||||
@@ -71,6 +71,7 @@ typedef struct libx265Context {
|
||||
char *preset;
|
||||
char *tune;
|
||||
char *profile;
|
||||
char *stats;
|
||||
AVDictionary *x265_opts;
|
||||
|
||||
void *sei_data;
|
||||
@@ -529,6 +530,24 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->flags & AV_CODEC_FLAG_PASS1) {
|
||||
if (ctx->api->param_parse(ctx->params, "pass", "1") == X265_PARAM_BAD_VALUE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid value for param \"pass\".\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
} else if (avctx->flags & AV_CODEC_FLAG_PASS2) {
|
||||
if (ctx->api->param_parse(ctx->params, "pass", "2") == X265_PARAM_BAD_VALUE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid value for param \"pass\".\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
if (ctx->stats) {
|
||||
if (ctx->api->param_parse(ctx->params, "stats", ctx->stats) == X265_PARAM_BAD_VALUE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid value \"%s\" for param \"stats\".\n", ctx->stats);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->params->rc.vbvBufferSize && avctx->rc_initial_buffer_occupancy > 1000 &&
|
||||
ctx->params->rc.vbvBufferInit == 0.9) {
|
||||
ctx->params->rc.vbvBufferInit = (float)avctx->rc_initial_buffer_occupancy / 1000;
|
||||
@@ -1009,6 +1028,7 @@ static const AVOption options[] = {
|
||||
{ "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
|
||||
{ "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
|
||||
{ "profile", "set the x265 profile", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
|
||||
{ "x265-stats", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
|
||||
{ "udu_sei", "Use user data unregistered SEI if available", OFFSET(udu_sei), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||
{ "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||
{ "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
|
||||
|
||||
Reference in New Issue
Block a user