Skip to content

Commit

Permalink
zencoder: use input to construct mediainfo instead of output[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioribeiro committed Oct 30, 2016
1 parent 1bf0c41 commit ede3cd5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 5 additions & 7 deletions provider/zencoder/zencoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,17 @@ func (z *zencoderProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
}, nil
}

// we are debating if this field still makes sense or not.
// refs #107
func (z *zencoderProvider) getMediaInfo(jobID int64) (provider.MediaInfo, error) {
jobDetails, err := z.client.GetJobDetails(jobID)
if err != nil {
return provider.MediaInfo{}, err
}
firstMediaFile := jobDetails.Job.OutputMediaFiles[0]
inputMediaFile := jobDetails.Job.InputMediaFile
return provider.MediaInfo{
Duration: time.Duration(firstMediaFile.DurationInMs * 1000),
Height: int64(firstMediaFile.Height),
Width: int64(firstMediaFile.Width),
VideoCodec: firstMediaFile.VideoCodec,
Duration: time.Duration(inputMediaFile.DurationInMs * 1000),
Height: int64(inputMediaFile.Height),
Width: int64(inputMediaFile.Width),
VideoCodec: inputMediaFile.VideoCodec,
}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions provider/zencoder/zencoder_fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func (z *FakeZencoder) GetJobProgress(id int64) (*zencoderClient.JobProgress, er
func (z *FakeZencoder) GetJobDetails(id int64) (*zencoderClient.JobDetails, error) {
return &zencoderClient.JobDetails{
Job: &zencoderClient.Job{
InputMediaFile: &zencoderClient.MediaFile{
Url: "http://nyt.net/input.mov",
Format: "mov",
VideoCodec: "ProRes422",
Width: 1920,
Height: 1080,
DurationInMs: 10000,
},
OutputMediaFiles: []*zencoderClient.MediaFile{
{
Url: "http://nyt.net/output1.mp4",
Expand Down
2 changes: 1 addition & 1 deletion provider/zencoder/zencoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func TestZencoderJobStatus(t *testing.T) {
"duration": float64(10000000),
"height": float64(1080),
"width": float64(1920),
"videoCodec": "h264",
"videoCodec": "ProRes422",
},
"output": map[string]interface{}{
"files": []interface{}{
Expand Down

0 comments on commit ede3cd5

Please sign in to comment.