Skip to content

Commit 3f17601

Browse files
authored
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
1 parent 8f385c1 commit 3f17601

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/FFmpegWriter.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,16 @@ AVStream* FFmpegWriter::add_video_stream()
995995
/* Init video encoder options */
996996
if (info.video_bit_rate >= 1000) {
997997
c->bit_rate = info.video_bit_rate;
998+
if (info.video_bit_rate >= 1500000) {
999+
c->qmin = 2;
1000+
c->qmax = 30;
1001+
}
1002+
// Here should be the setting for low fixed bitrate
1003+
// Defaults are used because mpeg2 otherwise had problems
1004+
}
1005+
else {
1006+
c->qmin = 0;
1007+
c->qmax = 63;
9981008
}
9991009

10001010
//TODO: Implement variable bitrate feature (which actually works). This implementation throws
@@ -1004,8 +1014,6 @@ AVStream* FFmpegWriter::add_video_stream()
10041014
//c->rc_buffer_size = FFMAX(c->rc_max_rate, 15000000) * 112L / 15000000 * 16384;
10051015
//if ( !c->rc_initial_buffer_occupancy )
10061016
// c->rc_initial_buffer_occupancy = c->rc_buffer_size * 3/4;
1007-
c->qmin = 2;
1008-
c->qmax = 30;
10091017

10101018
/* resolution must be a multiple of two */
10111019
// TODO: require /2 height and width

src/Timeline.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ void Timeline::ClearAllCache() {
14421442
// Set Max Image Size (used for performance optimization). Convenience function for setting
14431443
// Settings::Instance()->MAX_WIDTH and Settings::Instance()->MAX_HEIGHT.
14441444
void Timeline::SetMaxSize(int width, int height) {
1445-
// Init max image size
1446-
Settings::Instance()->MAX_WIDTH = width;
1447-
Settings::Instance()->MAX_HEIGHT = height;
1445+
// Init max image size (choose the smallest one)
1446+
Settings::Instance()->MAX_WIDTH = min(width, info.width);
1447+
Settings::Instance()->MAX_HEIGHT = min(height, info.height);
14481448
}

0 commit comments

Comments
 (0)