Skip to content

Commit

Permalink
Recording update (#5)
Browse files Browse the repository at this point in the history
* update recording api

* update docs

* double url param
  • Loading branch information
frostbyte73 authored Oct 8, 2021
1 parent d85ea73 commit d1f5468
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 29 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ USAGE:
livekit-cli [global options] command [command options] [arguments...]

VERSION:
0.6.0
0.6.1

COMMANDS:
create-token creates an access token
Expand All @@ -38,9 +38,11 @@ COMMANDS:
remove-participant
mute-track
update-subscriptions
join-room joins a room as a client
start-recording starts a recording with a deployed recorder service
end-recording
join-room Joins a room as a client
start-recording Starts a recording with a deployed recorder service
add-output Adds an rtmp output url to a live recording
remove-output Removes an rtmp output url from a live recording
end-recording Ends a recording
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
Expand All @@ -65,7 +67,7 @@ This will publish the pre-encoded ivf and ogg files to the room, indicating vide

### Recording

Recording requires a [recorder-service](https://docs.livekit.io/guides/recording/#service) to be set up first
Recording requires a [recorder service](https://docs.livekit.io/guides/recording/#service) to be set up first.

```shell
% ./bin/livekit-cli start-recording --help
Expand All @@ -79,23 +81,19 @@ OPTIONS:
--url value url to LiveKit instance (default: "http://localhost:7880") [$LIVEKIT_URL]
--api-key value [$LIVEKIT_API_KEY]
--api-secret value [$LIVEKIT_API_SECRET]
--request value StartRecordingRequest as json file (see https://github.com/livekit/protocol/blob/main/livekit_recording.proto#L16)
--request value StartRecordingRequest as json file (see https://github.com/livekit/livekit-recorder#request)
--help, -h show help (default: false)
```

Sample `request` config file:
Sample `request` json file:

```json
{
"input": {
"template": {
"layout": "speaker-dark",
"token": "token"
}
},
"output": {
"s3_path": "bucket/key"
}
"layout": "speaker-dark",
"token": "token"
},
"s3_url": "s3://bucket/path/filename.mp4"
}
```

Expand All @@ -110,7 +108,7 @@ USAGE:
livekit-load-tester [global options] command [command options] [arguments...]

VERSION:
0.5.0
0.6.1

COMMANDS:
help, h Shows a list of commands or help for one command
Expand Down
67 changes: 63 additions & 4 deletions cmd/livekit-cli/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
RecordCommands = []*cli.Command{
{
Name: "start-recording",
Usage: "starts a recording with a deployed recorder service",
Usage: "Starts a recording with a deployed recorder service",
Before: createRecordingClient,
Action: startRecording,
Flags: []cli.Flag{
Expand All @@ -25,13 +25,56 @@ var (
secretFlag,
&cli.StringFlag{
Name: "request",
Usage: "StartRecordingRequest as json file (see https://github.com/livekit/protocol/blob/main/livekit_recording.proto#L16)",
Usage: "StartRecordingRequest as json file (see https://github.com/livekit/livekit-recorder#request)",
Required: true,
},
},
},
{
Name: "add-output",
Usage: "Adds an rtmp output url to a live recording",
Before: createRecordingClient,
Action: addOutput,
Flags: []cli.Flag{
urlFlag,
apiKeyFlag,
secretFlag,
&cli.StringFlag{
Name: "id",
Usage: "id of the recording",
Required: true,
},
&cli.StringFlag{
Name: "rtmp-url",
Usage: "rtmp url to add",
Required: true,
},
},
},
{
Name: "remove-output",
Usage: "Removes an rtmp output url from a live recording",
Before: createRecordingClient,
Action: removeOutput,
Flags: []cli.Flag{
urlFlag,
apiKeyFlag,
secretFlag,
&cli.StringFlag{
Name: "id",
Usage: "id of the recording",
Required: true,
},
&cli.StringFlag{
Name: "rtmp-url",
Usage: "rtmp url to remove",
Required: true,
},
},
},
{
Name: "end-recording",
Usage: "Ends a recording",
Before: createRecordingClient,
Action: endRecording,
Flags: []cli.Flag{
Expand Down Expand Up @@ -82,15 +125,31 @@ func startRecording(c *cli.Context) error {
PrintJSON(req)
}

resp, err := recordingClient.StartRecording(context.Background(), req)
res, err := recordingClient.StartRecording(context.Background(), req)
if err != nil {
return err
}

fmt.Printf("Recording started. Recording ID: %s\n", resp.RecordingId)
fmt.Printf("Recording started. Recording ID: %s\n", res.RecordingId)
return nil
}

func addOutput(c *cli.Context) error {
_, err := recordingClient.AddOutput(context.Background(), &livekit.AddOutputRequest{
RecordingId: c.String("id"),
RtmpUrl: c.String("rtmp-url"),
})
return err
}

func removeOutput(c *cli.Context) error {
_, err := recordingClient.RemoveOutput(context.Background(), &livekit.RemoveOutputRequest{
RecordingId: c.String("id"),
RtmpUrl: c.String("rtmp-url"),
})
return err
}

func endRecording(c *cli.Context) error {
_, err := recordingClient.EndRecording(context.Background(), &livekit.EndRecordingRequest{
RecordingId: c.String("id"),
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.16

require (
github.com/ggwhite/go-masker v1.0.4
github.com/livekit/protocol v0.9.1
github.com/livekit/server-sdk-go v0.7.0
github.com/livekit/protocol v0.9.7-0.20211007223925-84fa102af619
github.com/livekit/server-sdk-go v0.7.2-0.20211007231855-a254a8409c5f
github.com/pion/webrtc/v3 v3.0.32
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8=
github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
github.com/livekit/protocol v0.9.1 h1:Ebt17AbmDux5Exc6xmk2uixuQoYxqRMhXNQGeaJ7Xrk=
github.com/livekit/protocol v0.9.1/go.mod h1:MEKn847Iu/2U8ClZyUmEm2oHn8k9fnSHy81Wv8kkSDo=
github.com/livekit/server-sdk-go v0.6.4-0.20210920204647-b86db5df6621 h1:qPMPB44P5a5tB7kVAItn+uZLevv7Ot97givQH4cvF4Y=
github.com/livekit/server-sdk-go v0.6.4-0.20210920204647-b86db5df6621/go.mod h1:byn6x4nvsVUmlkkNzxIAURvQMgdxZfTku18Y2qVE6bs=
github.com/livekit/server-sdk-go v0.7.0 h1:mN2W2Jekl36/3MpbA++CP/W84+9rbSARvPM7JSWgBoQ=
github.com/livekit/server-sdk-go v0.7.0/go.mod h1:byn6x4nvsVUmlkkNzxIAURvQMgdxZfTku18Y2qVE6bs=
github.com/livekit/protocol v0.9.7-0.20211007223925-84fa102af619 h1:aHbHAXnlUAHJfCyOd/zy1Kr2wtEcj2H0dx2eEm0YNsw=
github.com/livekit/protocol v0.9.7-0.20211007223925-84fa102af619/go.mod h1:MEKn847Iu/2U8ClZyUmEm2oHn8k9fnSHy81Wv8kkSDo=
github.com/livekit/server-sdk-go v0.7.2-0.20211007231855-a254a8409c5f h1:4kv4Y0eeO35jS/gnQlOCFVjkgmvZMu+DRhpDxC3mIoY=
github.com/livekit/server-sdk-go v0.7.2-0.20211007231855-a254a8409c5f/go.mod h1:pzi+WhiUCSKxWNsHjeBIE1PkA85bgcSdVOr+Ou9bPSM=
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0/go.mod h1:fcEyUyXZXoV4Abw8DX0t7wyL8mCDxXyU4iAFZfT3IHw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package livekit_cli

const (
Version = "0.6.0"
Version = "0.6.1"
)

0 comments on commit d1f5468

Please sign in to comment.