Video: Automatically use different presets based on video size
Jeffrey Pfau jeffrey@endrift.com
Fri, 14 Nov 2014 03:53:30 -0800
1 files changed,
8 insertions(+),
0 deletions(-)
M
src/platform/ffmpeg/ffmpeg-encoder.c
→
src/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);