func PosterFrameNamesForEncoding()

in transcodelauncher/posterframe_filename.go [14:35]


func PosterFrameNamesForEncoding(encodingKey string, imageXtn string) (string, string, error) {
	xtnRipper := regexp.MustCompile("^(.*)\\.([^.]+)")
	fileBase := path.Base(encodingKey)

	parts := xtnRipper.FindAllStringSubmatch(fileBase, -1)
	if parts == nil {
		return "", "", errors.New("encoding name had no file extension or was malformed")
	}

	fileBaseNoXtn := parts[0][1]

	//we assume that the filename is delimited by _
	fileElemts := strings.Split(fileBaseNoXtn, "_")
	if len(fileElemts) < 1 {
		return "", "", errors.New("encoding name was malformed, had no _ characters")
	}
	//so, the "_{encoding}" is the _last_ element of 'fileElemts'

	leadingPortion := strings.Join(fileElemts[0:len(fileElemts)-1], "_")
	trailingPortion := fileElemts[len(fileElemts)-1]
	return path.Dir(encodingKey) + "/" + leadingPortion + "_00001_" + trailingPortion + imageXtn, leadingPortion + "_" + trailingPortion + "_poster" + imageXtn, nil
}