Comprehensive documentation for accessing the DWARF camera streams:
- RTSP URLs and channels (ch0=tele, ch1=wide)
- The critical prerequisite: camera must be opened via WebSocket first
- ffmpeg commands for frame capture, timelapse, and video recording
- mpv and VLC usage with TCP transport
- Python/OpenCV integration example
- Troubleshooting common issues (black image, connection refused, VLC delay)
- Comparison of RTSP vs MJPEG modes across device models
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
72 lines
1.7 KiB
Go
72 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"time"
|
|
|
|
"github.com/antitbone/dwarfctl/internal/api"
|
|
)
|
|
|
|
func main() {
|
|
ip := "192.168.88.1"
|
|
if len(os.Args) > 1 {
|
|
ip = os.Args[1]
|
|
}
|
|
|
|
scope := api.New("rtsp-test")
|
|
scope.SetDebug(true)
|
|
fmt.Println("Connecting to", ip)
|
|
if err := scope.Connect(ip); err != nil {
|
|
die("connect: %v", err)
|
|
}
|
|
defer scope.Close()
|
|
|
|
fmt.Println("Opening wide camera...")
|
|
if err := scope.OpenCamera(api.CameraWide); err != nil {
|
|
die("open camera: %v", err)
|
|
}
|
|
fmt.Println("Wide camera opened. Waiting 3s for stream to initialize...")
|
|
time.Sleep(3 * time.Second)
|
|
|
|
url := fmt.Sprintf("rtsp://%s:554/ch1/stream0", ip)
|
|
out := "/tmp/rtsp_test_frame.jpg"
|
|
fmt.Println("Grabbing frame via ffmpeg...")
|
|
cmd := exec.Command("ffmpeg", "-rtsp_transport", "tcp",
|
|
"-i", url, "-frames:v", "1", "-q:v", "2", "-y", out)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
if err := cmd.Run(); err != nil {
|
|
die("ffmpeg: %v", err)
|
|
}
|
|
|
|
info, _ := os.Stat(out)
|
|
if info != nil {
|
|
fmt.Printf("SUCCESS: frame saved (%d bytes)\n", info.Size())
|
|
}
|
|
|
|
// Also try tele
|
|
fmt.Println("\nOpening tele camera...")
|
|
if err := scope.OpenCamera(api.CameraTele); err != nil {
|
|
die("open tele: %v", err)
|
|
}
|
|
time.Sleep(3 * time.Second)
|
|
url0 := fmt.Sprintf("rtsp://%s:554/ch0/stream0", ip)
|
|
out0 := "/tmp/rtsp_test_tele.jpg"
|
|
fmt.Println("Grabbing tele frame...")
|
|
cmd0 := exec.Command("ffmpeg", "-rtsp_transport", "tcp",
|
|
"-i", url0, "-frames:v", "1", "-q:v", "2", "-y", out0)
|
|
cmd0.Stdout = os.Stdout
|
|
cmd0.Stderr = os.Stderr
|
|
cmd0.Run()
|
|
if i, _ := os.Stat(out0); i != nil {
|
|
fmt.Printf("SUCCESS: tele frame saved (%d bytes)\n", i.Size())
|
|
}
|
|
}
|
|
|
|
func die(format string, args ...any) {
|
|
fmt.Fprintf(os.Stderr, "ERROR: "+format+"\n", args...)
|
|
os.Exit(1)
|
|
}
|