Skip to content

Commit

Permalink
Revert "video: Avoid copying source for clips"
Browse files Browse the repository at this point in the history
This reverts commit 5c4e430.
  • Loading branch information
victorges committed Jul 19, 2024
1 parent 5c4e430 commit a21f409
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
2 changes: 1 addition & 1 deletion transcode/transcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func RunTranscodeProcess(transcodeRequest TranscodeSegmentRequest, streamName st
sourceManifestOSURL := transcodeRequest.SourceManifestURL

// transcodeProfiles are desired constraints for transcoding process
transcodeProfiles, err := video.SetTranscodeProfiles(inputInfo, transcodeRequest.Profiles, transcodeRequest.IsClip)
transcodeProfiles, err := video.SetTranscodeProfiles(inputInfo, transcodeRequest.Profiles)
if err != nil {
return outputs, segmentsCount, fmt.Errorf("failed to set playback profiles: %w", err)
} else if len(transcodeProfiles) == 0 {
Expand Down
7 changes: 3 additions & 4 deletions video/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var DefaultProfile720p = EncodedProfile{
// DefaultTranscodeProfiles defines the default set of encoding profiles to use when none are specified
var DefaultTranscodeProfiles = []EncodedProfile{DefaultProfile360p, DefaultProfile720p}

func SetTranscodeProfiles(inputVideoStats InputVideo, transcodeProfiles []EncodedProfile, isClip bool) ([]EncodedProfile, error) {
func SetTranscodeProfiles(inputVideoStats InputVideo, transcodeProfiles []EncodedProfile) ([]EncodedProfile, error) {
videoTrack, err := inputVideoStats.GetTrack(TrackTypeVideo)
if err != nil {
return nil, fmt.Errorf("no video track found in input video: %w", err)
Expand All @@ -118,9 +118,8 @@ func SetTranscodeProfiles(inputVideoStats InputVideo, transcodeProfiles []Encode
transcodeProfiles = GenerateSingleProfileWithTargetParams(videoTrack, transcodeProfiles[0])
}
}

// Always copy the source rendition for HLS input unless it's a clip, which needs PTS correction through transcode
copySource := inputVideoStats.Format == "hls" && !isClip
// Always copy the source video for HLS input
copySource := inputVideoStats.Format == "hls"
// If Profiles were not specified, use the default set. Notice that they can come
// as an empty array for no transcoding, which is why we check nil instead of len
if transcodeProfiles == nil {
Expand Down
40 changes: 1 addition & 39 deletions video/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func TestSetTranscodeProfiles(t *testing.T) {
tests := []struct {
name string
input InputVideo
isClip bool
transcodeProfiles []EncodedProfile
want []EncodedProfile
}{
Expand Down Expand Up @@ -275,23 +274,6 @@ func TestSetTranscodeProfiles(t *testing.T) {
transcodeProfiles: []EncodedProfile{},
want: []EncodedProfile{{Name: "720p0", Width: 1280, Height: 720, Bitrate: 3_000_001, Copy: true}},
},
{
name: "does not add copy profile if clip",
input: InputVideo{
Format: "hls",
Tracks: []InputTrack{{
Type: "video",
Bitrate: 3_000_001,
VideoTrack: VideoTrack{
Width: 1280,
Height: 720,
},
}},
},
isClip: true,
transcodeProfiles: []EncodedProfile{{Name: "360p0", Width: 640, Height: 360, Bitrate: 900_000, Quality: 5}},
want: []EncodedProfile{{Name: "360p0", Width: 640, Height: 360, Bitrate: 900_000, Quality: 5}},
},
{
name: "includes copy profile in default profiles if hls input",
input: InputVideo{
Expand All @@ -311,30 +293,10 @@ func TestSetTranscodeProfiles(t *testing.T) {
{Name: "720p0", Width: 1280, Height: 720, Bitrate: 3_000_001, Copy: true},
},
},
{
name: "does not include copy profile in default profiles if clip",
input: InputVideo{
Format: "mp4",
Tracks: []InputTrack{{
Type: "video",
Bitrate: 3_000_001,
VideoTrack: VideoTrack{
Width: 1280,
Height: 720,
},
}},
},
isClip: true,
transcodeProfiles: nil,
want: []EncodedProfile{
{Name: "360p0", Width: 640, Height: 360, Bitrate: 900_000, Quality: DefaultQuality},
{Name: "720p0", Width: 1280, Height: 720, Bitrate: 3_600_001, Quality: DefaultQuality},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := SetTranscodeProfiles(tt.input, tt.transcodeProfiles, tt.isClip)
got, err := SetTranscodeProfiles(tt.input, tt.transcodeProfiles)
require.NoError(t, err)
require.Equal(t, tt.want, got)
})
Expand Down

0 comments on commit a21f409

Please sign in to comment.