Skip to content

Commit

Permalink
upd readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LdDl committed Jul 17, 2020
1 parent 446e6c1 commit af27cf1
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.vscode/
*.exe
cmd/video_server/video_server
cmd/video_server/hls/*
cmd/video_server/video_server.exe
cmd/video_server/hls/*
example_client/mse_example/node_modules
example_client/mse_example/.nuxt
example_client/mse_example/package-lock.json
example_client/hls_example/node_modules
example_client/hls_example/.nuxt
example_client/hls_example/package-lock.json
67 changes: 59 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## Table of Contents

- [About](#about)
- [Requirements](#requirements)
- [Installation](#installation)
- [go get](#go-get)
- [Binaries](#binaries)
- [From source](#from-source)
- [Usage](#usage)
- [Server](#start-server)
- [Client](#test-client-server)
Expand All @@ -13,19 +15,68 @@


## About
@todo

## Requirements
@todo
Simple WS/HTTP server for re-streaming video (RTSP) to client in MSE/HLS format.

## Instalation
@todo
### Go get
Install it via go get:
```shell
go install github.com/LdDl/video-server/...
```

### Binaries
Windows - [link]()

Linux - [link]()

### From source
```bash
go get github.com/LdDl/video-server
# or just clone it
# git clone https://github.com/LdDl/video-server.git
```
Go to root folder of downloaded repository, move to cmd/video_server folder:
```bash
cd $CLONED_PATH/cmd/video_server
go build -o video_server main.go
```

## Usage
```shell
video_server -h
```
```shell
-conf string
Path to configuration JSON-file (default "conf.json")
-cpuprofile file
write cpu profile to file
-memprofile file
write memory profile to file
```

### Start server
@todo
Prepare configuration file (example [here](cmd/video_server/conf.json)). Then run binary:
```shell
video_server --conf=conf.json
```
### Test Client-Server
@todo
For HLS-based player go to [hls-subdirectory](example_client/hls_example).

For MSE-based (websockets) player go to [mse-subdirectory](mse_example/hls_example).

Then follow this set of commands:
```shell
npm install
npm run dev
```

You will se something like this after succesfull fron-end start:
```shell
DONE Compiled successfully in 1783ms 12:09:30 PM
App running at:
- Local: http://localhost:8080/
```
Paste link to the browser and check if video loaded successfully.

## Dependencies
GIN web-framework - [https://github.com/gin-gonic/gin](https://github.com/gin-gonic/gin). License is [MIT](https://github.com/gin-gonic/gin/blob/master/LICENSE)
Expand Down
6 changes: 5 additions & 1 deletion cmd/video_server/conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"server": {
"http_port": ":36136"
"http_port": ":8090"
},
"hlsMsPerSegment": 10000,
"hlsDirectory": "./hls",
"hlsWindowSize": 5,
"hlsWindowCapacity" : 10,
"streams": [
{
"guid": "c2680f08-07cc-4dee-9231-685893e2661f",
Expand Down
3 changes: 2 additions & 1 deletion hls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (element *AppConfiguration) startHls(streamID uuid.UUID, ch chan av.Packet,

// Create playlist for HLS streams
playlistFileName := filepath.Join(element.HlsDirectory, fmt.Sprintf("%s.m3u8", streamID))
fmt.Println("Need to start HLS:", playlistFileName, element.HlsDirectory)
log.Printf("Need to start HLS: %s\n", playlistFileName)
playlist, err := m3u8.NewMediaPlaylist(element.HlsWindowSize, element.HlsCapacity)
if err != nil {
return errors.Wrap(err, "Can't create new mediaplayer list")
Expand Down Expand Up @@ -116,6 +116,7 @@ func (element *AppConfiguration) startHls(streamID uuid.UUID, ch chan av.Packet,
}
playlistFile.Write(playlist.Encode().Bytes())
playlistFile.Close()
log.Printf("m3u8 file has been re-created: %s\n", playlistFileName)

// Cleanup segments
if err := element.removeOutdatedSegments(streamID, playlist); err != nil {
Expand Down

0 comments on commit af27cf1

Please sign in to comment.