Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live-ai: Update to use FLV-enabled LPMS #3288

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,4 @@ COPY --from=build /usr/bin/grpc_health_probe /usr/local/bin/grpc_health_probe
COPY --from=build /src/tasmodel.pb /tasmodel.pb
COPY --from=build /usr/share/misc/pci.ids /usr/share/misc/pci.ids

RUN apt update && apt install -yqq ffmpeg

ENTRYPOINT ["/usr/local/bin/livepeer"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/livepeer/ai-worker v0.12.6
github.com/livepeer/go-tools v0.3.6-0.20240130205227-92479de8531b
github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18
github.com/livepeer/lpms v0.0.0-20241122145837-7b07ba3a2204
github.com/livepeer/lpms v0.0.0-20241203012405-fc96cadb6393
github.com/livepeer/m3u8 v0.11.1
github.com/mattn/go-sqlite3 v1.14.18
github.com/oapi-codegen/nethttp-middleware v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded h1:ZQlvR5RB4nfT+cO
github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded/go.mod h1:xkDdm+akniYxVT9KW1Y2Y7Hso6aW+rZObz3nrA9yTHw=
github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18 h1:4oH3NqV0NvcdS44Ld3zK2tO8IUiNozIggm74yobQeZg=
github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18/go.mod h1:Jpf4jHK+fbWioBHRDRM1WadNT1qmY27g2YicTdO0Rtc=
github.com/livepeer/lpms v0.0.0-20241122145837-7b07ba3a2204 h1:YalnQu8BB9vRh+7gcEjfzfHNl9NEwagBTHQqnlUYDrA=
github.com/livepeer/lpms v0.0.0-20241122145837-7b07ba3a2204/go.mod h1:z5ROP1l5OzAKSoqVRLc34MjUdueil6wHSecQYV7llIw=
github.com/livepeer/lpms v0.0.0-20241203012405-fc96cadb6393 h1:aoDFI66Kj1pQueka93PLY59WlnI7jy4cJUfPxteIgCE=
github.com/livepeer/lpms v0.0.0-20241203012405-fc96cadb6393/go.mod h1:z5ROP1l5OzAKSoqVRLc34MjUdueil6wHSecQYV7llIw=
github.com/livepeer/m3u8 v0.11.1 h1:VkUJzfNTyjy9mqsgp5JPvouwna8wGZMvd/gAfT5FinU=
github.com/livepeer/m3u8 v0.11.1/go.mod h1:IUqAtwWPAG2CblfQa4SVzTQoDcEMPyfNOaBSxqHMS04=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
Expand Down
2 changes: 1 addition & 1 deletion install_ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
echo 'WARNING: downloading and executing lpms/install_ffmpeg.sh, use it directly in case of issues'
curl https://raw.githubusercontent.com/livepeer/lpms/ffde2327537517b3345162e9544704571bc58a34/install_ffmpeg.sh | bash -s $1
curl https://raw.githubusercontent.com/livepeer/lpms/b33cac634b43d2ecd160224417daf8e920b0f500/install_ffmpeg.sh | bash -s $1
27 changes: 13 additions & 14 deletions server/ai_live_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"net/http"
"net/url"
"os"
"os/exec"
"time"

"github.com/livepeer/go-livepeer/clog"
"github.com/livepeer/go-livepeer/core"
"github.com/livepeer/go-livepeer/media"
"github.com/livepeer/go-livepeer/trickle"
"github.com/livepeer/lpms/ffmpeg"
)

func startTricklePublish(url *url.URL, params aiRequestParams) {
Expand Down Expand Up @@ -69,23 +69,22 @@
}
}()

// TODO: Change this to LPMS
go func() {
defer r.Close()
retryCount := 0
// TODO check whether stream is actually terminated
// so we aren't just looping unnecessarily

Check warning on line 76 in server/ai_live_video.go

View check run for this annotation

Codecov / codecov/patch

server/ai_live_video.go#L75-L76

Added lines #L75 - L76 were not covered by tests
for retryCount < 10 {
cmd := exec.Command("ffmpeg",
"-i", "pipe:0",
"-c:a", "copy",
"-c:v", "copy",
"-f", "flv",
params.liveParams.outputRTMPURL,
)
cmd.Stdin = r
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
clog.Infof(ctx, "Error running trickle subscribe ffmpeg: %s", err)
_, err := ffmpeg.Transcode3(&ffmpeg.TranscodeOptionsIn{
Fname: fmt.Sprintf("pipe:%d", r.Fd()),
}, []ffmpeg.TranscodeOptions{{
Oname: params.liveParams.outputRTMPURL,
AudioEncoder: ffmpeg.ComponentOptions{Name: "copy"},
VideoEncoder: ffmpeg.ComponentOptions{Name: "copy"},
Muxer: ffmpeg.ComponentOptions{Name: "flv"},
}})
if err != nil {
clog.Infof(ctx, "Error sending RTMP out: %s", err)

Check warning on line 87 in server/ai_live_video.go

View check run for this annotation

Codecov / codecov/patch

server/ai_live_video.go#L78-L87

Added lines #L78 - L87 were not covered by tests
}
retryCount++
time.Sleep(5 * time.Second)
Expand Down
Loading