all repos — mgba @ 97f2594ec9ec5a772077e919c2a284548d5b3db7

mGBA Game Boy Advance Emulator

Video: Automatically use different presets based on video size
Jeffrey Pfau jeffrey@endrift.com
Fri, 14 Nov 2014 03:53:30 -0800
commit

97f2594ec9ec5a772077e919c2a284548d5b3db7

parent

8607275f9f60372a8c551f7b9d77e460416c0183

1 files changed, 8 insertions(+), 0 deletions(-)

jump to
M src/platform/ffmpeg/ffmpeg-encoder.csrc/platform/ffmpeg/ffmpeg-encoder.c

@@ -234,6 +234,14 @@ if (encoder->context->oformat->flags & AVFMT_GLOBALHEADER) {

encoder->video->flags |= CODEC_FLAG_GLOBAL_HEADER; } if (strcmp(vcodec->name, "libx264") == 0) { + // Try to adaptively figure out when you can use a slower encoder + if (encoder->width * encoder->height > 1000000) { + av_opt_set(encoder->video->priv_data, "preset", "superfast", 0); + } else if (encoder->width * encoder->height > 500000) { + av_opt_set(encoder->video->priv_data, "preset", "veryfast", 0); + } else { + av_opt_set(encoder->video->priv_data, "preset", "faster", 0); + } av_opt_set(encoder->video->priv_data, "tune", "zerolatency", 0); } avcodec_open2(encoder->video, vcodec, 0);