Skip to content

Commit 2ad0ded

Browse files
authored
Merge branch 'master' into feat-logging-to-file
2 parents 7fd0ec8 + 1ab05e5 commit 2ad0ded

File tree

197 files changed

+7347
-2355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+7347
-2355
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Setup Go
2121
uses: actions/setup-go@v5
22-
with: { go-version: '1.21' }
22+
with: { go-version: '1.22' }
2323

2424
- name: Build go2rtc_win64
2525
env: { GOOS: windows, GOARCH: amd64 }
@@ -29,7 +29,7 @@ jobs:
2929
with: { name: go2rtc_win64, path: go2rtc.exe }
3030

3131
- name: Build go2rtc_win32
32-
env: { GOOS: windows, GOARCH: 386 }
32+
env: { GOOS: windows, GOARCH: 386, GOTOOLCHAIN: go1.20.14 }
3333
run: go build -ldflags "-s -w" -trimpath
3434
- name: Upload go2rtc_win32
3535
uses: actions/upload-artifact@v4
@@ -85,7 +85,7 @@ jobs:
8585
with: { name: go2rtc_linux_mipsel, path: go2rtc }
8686

8787
- name: Build go2rtc_mac_amd64
88-
env: { GOOS: darwin, GOARCH: amd64 }
88+
env: { GOOS: darwin, GOARCH: amd64, GOTOOLCHAIN: go1.20.14 }
8989
run: go build -ldflags "-s -w" -trimpath
9090
- name: Upload go2rtc_mac_amd64
9191
uses: actions/upload-artifact@v4
@@ -102,14 +102,14 @@ jobs:
102102
env: { GOOS: freebsd, GOARCH: amd64 }
103103
run: go build -ldflags "-s -w" -trimpath
104104
- name: Upload go2rtc_freebsd_amd64
105-
uses: actions/upload-artifact@v3
105+
uses: actions/upload-artifact@v4
106106
with: { name: go2rtc_freebsd_amd64, path: go2rtc }
107107

108108
- name: Build go2rtc_freebsd_arm64
109109
env: { GOOS: freebsd, GOARCH: arm64 }
110110
run: go build -ldflags "-s -w" -trimpath
111111
- name: Upload go2rtc_freebsd_arm64
112-
uses: actions/upload-artifact@v3
112+
uses: actions/upload-artifact@v4
113113
with: { name: go2rtc_freebsd_arm64, path: go2rtc }
114114

115115
docker-master:
@@ -123,7 +123,9 @@ jobs:
123123
id: meta
124124
uses: docker/metadata-action@v5
125125
with:
126-
images: ${{ github.repository }}
126+
images: |
127+
${{ github.repository }}
128+
ghcr.io/${{ github.repository }}
127129
tags: |
128130
type=ref,event=branch
129131
type=semver,pattern={{version}},enable=false
@@ -142,13 +144,22 @@ jobs:
142144
username: ${{ secrets.DOCKERHUB_USERNAME }}
143145
password: ${{ secrets.DOCKERHUB_TOKEN }}
144146

147+
- name: Login to GitHub Container Registry
148+
if: github.event_name != 'pull_request'
149+
uses: docker/login-action@v3
150+
with:
151+
registry: ghcr.io
152+
username: ${{ github.actor }}
153+
password: ${{ secrets.GITHUB_TOKEN }}
154+
145155
- name: Build and push
146156
uses: docker/build-push-action@v5
147157
with:
148158
context: .
149159
platforms: |
150160
linux/amd64
151161
linux/386
162+
linux/arm/v6
152163
linux/arm/v7
153164
linux/arm64/v8
154165
push: ${{ github.event_name != 'pull_request' }}
@@ -168,7 +179,9 @@ jobs:
168179
id: meta-hw
169180
uses: docker/metadata-action@v5
170181
with:
171-
images: ${{ github.repository }}
182+
images: |
183+
${{ github.repository }}
184+
ghcr.io/${{ github.repository }}
172185
flavor: |
173186
suffix=-hardware,onlatest=true
174187
latest=auto
@@ -189,6 +202,14 @@ jobs:
189202
with:
190203
username: ${{ secrets.DOCKERHUB_USERNAME }}
191204
password: ${{ secrets.DOCKERHUB_TOKEN }}
205+
206+
- name: Login to GitHub Container Registry
207+
if: github.event_name != 'pull_request'
208+
uses: docker/login-action@v3
209+
with:
210+
registry: ghcr.io
211+
username: ${{ github.actor }}
212+
password: ${{ secrets.GITHUB_TOKEN }}
192213

193214
- name: Build and push
194215
uses: docker/build-push-action@v5

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Go
2727
uses: actions/setup-go@v5
2828
with:
29-
go-version: '1.21'
29+
go-version: '1.22'
3030

3131
- name: Build Go binary
3232
run: go build -ldflags "-s -w" -trimpath -o ./go2rtc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
go2rtc.yaml
55
go2rtc.json
66

7+
go2rtc_freebsd*
78
go2rtc_linux*
89
go2rtc_mac*
910
go2rtc_win*

Dockerfile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
# 0. Prepare images
44
ARG PYTHON_VERSION="3.11"
5-
ARG GO_VERSION="1.21"
6-
ARG NGROK_VERSION="3"
5+
ARG GO_VERSION="1.22"
76

8-
FROM python:${PYTHON_VERSION}-alpine AS base
9-
FROM ngrok/ngrok:${NGROK_VERSION}-alpine AS ngrok
107

8+
# 1. Download ngrok binary (for support arm/v6)
9+
FROM alpine AS ngrok
10+
ARG TARGETARCH
11+
ARG TARGETOS
12+
13+
ADD https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz /
14+
RUN tar -xzf /ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz -C /bin
1115

12-
# 1. Build go2rtc binary
16+
17+
# 2. Build go2rtc binary
1318
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
1419
ARG TARGETPLATFORM
1520
ARG TARGETOS
@@ -30,21 +35,14 @@ COPY . .
3035
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
3136

3237

33-
# 2. Collect all files
34-
FROM scratch AS rootfs
35-
36-
COPY --from=build /build/go2rtc /usr/local/bin/
37-
COPY --from=ngrok /bin/ngrok /usr/local/bin/
38-
39-
4038
# 3. Final image
41-
FROM base
39+
FROM python:${PYTHON_VERSION}-alpine AS base
4240

4341
# Install ffmpeg, tini (for signal handling),
4442
# and other common tools for the echo source.
4543
# alsa-plugins-pulse for ALSA support (+0MB)
4644
# font-droid for FFmpeg drawtext filter (+2MB)
47-
RUN apk add --no-cache tini ffmpeg bash curl jq alsa-plugins-pulse font-droid
45+
RUN apk add --no-cache tini ffmpeg ffplay bash curl jq alsa-plugins-pulse font-droid
4846

4947
# Hardware Acceleration for Intel CPU (+50MB)
5048
ARG TARGETARCH
@@ -56,7 +54,8 @@ RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver
5654
# Hardware: AMD and NVidia VDPAU (not sure about this)
5755
# RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total)
5856

59-
COPY --from=rootfs / /
57+
COPY --from=build /build/go2rtc /usr/local/bin/
58+
COPY --from=ngrok /bin/ngrok /usr/local/bin/
6059

6160
ENTRYPOINT ["/sbin/tini", "--"]
6261
VOLUME /config

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,19 @@ Ultimate camera streaming application with support RTSP, WebRTC, HomeKit, FFmpeg
115115

116116
Download binary for your OS from [latest release](https://github.com/AlexxIT/go2rtc/releases/):
117117

118-
- `go2rtc_win64.zip` - Windows 64-bit
119-
- `go2rtc_win32.zip` - Windows 32-bit
118+
- `go2rtc_win64.zip` - Windows 10+ 64-bit
119+
- `go2rtc_win32.zip` - Windows 7+ 32-bit
120120
- `go2rtc_win_arm64.zip` - Windows ARM 64-bit
121121
- `go2rtc_linux_amd64` - Linux 64-bit
122122
- `go2rtc_linux_i386` - Linux 32-bit
123123
- `go2rtc_linux_arm64` - Linux ARM 64-bit (ex. Raspberry 64-bit OS)
124124
- `go2rtc_linux_arm` - Linux ARM 32-bit (ex. Raspberry 32-bit OS)
125125
- `go2rtc_linux_armv6` - Linux ARMv6 (for old Raspberry 1 and Zero)
126126
- `go2rtc_linux_mipsel` - Linux MIPS (ex. [Xiaomi Gateway 3](https://github.com/AlexxIT/XiaomiGateway3), [Wyze cameras](https://github.com/gtxaspec/wz_mini_hacks))
127-
- `go2rtc_mac_amd64.zip` - Mac Intel 64-bit
128-
- `go2rtc_mac_arm64.zip` - Mac ARM 64-bit
127+
- `go2rtc_mac_amd64.zip` - macOS 10.13+ Intel 64-bit
128+
- `go2rtc_mac_arm64.zip` - macOS ARM 64-bit
129+
- `go2rtc_freebsd_amd64.zip` - FreeBSD 64-bit
130+
- `go2rtc_freebsd_arm64.zip` - FreeBSD ARM 64-bit
129131

130132
Don't forget to fix the rights `chmod +x go2rtc_xxx_xxx` on Linux and Mac.
131133

@@ -170,7 +172,7 @@ Available modules:
170172
- [api](#module-api) - HTTP API (important for WebRTC support)
171173
- [rtsp](#module-rtsp) - RTSP Server (important for FFmpeg support)
172174
- [webrtc](#module-webrtc) - WebRTC Server
173-
- [mp4](#module-mp4) - MSE, MP4 stream and MP4 shapshot Server
175+
- [mp4](#module-mp4) - MSE, MP4 stream and MP4 snapshot Server
174176
- [hls](#module-hls) - HLS TS or fMP4 stream Server
175177
- [mjpeg](#module-mjpeg) - MJPEG Server
176178
- [ffmpeg](#source-ffmpeg) - FFmpeg integration
@@ -648,10 +650,11 @@ This source type support Roborock vacuums with cameras. Known working models:
648650

649651
- Roborock S6 MaxV - only video (the vacuum has no microphone)
650652
- Roborock S7 MaxV - video and two way audio
653+
- Roborock Qrevo MaxV - video and two way audio
651654

652-
Source support load Roborock credentials from Home Assistant [custom integration](https://github.com/humbertogontijo/homeassistant-roborock). Otherwise, you need to log in to your Roborock account (MiHome account is not supported). Go to: go2rtc WebUI > Add webpage. Copy `roborock://...` source for your vacuum and paste it to `go2rtc.yaml` config.
655+
Source support load Roborock credentials from Home Assistant [custom integration](https://github.com/humbertogontijo/homeassistant-roborock) or the [core integration](https://www.home-assistant.io/integrations/roborock). Otherwise, you need to log in to your Roborock account (MiHome account is not supported). Go to: go2rtc WebUI > Add webpage. Copy `roborock://...` source for your vacuum and paste it to `go2rtc.yaml` config.
653656

654-
If you have graphic pin for your vacuum - add it as numeric pin (lines: 123, 456, 678) to the end of the roborock-link.
657+
If you have graphic pin for your vacuum - add it as numeric pin (lines: 123, 456, 789) to the end of the roborock-link.
655658

656659
#### Source: WebRTC
657660

@@ -880,7 +883,7 @@ Read more about [codecs filters](#codecs-filters).
880883

881884
You can get any stream as RTMP-stream: `rtmp://192.168.1.123/{stream_name}`. Only H264/AAC codecs supported right now.
882885

883-
[Incoming stream](#incoming-sources) in RTMP-format tested only with [OBS Studio](https://obsproject.com/) and Dahua camera. Different FFmpeg versions has differnt problems with this format.
886+
[Incoming stream](#incoming-sources) in RTMP-format tested only with [OBS Studio](https://obsproject.com/) and Dahua camera. Different FFmpeg versions has different problems with this format.
884887

885888
```yaml
886889
rtmp:

examples/go2rtc_mjpeg/main.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"github.com/AlexxIT/go2rtc/internal/api"
5+
"github.com/AlexxIT/go2rtc/internal/api/ws"
6+
"github.com/AlexxIT/go2rtc/internal/app"
7+
"github.com/AlexxIT/go2rtc/internal/ffmpeg"
8+
"github.com/AlexxIT/go2rtc/internal/mjpeg"
9+
"github.com/AlexxIT/go2rtc/internal/streams"
10+
"github.com/AlexxIT/go2rtc/internal/v4l2"
11+
"github.com/AlexxIT/go2rtc/pkg/shell"
12+
)
13+
14+
func main() {
15+
app.Init()
16+
streams.Init()
17+
18+
api.Init()
19+
ws.Init()
20+
21+
ffmpeg.Init()
22+
mjpeg.Init()
23+
v4l2.Init()
24+
25+
shell.RunUntilSignal()
26+
}

examples/onvif_client/main.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"net"
6+
"net/url"
7+
"os"
8+
9+
"github.com/AlexxIT/go2rtc/pkg/onvif"
10+
)
11+
12+
func main() {
13+
var rawURL = os.Args[1]
14+
var operation = os.Args[2]
15+
var token string
16+
if len(os.Args) > 3 {
17+
token = os.Args[3]
18+
}
19+
20+
client, err := onvif.NewClient(rawURL)
21+
if err != nil {
22+
log.Panic(err)
23+
}
24+
25+
var b []byte
26+
27+
switch operation {
28+
case onvif.ServiceGetServiceCapabilities:
29+
b, err = client.MediaRequest(operation)
30+
case onvif.DeviceGetCapabilities,
31+
onvif.DeviceGetDeviceInformation,
32+
onvif.DeviceGetDiscoveryMode,
33+
onvif.DeviceGetDNS,
34+
onvif.DeviceGetHostname,
35+
onvif.DeviceGetNetworkDefaultGateway,
36+
onvif.DeviceGetNetworkInterfaces,
37+
onvif.DeviceGetNetworkProtocols,
38+
onvif.DeviceGetNTP,
39+
onvif.DeviceGetScopes,
40+
onvif.DeviceGetServices,
41+
onvif.DeviceGetSystemDateAndTime,
42+
onvif.DeviceSystemReboot:
43+
b, err = client.DeviceRequest(operation)
44+
case onvif.MediaGetProfiles, onvif.MediaGetVideoSources:
45+
b, err = client.MediaRequest(operation)
46+
case onvif.MediaGetProfile:
47+
b, err = client.GetProfile(token)
48+
case onvif.MediaGetVideoSourceConfiguration:
49+
b, err = client.GetVideoSourceConfiguration(token)
50+
case onvif.MediaGetStreamUri:
51+
b, err = client.GetStreamUri(token)
52+
case onvif.MediaGetSnapshotUri:
53+
b, err = client.GetSnapshotUri(token)
54+
default:
55+
log.Printf("unknown action\n")
56+
}
57+
58+
if err != nil {
59+
log.Printf("%s\n", err)
60+
}
61+
62+
u, err := url.Parse(rawURL)
63+
if err != nil {
64+
log.Fatal(err)
65+
}
66+
67+
host, _, _ := net.SplitHostPort(u.Host)
68+
69+
if err = os.WriteFile(host+"_"+operation+".xml", b, 0644); err != nil {
70+
log.Printf("%s\n", err)
71+
}
72+
}

examples/rtsp_client/main.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"os"
6+
7+
"github.com/AlexxIT/go2rtc/pkg/core"
8+
"github.com/AlexxIT/go2rtc/pkg/rtsp"
9+
"github.com/AlexxIT/go2rtc/pkg/shell"
10+
)
11+
12+
func main() {
13+
client := rtsp.NewClient(os.Args[1])
14+
if err := client.Dial(); err != nil {
15+
log.Panic(err)
16+
}
17+
18+
client.Medias = []*core.Media{
19+
{
20+
Kind: core.KindAudio,
21+
Direction: core.DirectionRecvonly,
22+
Codecs: []*core.Codec{
23+
{Name: core.CodecPCMU, ClockRate: 8000},
24+
},
25+
ID: "streamid=0",
26+
},
27+
}
28+
if err := client.Announce(); err != nil {
29+
log.Panic(err)
30+
}
31+
if _, err := client.SetupMedia(client.Medias[0]); err != nil {
32+
log.Panic(err)
33+
}
34+
if err := client.Record(); err != nil {
35+
log.Panic(err)
36+
}
37+
38+
shell.RunUntilSignal()
39+
}

0 commit comments

Comments
 (0)