From d6fdaae2d00d4abe54f208b897ee06f0d3ddf4f4 Mon Sep 17 00:00:00 2001 From: gioelecerati <50955448+gioelecerati@users.noreply.github.com> Date: Thu, 19 May 2022 19:41:12 +0200 Subject: [PATCH] Added Content-Resolution to prepare & transcode (#31) * Added Content-Resolution to prepare & transcode * go mod tidy --- go.mod | 2 +- go.sum | 4 ++-- task/prepare.go | 10 +++++++++- task/transcode.go | 9 ++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index de2e20ce..e34e85ef 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/golang/glog v1.0.0 - github.com/livepeer/go-api-client v0.1.2 + github.com/livepeer/go-api-client v0.1.3-0.20220513154150-a37f7c0b5586 github.com/livepeer/go-livepeer v0.5.31-0.20220519163208-13165dd519d4 github.com/livepeer/joy4 v0.1.2-0.20220210094601-95e4d28f5f07 github.com/livepeer/livepeer-data v0.4.14 diff --git a/go.sum b/go.sum index 0961014f..ca059c28 100644 --- a/go.sum +++ b/go.sum @@ -728,8 +728,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/livepeer/go-api-client v0.1.2 h1:PhrkA83vUS+JeOWJlX+XSXwdUVknrbNe9pJs11y/9uI= -github.com/livepeer/go-api-client v0.1.2/go.mod h1:FPgo6hPAEQkWS/Bmepdm+O/LWfurbmym93ghzLueTUo= +github.com/livepeer/go-api-client v0.1.3-0.20220513154150-a37f7c0b5586 h1:27OUb421Vv4YtOOh90dXCWIVxy/3hMqjy5840Q0KbvI= +github.com/livepeer/go-api-client v0.1.3-0.20220513154150-a37f7c0b5586/go.mod h1:FPgo6hPAEQkWS/Bmepdm+O/LWfurbmym93ghzLueTUo= github.com/livepeer/go-livepeer v0.5.31-0.20220519163208-13165dd519d4 h1:bNkqJMaR29XF/GAWmYR54RTmLbGB+OkbTU4aW0iDLmU= github.com/livepeer/go-livepeer v0.5.31-0.20220519163208-13165dd519d4/go.mod h1:g+zTFyc3KUMFbcvN+Q10LO9bQhrzwEbnkCa8Donlbcg= github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded/go.mod h1:xkDdm+akniYxVT9KW1Y2Y7Hso6aW+rZObz3nrA9yTHw= diff --git a/task/prepare.go b/task/prepare.go index 8e6861cc..52a0d5e5 100644 --- a/task/prepare.go +++ b/task/prepare.go @@ -79,6 +79,14 @@ func Prepare(tctx *TaskContext, assetSpec *livepeerAPI.AssetSpec, file io.ReadSe var transcoded [][]byte err = nil + contentResolution := "" + for _, track := range assetSpec.VideoSpec.Tracks { + if track.Type == "video" { + contentResolution = fmt.Sprintf("%dx%d", track.Width, track.Height) + break + } + } + for seg := range segmentsIn { if seg.Err == io.EOF { break @@ -90,7 +98,7 @@ func Prepare(tctx *TaskContext, assetSpec *livepeerAPI.AssetSpec, file io.ReadSe } glog.V(model.VERBOSE).Infof("Got segment seqNo=%d pts=%s dur=%s data len bytes=%d\n", seg.SeqNo, seg.Pts, seg.Duration, len(seg.Data)) started := time.Now() - _, err = lapi.PushSegment(stream.ID, seg.SeqNo, seg.Duration, seg.Data) + _, err = lapi.PushSegment(stream.ID, seg.SeqNo, seg.Duration, seg.Data, contentResolution) if err != nil { glog.Errorf("Error while segment push for prepare err=%v\n", err) break diff --git a/task/transcode.go b/task/transcode.go index b6e6013e..897895ab 100644 --- a/task/transcode.go +++ b/task/transcode.go @@ -161,6 +161,13 @@ func TaskTranscode(tctx *TaskContext) (*data.TaskOutput, error) { outFiles = append(outFiles, mp4muxer) outBuffers = append(outBuffers, ws) var transcoded [][]byte + contentResolution := "" + for _, track := range tctx.InputAsset.AssetSpec.VideoSpec.Tracks { + if track.Type == "video" { + contentResolution = fmt.Sprintf("%dx%d", track.Width, track.Height) + break + } + } err = nil out: for seg := range segmentsIn { @@ -174,7 +181,7 @@ out: } glog.V(model.VERBOSE).Infof("Got segment seqNo=%d pts=%s dur=%s data len bytes=%d\n", seg.SeqNo, seg.Pts, seg.Duration, len(seg.Data)) started := time.Now() - transcoded, err = lapi.PushSegment(stream.ID, seg.SeqNo, seg.Duration, seg.Data) + transcoded, err = lapi.PushSegment(stream.ID, seg.SeqNo, seg.Duration, seg.Data, contentResolution) if err != nil { glog.Errorf("Segment push playbackID=%s err=%v\n", inputPlaybackID, err) break