-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newer codecs (svt_av1, rav1e, svt_hevc) #445
Changes from 1 commit
f63c1e0
6711c9c
e03cd87
ddd5246
6476f93
93d12e7
d9e6af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -255,7 +255,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction f | |||
} | ||||
if (bit_rate >= 1000) // bit_rate is the bitrate in b/s | ||||
info.video_bit_rate = bit_rate; | ||||
if ((bit_rate >= 0) && (bit_rate < 64)) // bit_rate is the bitrate in crf | ||||
if ((bit_rate >= 0) && (bit_rate < 256)) // bit_rate is the bitrate in crf | ||||
info.video_bit_rate = bit_rate; | ||||
|
||||
info.interlaced_frame = interlaced; | ||||
|
@@ -341,7 +341,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va | |||
// Was option found? | ||||
if (option || (name == "g" || name == "qmin" || name == "qmax" || name == "max_b_frames" || name == "mb_decision" || | ||||
name == "level" || name == "profile" || name == "slices" || name == "rc_min_rate" || name == "rc_max_rate" || | ||||
name == "rc_buffer_size" || name == "crf" || name == "cqp")) { | ||||
name == "rc_buffer_size" || name == "crf" || name == "cqp" || name == "qp")) { | ||||
// Check for specific named options | ||||
if (name == "g") | ||||
// Set gop_size | ||||
|
@@ -462,6 +462,18 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va | |||
case AV_CODEC_ID_AV1 : | ||||
c->bit_rate = 0; | ||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value),63), 0); | ||||
if (strstr(info.vcodec.c_str(), "svt_av1") != NULL) { | ||||
//av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); | ||||
av_opt_set_int(c->priv_data, "preset", 6, 0); | ||||
av_opt_set_int(c->priv_data, "forced-idr",1,0); | ||||
} | ||||
if (strstr(info.vcodec.c_str(), "rav1e") != NULL) { | ||||
//av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),255), 0); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same.
Suggested change
|
||||
av_opt_set_int(c->priv_data, "speed", 7, 0); | ||||
av_opt_set_int(c->priv_data, "tile-rows", 2, 0); | ||||
av_opt_set_int(c->priv_data, "tile-columns", 4, 0); | ||||
//av_opt_set(c->priv_data, "tile-row", "", 0); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's 'tile-row'? I saw it commented out in a few places. |
||||
} | ||||
break; | ||||
#endif | ||||
case AV_CODEC_ID_VP8 : | ||||
|
@@ -503,6 +515,36 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va | |||
c->bit_rate = (int) (mbs); | ||||
} | ||||
} | ||||
#endif | ||||
} else if (name == "qp") { | ||||
// encode quality and special settings like lossless | ||||
// This might be better in an extra methods as more options | ||||
// and way to set quality are possible | ||||
#if (LIBAVCODEC_VERSION_MAJOR >= 58) | ||||
switch (c->codec_id) { | ||||
case AV_CODEC_ID_AV1 : | ||||
c->bit_rate = 0; | ||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); | ||||
if (strstr(info.vcodec.c_str(), "svt_av1") != NULL) { | ||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); | ||||
av_opt_set_int(c->priv_data, "preset", 6, 0); | ||||
av_opt_set_int(c->priv_data, "forced-idr",1,0); | ||||
} | ||||
if (strstr(info.vcodec.c_str(), "rav1e") != NULL) { | ||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),255), 0); | ||||
av_opt_set_int(c->priv_data, "speed", 7, 0); | ||||
av_opt_set_int(c->priv_data, "tile-rows", 2, 0); | ||||
av_opt_set_int(c->priv_data, "tile-columns", 4, 0); | ||||
//av_opt_set(c->priv_data, "tile-row", "", 0); | ||||
} | ||||
if (strstr(info.vcodec.c_str(), "aom") != NULL) { | ||||
// Hack to set tiles; libaom doesn have qp only crf | ||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value),63), 0); | ||||
av_opt_set_int(c->priv_data, "tile-rows", 1, 0); // log2 of number of rows | ||||
av_opt_set_int(c->priv_data, "tile-columns", 2, 0); // log2 of number of columns | ||||
} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Hack to set tiles?" So if I'm understanding this right, when using the // Encode with a CRF of 15 and.... (no? default?) tiling
writer.setOption(VIDEO_STREAM, "crf", 15)
// Encode with a CRF of 15 and tile-rows=1, tile-columns=2
writer.setOption(VIDEO_STREAM, "qp", 15) Is that right? Feels a bit magical for my blood. Is there any reason to do it this way, instead of just setting the |
||||
break; | ||||
} | ||||
#endif | ||||
} else { | ||||
// Set AVOption | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed.