From 5ccbd7c1c27bb640bf8964a36abe60b4caf2d246 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sun, 12 May 2024 15:58:17 +0300 Subject: [PATCH] Rename param source to video for ffmpeg virtual source --- internal/ffmpeg/ffmpeg.go | 6 ++++++ internal/ffmpeg/virtual/virtual.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/internal/ffmpeg/ffmpeg.go b/internal/ffmpeg/ffmpeg.go index e815f39b..b85185a9 100644 --- a/internal/ffmpeg/ffmpeg.go +++ b/internal/ffmpeg/ffmpeg.go @@ -280,6 +280,12 @@ func parseArgs(s string) *ffmpeg.Args { } } + if query["bitrate"] != nil { + // https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate + b := query["bitrate"][0] + args.AddCodec("-b:v " + b + " -maxrate " + b + " -bufsize " + b) + } + // 4. Process audio codecs if args.Audio > 0 { for _, audio := range query["audio"] { diff --git a/internal/ffmpeg/virtual/virtual.go b/internal/ffmpeg/virtual/virtual.go index 4a791982..2e1dd9bd 100644 --- a/internal/ffmpeg/virtual/virtual.go +++ b/internal/ffmpeg/virtual/virtual.go @@ -11,13 +11,13 @@ func GetInput(src string) (string, error) { } // set defaults (using Add instead of Set) - query.Add("source", "testsrc") + query.Add("video", "testsrc") query.Add("size", "1920x1080") query.Add("decimals", "2") // https://ffmpeg.org/ffmpeg-filters.html - source := query.Get("source") - input := "-re -f lavfi -i " + source + video := query.Get("video") + input := "-re -f lavfi -i " + video sep := "=" // first separator for key, values := range query { @@ -29,18 +29,18 @@ func GetInput(src string) (string, error) { case "size": switch value { case "720": - value = "1280x720" + value = "1280x720" // crf=1 -> 12 Mbps case "1080": - value = "1920x1080" + value = "1920x1080" // crf=1 -> 25 Mbps case "2K": - value = "2560x1440" + value = "2560x1440" // crf=1 -> 43 Mbps case "4K": - value = "3840x2160" + value = "3840x2160" // crf=1 -> 103 Mbps case "8K": value = "7680x4230" // https://reolink.com/blog/8k-resolution/ } case "decimals": - if source != "testsrc" { + if video != "testsrc" { continue } default: