Skip to content

Commit

Permalink
Rename param source to video for ffmpeg virtual source
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 12, 2024
1 parent 778245d commit 5ccbd7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions internal/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"] {
Expand Down
16 changes: 8 additions & 8 deletions internal/ffmpeg/virtual/virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down

0 comments on commit 5ccbd7c

Please sign in to comment.