Browse Source

playback: make 'format' parameter optional (#2980)

pull/2987/head
Alessandro Ros 1 year ago committed by GitHub
parent
commit
695e327a03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      README.md
  2. 2
      internal/playback/server.go

9
README.md

@ -1224,7 +1224,7 @@ Where [mypath] is the name of a path. The server will return a list of timespans @@ -1224,7 +1224,7 @@ Where [mypath] is the name of a path. The server will return a list of timespans
The server provides an endpoint for downloading recordings:
```
http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]&format=[format]
http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]
```
Where:
@ -1232,19 +1232,18 @@ Where: @@ -1232,19 +1232,18 @@ Where:
* [mypath] is the path name
* [start_date] is the start date in RFC3339 format
* [duration] is the maximum duration of the recording in seconds
* [format] must be fmp4
All parameters must be [url-encoded](https://www.urlencoder.org/). For instance:
```
http://localhost:9996/get?path=stream2&start=2024-01-14T16%3A33%3A17%2B00%3A00&duration=200.5&format=fmp4
http://localhost:9996/get?path=stream2&start=2024-01-14T16%3A33%3A17%2B00%3A00&duration=200.5
```
The resulting stream is natively compatible with any browser, therefore its URL can be directly inserted into a \<video> tag:
The resulting stream uses the fMP4 format, that is natively compatible with any browser, therefore its URL can be directly inserted into a \<video> tag:
```html
<video controls>
<source src="http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]&format=[format]" type="video/mp4" />
<source src="http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]" type="video/mp4" />
</video>
```

2
internal/playback/server.go

@ -190,7 +190,7 @@ func (p *Server) onGet(ctx *gin.Context) { @@ -190,7 +190,7 @@ func (p *Server) onGet(ctx *gin.Context) {
}
format := ctx.Query("format")
if format != "fmp4" {
if format != "" && format != "fmp4" {
p.writeError(ctx, http.StatusBadRequest, fmt.Errorf("invalid format: %s", format))
return
}

Loading…
Cancel
Save