@@ -542,12 +542,12 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va
542542 }
543543 else if (strstr (info.vcodec .c_str (), " rav1e" ) != NULL ) {
544544 // Set number of tiles to a fixed value
545- // TODO Let user choose number of tiles
545+ // TODO Let user choose number of tiles
546546 av_opt_set_int (c->priv_data , " qp" , std::min (std::stoi (value),255 ), 0 );
547547 }
548548 else if (strstr (info.vcodec .c_str (), " aom" ) != NULL ) {
549549 // Set number of tiles to a fixed value
550- // TODO Let user choose number of tiles
550+ // TODO Let user choose number of tiles
551551 // libaom doesn't have qp only crf
552552 av_opt_set_int (c->priv_data , " crf" , std::min (std::stoi (value),63 ), 0 );
553553 }
@@ -1207,10 +1207,10 @@ AVStream *FFmpegWriter::add_video_stream() {
12071207#endif
12081208
12091209 /* Init video encoder options */
1210- if (info.video_bit_rate >= 1000
1210+ if (info.video_bit_rate >= 1000
12111211#if (LIBAVCODEC_VERSION_MAJOR >= 58)
12121212 && c->codec_id != AV_CODEC_ID_AV1
1213- #endif
1213+ #endif
12141214 ) {
12151215 c->bit_rate = info.video_bit_rate ;
12161216 if (info.video_bit_rate >= 1500000 ) {
@@ -1226,40 +1226,40 @@ AVStream *FFmpegWriter::add_video_stream() {
12261226#if (LIBAVCODEC_VERSION_MAJOR >= 58)
12271227 case AV_CODEC_ID_AV1 :
12281228 // TODO: Set `crf` or `qp` according to bitrate, as bitrate is not supported by these encoders yet.
1229- if (info.video_bit_rate >= 1000 ) {
1230- c->bit_rate = 0 ;
1231- if (strstr (info.vcodec .c_str (), " aom" ) != NULL ) {
1232- int calculated_quality = 35 ;
1233- if (info.video_bit_rate < 500000 ) calculated_quality = 50 ;
1234- if (info.video_bit_rate > 5000000 ) calculated_quality = 10 ;
1235- av_opt_set_int (c->priv_data , " crf" , calculated_quality, 0 );
1236- info.video_bit_rate = calculated_quality;
1237- } else {
1238- int calculated_quality = 50 ;
1239- if (info.video_bit_rate < 500000 ) calculated_quality = 60 ;
1240- if (info.video_bit_rate > 5000000 ) calculated_quality = 15 ;
1241- av_opt_set_int (c->priv_data , " qp" , calculated_quality, 0 );
1242- info.video_bit_rate = calculated_quality;
1243- } // medium
1244- }
1245- if (strstr (info.vcodec .c_str (), " svt_av1" ) != NULL ) {
1246- av_opt_set_int (c->priv_data , " preset" , 6 , 0 );
1247- av_opt_set_int (c->priv_data , " forced-idr" ,1 ,0 );
1248- }
1249- else if (strstr (info.vcodec .c_str (), " rav1e" ) != NULL ) {
1250- av_opt_set_int (c->priv_data , " speed" , 7 , 0 );
1251- av_opt_set_int (c->priv_data , " tile-rows" , 2 , 0 );
1252- av_opt_set_int (c->priv_data , " tile-columns" , 4 , 0 );
1253- }
1254- else if (strstr (info.vcodec .c_str (), " aom" ) != NULL ) {
1255- // Set number of tiles to a fixed value
1256- // TODO: Allow user to chose their own number of tiles
1257- av_opt_set_int (c->priv_data , " tile-rows" , 1 , 0 ); // log2 of number of rows
1258- av_opt_set_int (c->priv_data , " tile-columns" , 2 , 0 ); // log2 of number of columns
1259- av_opt_set_int (c->priv_data , " row-mt" , 1 , 0 ); // use multiple cores
1260- av_opt_set_int (c->priv_data , " cpu-used" , 3 , 0 ); // default is 1, usable is 4
1261- }
1262- // break;
1229+ if (info.video_bit_rate >= 1000 ) {
1230+ c->bit_rate = 0 ;
1231+ if (strstr (info.vcodec .c_str (), " aom" ) != NULL ) {
1232+ int calculated_quality = 35 ;
1233+ if (info.video_bit_rate < 500000 ) calculated_quality = 50 ;
1234+ if (info.video_bit_rate > 5000000 ) calculated_quality = 10 ;
1235+ av_opt_set_int (c->priv_data , " crf" , calculated_quality, 0 );
1236+ info.video_bit_rate = calculated_quality;
1237+ } else {
1238+ int calculated_quality = 50 ;
1239+ if (info.video_bit_rate < 500000 ) calculated_quality = 60 ;
1240+ if (info.video_bit_rate > 5000000 ) calculated_quality = 15 ;
1241+ av_opt_set_int (c->priv_data , " qp" , calculated_quality, 0 );
1242+ info.video_bit_rate = calculated_quality;
1243+ } // medium
1244+ }
1245+ if (strstr (info.vcodec .c_str (), " svt_av1" ) != NULL ) {
1246+ av_opt_set_int (c->priv_data , " preset" , 6 , 0 );
1247+ av_opt_set_int (c->priv_data , " forced-idr" ,1 ,0 );
1248+ }
1249+ else if (strstr (info.vcodec .c_str (), " rav1e" ) != NULL ) {
1250+ av_opt_set_int (c->priv_data , " speed" , 7 , 0 );
1251+ av_opt_set_int (c->priv_data , " tile-rows" , 2 , 0 );
1252+ av_opt_set_int (c->priv_data , " tile-columns" , 4 , 0 );
1253+ }
1254+ else if (strstr (info.vcodec .c_str (), " aom" ) != NULL ) {
1255+ // Set number of tiles to a fixed value
1256+ // TODO: Allow user to chose their own number of tiles
1257+ av_opt_set_int (c->priv_data , " tile-rows" , 1 , 0 ); // log2 of number of rows
1258+ av_opt_set_int (c->priv_data , " tile-columns" , 2 , 0 ); // log2 of number of columns
1259+ av_opt_set_int (c->priv_data , " row-mt" , 1 , 0 ); // use multiple cores
1260+ av_opt_set_int (c->priv_data , " cpu-used" , 3 , 0 ); // default is 1, usable is 4
1261+ }
1262+ // break;
12631263#endif
12641264 case AV_CODEC_ID_VP9 :
12651265 case AV_CODEC_ID_HEVC :
0 commit comments