Created
October 29, 2016 01:54
-
-
Save flavioribeiro/f040c6063ac8a2ff5cd9935c8dba581a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git provider/zencoder/zencoder.go provider/zencoder/zencoder.go | |
| index d1b0daa..2ff8060 100644 | |
| --- provider/zencoder/zencoder.go | |
| +++ provider/zencoder/zencoder.go | |
| @@ -78,42 +78,49 @@ func (z *zencoderProvider) buildOutputs(transcodeProfile provider.TranscodeProfi | |
| return nil, fmt.Errorf("Error getting localpreset: %s", err.Error()) | |
| } | |
| localPresetStruct := localPresetOutput.(*db.LocalPreset) | |
| - preset := localPresetStruct.Preset | |
| - zencoderOutput := zencoder.OutputSettings{ | |
| - Label: preset.Name + ":" + preset.Description, | |
| - Format: preset.Container, | |
| - VideoCodec: preset.Video.Codec, | |
| - AudioCodec: preset.Audio.Codec, | |
| - } | |
| - width, err := strconv.ParseInt(preset.Video.Width, 10, 32) | |
| - zencoderOutput.Width = int32(width) | |
| - height, err := strconv.ParseInt(preset.Video.Height, 10, 32) | |
| - zencoderOutput.Height = int32(height) | |
| - videoBitrate, err := strconv.ParseInt(preset.Video.Bitrate, 10, 32) | |
| - zencoderOutput.VideoBitrate = int32(videoBitrate) | |
| - keyframeInterval, err := strconv.ParseInt(preset.Video.GopSize, 10, 32) | |
| - zencoderOutput.KeyframeInterval = int32(keyframeInterval) | |
| - audioBitrate, err := strconv.ParseInt(preset.Audio.Bitrate, 10, 32) | |
| - zencoderOutput.AudioBitrate = int32(audioBitrate) | |
| + zencoderOutput, err := z.buildOutput(localPresetStruct.Preset) | |
| if err != nil { | |
| return nil, err | |
| } | |
| - if preset.Video.GopMode == "fixed" { | |
| - zencoderOutput.FixedKeyframeInterval = true | |
| - } | |
| - if preset.Video.Codec == "h264" { | |
| - zencoderOutput.H264Profile = preset.Profile | |
| - zencoderOutput.H264Level = preset.ProfileLevel | |
| - } | |
| - if preset.RateControl == "CBR" { | |
| - zencoderOutput.ConstantBitrate = true | |
| - } | |
| - zencoderOutput.Deinterlace = "on" | |
| zencoderOutputs = append(zencoderOutputs, &zencoderOutput) | |
| } | |
| return zencoderOutputs, nil | |
| } | |
| +func (z *zencoderProvider) buildOutput(preset db.Preset) (zencoder.OutputSettings, error) { | |
| + zencoderOutput := zencoder.OutputSettings{ | |
| + Label: preset.Name + ":" + preset.Description, | |
| + Format: preset.Container, | |
| + VideoCodec: preset.Video.Codec, | |
| + AudioCodec: preset.Audio.Codec, | |
| + } | |
| + width, err := strconv.ParseInt(preset.Video.Width, 10, 32) | |
| + zencoderOutput.Width = int32(width) | |
| + height, err := strconv.ParseInt(preset.Video.Height, 10, 32) | |
| + zencoderOutput.Height = int32(height) | |
| + videoBitrate, err := strconv.ParseInt(preset.Video.Bitrate, 10, 32) | |
| + zencoderOutput.VideoBitrate = int32(videoBitrate) | |
| + keyframeInterval, err := strconv.ParseInt(preset.Video.GopSize, 10, 32) | |
| + zencoderOutput.KeyframeInterval = int32(keyframeInterval) | |
| + audioBitrate, err := strconv.ParseInt(preset.Audio.Bitrate, 10, 32) | |
| + zencoderOutput.AudioBitrate = int32(audioBitrate) | |
| + if err != nil { | |
| + return zencoder.OutputSettings{}, err | |
| + } | |
| + if preset.Video.GopMode == "fixed" { | |
| + zencoderOutput.FixedKeyframeInterval = true | |
| + } | |
| + if preset.Video.Codec == "h264" { | |
| + zencoderOutput.H264Profile = preset.Profile | |
| + zencoderOutput.H264Level = preset.ProfileLevel | |
| + } | |
| + if preset.RateControl == "CBR" { | |
| + zencoderOutput.ConstantBitrate = true | |
| + } | |
| + zencoderOutput.Deinterlace = "on" | |
| + return zencoderOutput, nil | |
| +} | |
| + | |
| func (z *zencoderProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) { | |
| return &provider.JobStatus{}, nil | |
| } | |
| diff --git provider/zencoder/zencoder_test.go provider/zencoder/zencoder_test.go | |
| index f71c06c..76767a1 100644 | |
| --- provider/zencoder/zencoder_test.go | |
| +++ provider/zencoder/zencoder_test.go | |
| @@ -286,6 +286,30 @@ func TestZencoderTranscode(t *testing.T) { | |
| } | |
| } | |
| +func TestZencoderBuildOutput(t *testing.T) { | |
| + prov := &zencoderProvider{} | |
| + preset := db.Preset{ | |
| + Name: "mp4_1080p", | |
| + Description: "my nice preset", | |
| + Container: "mp4", | |
| + Profile: "main", | |
| + ProfileLevel: "3.1", | |
| + RateControl: "VBR", | |
| + Video: db.VideoPreset{ | |
| + Bitrate: "3500000", | |
| + Codec: "h264", | |
| + GopMode: "fixed", | |
| + GopSize: "90", | |
| + Height: "1080", | |
| + }, | |
| + Audio: db.AudioPreset{Bitrate: "128000", Codec: "aac"}, | |
| + } | |
| + _, err := prov.buildOutput(preset) | |
| + if err != nil { | |
| + t.Fatal(err) | |
| + } | |
| +} | |
| + | |
| func cleanLocalPresets() error { | |
| client := redisDriver.NewClient(&redisDriver.Options{Addr: "127.0.0.1:6379"}) | |
| defer client.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment