diff --git a/transcode/manifest.go b/transcode/manifest.go index b59951282..5f0bbd13a 100644 --- a/transcode/manifest.go +++ b/transcode/manifest.go @@ -3,6 +3,7 @@ package transcode import ( "fmt" "net/url" + "path" "path/filepath" "sort" "strings" @@ -93,7 +94,7 @@ func GenerateAndUploadManifests(sourceManifest m3u8.MediaPlaylist, targetOSURL s for i, profile := range transcodedStats { // For each profile, add a new entry to the master manifest masterPlaylist.Append( - fmt.Sprintf("rendition-%d/index.m3u8", i), + path.Join(profile.Name, "index.m3u8"), &m3u8.MediaPlaylist{ TargetDuration: sourceManifest.TargetDuration, }, @@ -128,7 +129,7 @@ func GenerateAndUploadManifests(sourceManifest m3u8.MediaPlaylist, targetOSURL s renditionPlaylist.Close() manifestFilename := "index.m3u8" - renditionManifestBaseURL := fmt.Sprintf("%s/rendition-%d", targetOSURL, i) + renditionManifestBaseURL := fmt.Sprintf("%s/%s", targetOSURL, profile.Name) err = clients.UploadToOSURL(renditionManifestBaseURL, manifestFilename, strings.NewReader(renditionPlaylist.String())) if err != nil { return "", fmt.Errorf("failed to upload rendition playlist: %s", err) diff --git a/transcode/transcode.go b/transcode/transcode.go index 36eaa24b2..1e03ad9f3 100644 --- a/transcode/transcode.go +++ b/transcode/transcode.go @@ -95,6 +95,18 @@ func RunTranscodeProcess(transcodeRequest TranscodeSegmentRequest, streamName st } // Go back to the root directory to set as the output for transcode renditions targetTranscodedPath := path.Dir(path.Dir(segmentedOutputManifestURL.Path)) + // Use the same manifest filename that was used for the segmented manifest + targetTranscodedManifestFilename := path.Base(segmentedOutputManifestURL.String()) + // Generate the new output path of the transcoded manifest + targetTranscodedOutputPath := path.Join(targetTranscodedPath, targetTranscodedManifestFilename) + // Generate the manifest output URL from the manifest output path (e.g. s3+https://USER:PASS@storage.googleapis.com/user/hls/index.m3u8) + tpath, err := url.Parse(targetTranscodedOutputPath) + if err != nil { + return outputs, fmt.Errorf("failed to parse targetTranscodedOutputPath: %s", err) + } + targetTranscodedOutputURL := segmentedOutputManifestURL.ResolveReference(tpath) + + // Generate the rendition output URL (e.g. s3+https://USER:PASS@storage.googleapis.com/user/hls/) tout, err := url.Parse(targetTranscodedPath) if err != nil { return outputs, fmt.Errorf("failed to parse targetTranscodedPath: %s", err) @@ -219,7 +231,7 @@ func transcodeSegment(segment segmentInfo, streamName, manifestID string, transc return fmt.Errorf("failed to find profile with name %q while parsing rendition segment", transcodedSegment.Name) } - targetRenditionURL, err := url.JoinPath(targetOSURL.String(), fmt.Sprintf("rendition-%d/", renditionIndex)) + targetRenditionURL, err := url.JoinPath(targetOSURL.String(), transcodedSegment.Name) if err != nil { return fmt.Errorf("error building rendition segment URL %q: %s", targetRenditionURL, err) }