Skip to content

Commit f66ccb1

Browse files
authored
Set video bit rate to 0 if an invalid bit rate detected (which happens when using crf) (#191)
1 parent 0587ada commit f66ccb1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/FFmpegWriter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
148148
}
149149
if (bit_rate >= 1000) // bit_rate is the bitrate in b/s
150150
info.video_bit_rate = bit_rate;
151+
else
152+
info.video_bit_rate = 0;
151153

152154
info.interlaced_frame = interlaced;
153155
info.top_field_first = top_field_first;
@@ -968,9 +970,12 @@ AVStream* FFmpegWriter::add_video_stream()
968970
#endif
969971

970972
/* Init video encoder options */
971-
if (info.video_bit_rate > 1000) {
973+
if (info.video_bit_rate >= 1000) {
972974
c->bit_rate = info.video_bit_rate;
973975
}
976+
else {
977+
c->bit_rate = 0;
978+
}
974979

975980
//TODO: Implement variable bitrate feature (which actually works). This implementation throws
976981
//invalid bitrate errors and rc buffer underflow errors, etc...

0 commit comments

Comments
 (0)