46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package streamer
|
|
|
|
import (
|
|
"fmt"
|
|
"live-streamer/config"
|
|
"log"
|
|
)
|
|
|
|
func buildFFmpegArgs(videoItem config.InputItem) []string {
|
|
videoPath := videoItem.Path
|
|
|
|
args := []string{"-re"}
|
|
if videoItem.Start != "" {
|
|
args = append(args, "-ss", videoItem.Start)
|
|
}
|
|
|
|
if videoItem.End != "" {
|
|
args = append(args, "-to", videoItem.End)
|
|
}
|
|
|
|
args = append(args,
|
|
"-i", videoPath,
|
|
"-c:v", config.GlobalConfig.Play.VideoCodec,
|
|
"-preset", config.GlobalConfig.Play.Preset,
|
|
"-crf", fmt.Sprintf("%d", config.GlobalConfig.Play.CRF),
|
|
"-maxrate", config.GlobalConfig.Play.MaxRate,
|
|
"-bufsize", config.GlobalConfig.Play.BufSize,
|
|
"-vf", fmt.Sprintf("scale=%s", config.GlobalConfig.Play.Scale),
|
|
"-r", fmt.Sprintf("%d", config.GlobalConfig.Play.FrameRate),
|
|
"-c:a", config.GlobalConfig.Play.AudioCodec,
|
|
"-b:a", config.GlobalConfig.Play.AudioBitrate,
|
|
"-ar", fmt.Sprintf("%d", config.GlobalConfig.Play.AudioSampleRate),
|
|
"-f", config.GlobalConfig.Play.OutputFormat,
|
|
)
|
|
|
|
if len(config.GlobalConfig.Play.CustomArgs) != 0 {
|
|
args = append(args, config.GlobalConfig.Play.CustomArgs...)
|
|
}
|
|
|
|
args = append(args, fmt.Sprintf("%s/%s", config.GlobalConfig.Output.RTMPServer, config.GlobalConfig.Output.StreamKey))
|
|
|
|
log.Println("ffmpeg args: ", args)
|
|
|
|
return args
|
|
}
|