From 3f17601db6f7a46bc37e93fe9ab08ec85d1b819d Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sat, 9 Mar 2019 13:19:07 -0600 Subject: [PATCH] Invalid SetMaxSize Logic and Invalid CRF q settings in FFmpegWriter (#198) * Limit max size of preview to the timeline size (this renders very small profiles correctly) * Fixing CRF quality setting to allow "low" quality without breaking --- src/FFmpegWriter.cpp | 12 ++++++++++-- src/Timeline.cpp | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index b9b6ba76..5d09341c 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -995,6 +995,16 @@ AVStream* FFmpegWriter::add_video_stream() /* Init video encoder options */ if (info.video_bit_rate >= 1000) { c->bit_rate = info.video_bit_rate; + if (info.video_bit_rate >= 1500000) { + c->qmin = 2; + c->qmax = 30; + } + // Here should be the setting for low fixed bitrate + // Defaults are used because mpeg2 otherwise had problems + } + else { + c->qmin = 0; + c->qmax = 63; } //TODO: Implement variable bitrate feature (which actually works). This implementation throws @@ -1004,8 +1014,6 @@ AVStream* FFmpegWriter::add_video_stream() //c->rc_buffer_size = FFMAX(c->rc_max_rate, 15000000) * 112L / 15000000 * 16384; //if ( !c->rc_initial_buffer_occupancy ) // c->rc_initial_buffer_occupancy = c->rc_buffer_size * 3/4; - c->qmin = 2; - c->qmax = 30; /* resolution must be a multiple of two */ // TODO: require /2 height and width diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 28c8956a..384273bd 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -1442,7 +1442,7 @@ void Timeline::ClearAllCache() { // Set Max Image Size (used for performance optimization). Convenience function for setting // Settings::Instance()->MAX_WIDTH and Settings::Instance()->MAX_HEIGHT. void Timeline::SetMaxSize(int width, int height) { - // Init max image size - Settings::Instance()->MAX_WIDTH = width; - Settings::Instance()->MAX_HEIGHT = height; + // Init max image size (choose the smallest one) + Settings::Instance()->MAX_WIDTH = min(width, info.width); + Settings::Instance()->MAX_HEIGHT = min(height, info.height); } \ No newline at end of file