mirror of https://bitbucket.org/ausocean/av.git
cmd/revid-cli & revid: fixed conflict
This commit is contained in:
commit
93e856792d
|
@ -110,23 +110,24 @@ func handleFlags() revid.Config {
|
|||
rtmpMethodPtr = flag.String("RtmpMethod", "", "The method used to send over rtmp: Ffmpeg, Librtmp")
|
||||
quantizePtr = flag.Bool("Quantize", false, "Quantize input (non-variable bitrate)")
|
||||
verbosityPtr = flag.String("Verbosity", "Info", "Verbosity: Debug, Info, Warning, Error, Fatal")
|
||||
framesPerClipPtr = flag.Uint("FramesPerClip", 0, "Number of frames per clip sent")
|
||||
rtmpUrlPtr = flag.String("RtmpUrl", "", "Url of rtmp endpoint")
|
||||
bitratePtr = flag.Uint("Bitrate", 0, "Bitrate of recorded video")
|
||||
outputPathPtr = flag.String("OutputPath", "", "The directory of the output file")
|
||||
inputFilePtr = flag.String("InputPath", "", "The directory of the input file")
|
||||
heightPtr = flag.Uint("Height", 0, "Height in pixels")
|
||||
widthPtr = flag.Uint("Width", 0, "Width in pixels")
|
||||
frameRatePtr = flag.Uint("FrameRate", 0, "Frame rate of captured video")
|
||||
httpAddressPtr = flag.String("HttpAddress", "", "Destination address of http posts")
|
||||
quantizationPtr = flag.Uint("Quantization", 0, "Desired quantization value: 0-40")
|
||||
intraRefreshPeriodPtr = flag.Uint("IntraRefreshPeriod", 0, "The IntraRefreshPeriod i.e. how many keyframes we send")
|
||||
verticalFlipPtr = flag.Bool("VerticalFlip", false, "Flip video vertically: Yes, No")
|
||||
horizontalFlipPtr = flag.Bool("HorizontalFlip", false, "Flip video horizontally: Yes, No")
|
||||
rtpAddrPtr = flag.String("RtpAddr", "", "Rtp destination address: <IP>:<port> (port is generally 6970-6999)")
|
||||
logPathPtr = flag.String("LogPath", defaultLogPath, "The log path")
|
||||
configFilePtr = flag.String("ConfigFile", "", "NetSender config file")
|
||||
rtmpUrlPtr = flag.String("RtmpUrl", "", "Url of rtmp endpoint")
|
||||
outputPathPtr = flag.String("OutputPath", "", "The directory of the output file")
|
||||
inputFilePtr = flag.String("InputPath", "", "The directory of the input file")
|
||||
httpAddressPtr = flag.String("HttpAddress", "", "Destination address of http posts")
|
||||
sendRetryPtr = flag.Bool("retry", false, "Specify whether a failed send should be retried.")
|
||||
verticalFlipPtr = flag.Bool("VerticalFlip", false, "Flip video vertically: Yes, No")
|
||||
horizontalFlipPtr = flag.Bool("HorizontalFlip", false, "Flip video horizontally: Yes, No")
|
||||
framesPerClipPtr = flag.Uint("FramesPerClip", 0, "Number of frames per clip sent")
|
||||
bitratePtr = flag.Uint("Bitrate", 0, "Bitrate of recorded video")
|
||||
heightPtr = flag.Uint("Height", 0, "Height in pixels")
|
||||
widthPtr = flag.Uint("Width", 0, "Width in pixels")
|
||||
frameRatePtr = flag.Uint("FrameRate", 0, "Frame rate of captured video")
|
||||
quantizationPtr = flag.Uint("Quantization", 0, "Desired quantization value: 0-40")
|
||||
intraRefreshPeriodPtr = flag.Uint("IntraRefreshPeriod", 0, "The IntraRefreshPeriod i.e. how many keyframes we send")
|
||||
rotationPtr = flag.Uint("Rotatation", 0, "Rotate video output. (0-359 degrees)")
|
||||
)
|
||||
|
||||
var outputs flagStrings
|
||||
|
@ -223,6 +224,7 @@ func handleFlags() revid.Config {
|
|||
}
|
||||
|
||||
cfg.Quantize = *quantizePtr
|
||||
cfg.Rotation = *rotationPtr
|
||||
cfg.FlipHorizontal = *horizontalFlipPtr
|
||||
cfg.FlipVertical = *verticalFlipPtr
|
||||
cfg.FramesPerClip = *framesPerClipPtr
|
||||
|
@ -251,10 +253,10 @@ func run(cfg revid.Config) {
|
|||
readPin := func(pin *netsender.Pin) error {
|
||||
switch {
|
||||
case pin.Name == "X23":
|
||||
if rv == nil {
|
||||
pin.Value = -1
|
||||
pin.Value = -1
|
||||
if rv != nil {
|
||||
pin.Value = rv.Bitrate()
|
||||
}
|
||||
pin.Value = rv.Bitrate()
|
||||
case pin.Name[0] == 'X':
|
||||
return sds.ReadSystem(pin)
|
||||
default:
|
||||
|
|
|
@ -69,6 +69,7 @@ type Config struct {
|
|||
Logger Logger
|
||||
SendRetry bool
|
||||
BurstPeriod uint
|
||||
Rotation uint
|
||||
}
|
||||
|
||||
// Enums for config struct
|
||||
|
@ -113,6 +114,7 @@ const (
|
|||
defaultInputCodec = H264
|
||||
defaultRtpAddr = "localhost:6970"
|
||||
defaultBurstPeriod = 10 // Seconds
|
||||
defaultRotation = 0 // Degrees
|
||||
)
|
||||
|
||||
// Validate checks for any errors in the config fields and defaults settings
|
||||
|
@ -200,6 +202,11 @@ func (c *Config) Validate(r *Revid) error {
|
|||
c.FramesPerClip = defaultFramesPerClip
|
||||
}
|
||||
|
||||
if c.Rotation > 359 {
|
||||
c.Logger.Log(logger.Warning, pkg+"bad rotate angle, defaulting", "angle", defaultRotation)
|
||||
c.Rotation = defaultRotation
|
||||
}
|
||||
|
||||
if c.Width == 0 {
|
||||
c.Logger.Log(logger.Info, pkg+"no width defined, defaulting", "width", defaultWidth)
|
||||
c.Width = defaultWidth
|
||||
|
|
|
@ -370,6 +370,15 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
break
|
||||
}
|
||||
r.config.FrameRate = uint(v)
|
||||
case "Rotation":
|
||||
v, err := strconv.ParseUint(value, 10, 0)
|
||||
if err != nil || v > 359 {
|
||||
r.config.Logger.Log(logger.Warning, pkg+"invalid rotation param", "value", value)
|
||||
break
|
||||
}
|
||||
r.config.Rotation = uint(v)
|
||||
case "HttpAddress":
|
||||
r.config.HttpAddress = value
|
||||
case "Quantization":
|
||||
q, err := strconv.ParseUint(value, 10, 0)
|
||||
if err != nil {
|
||||
|
@ -384,6 +393,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
break
|
||||
}
|
||||
r.config.IntraRefreshPeriod = uint(p)
|
||||
|
||||
case "HorizontalFlip":
|
||||
switch strings.ToLower(value) {
|
||||
case "true":
|
||||
|
@ -481,13 +491,16 @@ func (r *Revid) startRaspivid() error {
|
|||
"--height", fmt.Sprint(r.config.Height),
|
||||
"--bitrate", fmt.Sprint(r.config.Bitrate),
|
||||
"--framerate", fmt.Sprint(r.config.FrameRate),
|
||||
"--rotation", fmt.Sprint(r.config.Rotation),
|
||||
}
|
||||
|
||||
if r.config.FlipVertical {
|
||||
args = append(args, "--vflip")
|
||||
}
|
||||
if r.config.FlipHorizontal {
|
||||
args = append(args, "--hflip")
|
||||
}
|
||||
if r.config.FlipVertical {
|
||||
args = append(args, "--vflip")
|
||||
}
|
||||
|
||||
switch r.config.InputCodec {
|
||||
default:
|
||||
return fmt.Errorf("revid: invalid input codec: %v", r.config.InputCodec)
|
||||
|
@ -534,14 +547,7 @@ func (r *Revid) startV4L() error {
|
|||
"-f", "h264",
|
||||
"-r", fmt.Sprint(r.config.FrameRate),
|
||||
}
|
||||
switch {
|
||||
case r.config.FlipHorizontal && r.config.FlipVertical:
|
||||
args = append(args, "-vf", "hflip,vflip")
|
||||
case r.config.FlipHorizontal:
|
||||
args = append(args, "-vf", "hflip")
|
||||
case r.config.FlipVertical:
|
||||
args = append(args, "-vf", "vflip")
|
||||
}
|
||||
|
||||
args = append(args,
|
||||
"-b:v", fmt.Sprint(r.config.Bitrate),
|
||||
"-maxrate", fmt.Sprint(r.config.Bitrate),
|
||||
|
|
Loading…
Reference in New Issue