Make quality configurable

Signed-off-by: Daniel Widerin <daniel@widerin.net>
This commit is contained in:
Daniel Widerin 2020-10-25 01:10:18 +02:00
parent 7b64627baa
commit 0ad37313d2
No known key found for this signature in database
GPG Key ID: F75B6C110ED4EF65
3 changed files with 10 additions and 2 deletions

View File

@ -32,6 +32,7 @@ library which made this wrapper possible.
--port value VNC port (default: 5900) [$VR_VNC_PORT]
--password value Password to connect to the VNC host (default: "secret") [$VR_VNC_PASSWORD]
--framerate value Framerate to record (default: 30) [$VR_FRAMERATE]
--crf value Constant Rate Factor (CRF) to record with (default: 35) [$VR_CRF]
--outfile value Output file to record to. (default: "output.mp4") [$VR_OUTFILE]
--help, -h show help
--version, -v print the version

View File

@ -112,6 +112,7 @@ type X264ImageCustomEncoder struct {
input io.WriteCloser
closed bool
Framerate int
ConstantRateFactor int
}
func (enc *X264ImageCustomEncoder) Init(videoFileName string) {
@ -126,10 +127,9 @@ func (enc *X264ImageCustomEncoder) Init(videoFileName string) {
"-y",
"-i", "-",
"-vcodec", "libx264",
"-threads", "8",
"-preset", "veryfast",
"-g", "250",
"-crf", "37",
"-crf", strconv.Itoa(enc.ConstantRateFactor),
videoFileName,
)
cmd.Stdout = os.Stdout

View File

@ -64,6 +64,12 @@ func main() {
Usage: "Framerate to record",
EnvVars: []string{"VR_FRAMERATE"},
},
&cli.IntFlag{
Name: "crf",
Value: 35,
Usage: "Constant Rate Factor (CRF) to record with",
EnvVars: []string{"VR_CRF"},
},
&cli.StringFlag{
Name: "outfile",
Value: "output.mp4",
@ -143,6 +149,7 @@ func recorder(c *cli.Context) error {
vcodec := &X264ImageCustomEncoder{
FFMpegBinPath: ffmpeg_path,
Framerate: c.Int("framerate"),
ConstantRateFactor: c.Int("crf"),
}
//goland:noinspection GoUnhandledErrorResult