Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable preview mode #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Flags:
--horizontal-flip horizontally flip video
-v, --version version for raspilive
--vertical-flip vertically flip video
--no-preview disable preview mode
--width int video width (default 1280)

Use "raspilive [command] --help" for more information about a command.
Expand Down Expand Up @@ -63,6 +64,7 @@ Global Flags:
--horizontal-flip horizontally flip video
--vertical-flip vertically flip video
--width int video width (default 1280)
--no-preview disable preview mode
```

#### DASH
Expand Down
2 changes: 2 additions & 0 deletions cmd/raspilive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type VideoCfg struct {
Fps int
HorizontalFlip bool
VerticalFlip bool
NoPreview bool
}

func main() {
Expand Down Expand Up @@ -47,6 +48,7 @@ func main() {
rootCmd.PersistentFlags().IntVar(&video.Fps, "fps", 30, "video framerate")
rootCmd.PersistentFlags().BoolVar(&video.HorizontalFlip, "horizontal-flip", false, "horizontally flip video")
rootCmd.PersistentFlags().BoolVar(&video.VerticalFlip, "vertical-flip", false, "vertically flip video")
rootCmd.PersistentFlags().BoolVar(&video.NoPreview, "no-preview", false, "disable preview mode")
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug logging")

rootCmd.Execute()
Expand Down
7 changes: 6 additions & 1 deletion internal/raspivid/raspivid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options struct {
Fps int // Framerate of the video
HorizontalFlip bool // Flip the video horizontally
VerticalFlip bool // Flip the video vertically
NoPreview bool // Disable preview mode
}

// Stream represents a Raspberry Pi camera video streamer.
Expand All @@ -41,14 +42,18 @@ func NewStream(options Options) (*Stream, error) {
if options.Fps != 0 {
args = append(args, "--framerate", strconv.Itoa(options.Fps))
}

if options.HorizontalFlip {
args = append(args, "--hflip")
}

if options.VerticalFlip {
args = append(args, "--vflip")
}

if options.NoPreview != 0 {
args = append(args, "--nopreview")
}

cmd := execCommand("raspivid", args...)
video, err := cmd.StdoutPipe()
Expand Down
5 changes: 3 additions & 2 deletions internal/raspivid/raspivid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ func TestNewStream(t *testing.T) {
},
},
{
Options{Width: 1280, Height: 720, Fps: 30, HorizontalFlip: true, VerticalFlip: true},
Options{Width: 1280, Height: 720, Fps: 30, HorizontalFlip: true, VerticalFlip: true, NoPreview: true},
[]string{
"raspivid",
"-o", "-",
"-t", "0",
"--width", "1280",
"--height", "720",
"--framerate", "30",
"--hflip", "--vflip",
"--hflip", "--vflip",
"--no-preview"
},
},
}
Expand Down