SHA256
Add CBR, VBR, and CQP Bitrate Control Options and Dynamic UI Generation
This commit is contained in:
1 parent
d7ca416980
commit
c6356a28f0
7 files changed
+222
-33
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using ADOFAIRenderer.Core;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
@@ -55,14 +56,49 @@ namespace ADOFAIRenderer.Util.FFmpeg
|
||||
VideoCodec = codec;
|
||||
}
|
||||
|
||||
public void Start(string path, float bitrate)
|
||||
public void Start(string path, RenderManager.BitrateControlMode mode, int bitrate, int maxBitrate, int qp)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
var command = "-y -f rawvideo -vcodec rawvideo -pixel_format rgba -colorspace rgb -color_range 2 -video_size " + Width + "x" + Height + " -framerate " + FrameRate + " -threads 4 -loglevel quiet -i - " + Codec2String(VideoCodec) + " -pix_fmt yuv420p -fps_mode cfr " + " -r " + VideoFPS + $" -b:v {(int)bitrate}k" + " \"" + path + "\"";
|
||||
|
||||
string bitrateArgs = mode switch
|
||||
{
|
||||
RenderManager.BitrateControlMode.CBR => $"-b:v {bitrate}k -minrate {bitrate}k -maxrate {bitrate}k -bufsize {bitrate * 2}k",
|
||||
RenderManager.BitrateControlMode.VBR => $"-b:v {bitrate}k -maxrate {maxBitrate}k -bufsize {maxBitrate * 2}k",
|
||||
RenderManager.BitrateControlMode.CQP => GetCqpArgs(VideoCodec, qp),
|
||||
_ => $"-b:v {bitrate}k"
|
||||
};
|
||||
|
||||
var command = "-y -f rawvideo -vcodec rawvideo -pixel_format rgba -colorspace rgb -color_range 2 -video_size " +
|
||||
Width + "x" + Height + " -framerate " + FrameRate + " -threads 4 -loglevel quiet -i - " +
|
||||
Codec2String(VideoCodec) + " " + bitrateArgs + " -pix_fmt yuv420p -fps_mode cfr -r " +
|
||||
VideoFPS + " \"" + path + "\"";
|
||||
|
||||
Execute(command);
|
||||
}
|
||||
|
||||
private static string GetCqpArgs(Codec codec, int qp)
|
||||
{
|
||||
return codec switch
|
||||
{
|
||||
Codec.H264_NVIDIA => $"-rc constqp -qp {qp}",
|
||||
Codec.HEVC_NVIDIA => $"-rc constqp -qp {qp}",
|
||||
Codec.AV1_NVIDIA => $"-rc constqp -qp {qp}",
|
||||
Codec.VP9_NVIDIA => $"-rc constqp -qp {qp}",
|
||||
|
||||
Codec.H264_QSV => $"-global_quality {qp}",
|
||||
Codec.HEVC_QSV => $"-global_quality {qp}",
|
||||
Codec.AV1_QSV => $"-global_quality {qp}",
|
||||
|
||||
Codec.H264_Default => $"-crf {qp}",
|
||||
Codec.HEVC_Default => $"-crf {qp}",
|
||||
Codec.AV1_Default => $"-crf {qp}",
|
||||
Codec.VP9_Default => $"-crf {qp}",
|
||||
|
||||
_ => $"-qp {qp}"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user