mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-04-18 07:03:37 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d590eb788 | |||
| 29fe6fedfb | |||
| ee47832cd6 |
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
# [0.10.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- screenshot save command, see [ScreenshotCmd](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#screenshotcmd)
|
||||||
|
|
||||||
# [0.9.0]
|
# [0.9.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -572,6 +572,25 @@ gobs-cli projector open --monitor-index=1 "test_scene"
|
|||||||
gobs-cli projector open --monitor-index=1 "test_group"
|
gobs-cli projector open --monitor-index=1 "test_group"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ScreenshotCmd
|
||||||
|
|
||||||
|
- save: Take a screenshot and save it to a file.
|
||||||
|
- flags:
|
||||||
|
|
||||||
|
*optional*
|
||||||
|
- --width:
|
||||||
|
- defaults to 1920
|
||||||
|
- --height:
|
||||||
|
- defaults to 1080
|
||||||
|
- --quality:
|
||||||
|
- defaults to -1
|
||||||
|
|
||||||
|
- args: <source_name> <output_path>
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli screenshot save --width=2560 --height=1440 "Scene" "C:\Users\me\Videos\screenshot.png"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
||||||
[obs-keyids]: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h
|
[obs-keyids]: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h
|
||||||
1
main.go
1
main.go
@@ -47,6 +47,7 @@ type CLI struct {
|
|||||||
Hotkey HotkeyCmd `help:"Manage hotkeys." cmd:"" aliases:"hk"`
|
Hotkey HotkeyCmd `help:"Manage hotkeys." cmd:"" aliases:"hk"`
|
||||||
Filter FilterCmd `help:"Manage filters." cmd:"" aliases:"f"`
|
Filter FilterCmd `help:"Manage filters." cmd:"" aliases:"f"`
|
||||||
Projector ProjectorCmd `help:"Manage projectors." cmd:"" aliases:"prj"`
|
Projector ProjectorCmd `help:"Manage projectors." cmd:"" aliases:"prj"`
|
||||||
|
Screenshot ScreenshotCmd `help:"Take screenshots." cmd:"" aliases:"ss"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
|
|||||||
41
screenshot.go
Normal file
41
screenshot.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/andreykaipov/goobs/api/requests/sources"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ScreenshotCmd provides commands to manage screenshots in OBS Studio.
|
||||||
|
type ScreenshotCmd struct {
|
||||||
|
Save ScreenshotSaveCmd `cmd:"" help:"Take a screenshot and save it to a file." aliases:"sv"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScreenshotSaveCmd represents the command to save a screenshot of a source in OBS.
|
||||||
|
type ScreenshotSaveCmd struct {
|
||||||
|
SourceName string `arg:"" help:"Name of the source to take a screenshot of."`
|
||||||
|
FilePath string `arg:"" help:"Path to the file where the screenshot will be saved."`
|
||||||
|
Width float64 ` help:"Width of the screenshot in pixels." flag:"" default:"1920"`
|
||||||
|
Height float64 ` help:"Height of the screenshot in pixels." flag:"" default:"1080"`
|
||||||
|
Quality float64 ` help:"Quality of the screenshot (1-100)." flag:"" default:"-1"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run executes the command to take a screenshot and save it to a file.
|
||||||
|
func (cmd *ScreenshotSaveCmd) Run(ctx *context) error {
|
||||||
|
_, err := ctx.Client.Sources.SaveSourceScreenshot(
|
||||||
|
sources.NewSaveSourceScreenshotParams().
|
||||||
|
WithSourceName(cmd.SourceName).
|
||||||
|
WithImageFormat(trimPrefix(filepath.Ext(cmd.FilePath), ".")).
|
||||||
|
WithImageFilePath(cmd.FilePath).
|
||||||
|
WithImageWidth(cmd.Width).
|
||||||
|
WithImageHeight(cmd.Height).
|
||||||
|
WithImageCompressionQuality(cmd.Quality),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to take screenshot: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(ctx.Out, "Screenshot saved to %s.\n", cmd.FilePath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user