in common/EndpointEncoding.go [111:172]
func JobOutputToEncoding(o *types.JobOutput, presetInfo *types.Preset, contentId int32, titleId int32, fcsId string, urlBase string) *Encoding {
encodingUrl := fmt.Sprintf("%s/%s", urlBase, *o.Key)
//log.Printf("Output file %s has format %s, vcodec %s, acodec %s, vbitrate %s, abitrate %s",
// *o.Key,
// *presetInfo.Container,
// *presetInfo.Video.Codec,
// *presetInfo.Audio.Codec,
// *presetInfo.Video.BitRate,
// *presetInfo.Audio.BitRate,
// )
formatMajor := "audio" //if the "video" part of the preset is configured we switch it to "video"
var bitRateNum int32
if videoPreset := presetInfo.Video; videoPreset != nil {
temp, err := strconv.ParseInt(*videoPreset.BitRate, 10, 32)
if err != nil {
log.Fatalf("Could not convert bitrate string '%s' to number: %s", *videoPreset.BitRate, err)
}
formatMajor = "video"
bitRateNum = int32(temp)
}
var audBitRateNum int32
if audioPreset := presetInfo.Audio; audioPreset != nil {
temp, err := strconv.ParseInt(*audioPreset.BitRate, 10, 32)
if err != nil {
log.Fatalf("Could not convert bitrate string '%s' to number: %s", *audioPreset.BitRate, err)
}
audBitRateNum = int32(temp)
}
var maybeAspectRatio string
if aspect := presetInfo.Video.AspectRatio; aspect != nil {
maybeAspectRatio = *aspect
} else {
maybeAspectRatio = ""
}
formatString := fmt.Sprintf("%s/%s", formatMajor, *presetInfo.Container)
return &Encoding{
EncodingId: GenerateNumericId(),
ContentId: contentId,
Url: encodingUrl,
Format: formatString,
Mobile: false,
Multirate: false,
VCodec: *presetInfo.Video.Codec,
ACodec: *presetInfo.Audio.Codec,
VBitrate: bitRateNum,
ABitrate: audBitRateNum,
LastUpdate: time.Now(),
FrameWidth: *o.Width,
FrameHeight: *o.Height,
Duration: float32(*o.Duration),
FileSize: *o.FileSize,
FCSID: fcsId,
OctopusId: titleId,
Aspect: maybeAspectRatio,
}
}