-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added onne more thing to attempt prevention of the %2 error for H264
Also added test
- Loading branch information
Showing
3 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package transcode_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bcc-code/bcc-media-flows/paths" | ||
"github.com/bcc-code/bcc-media-flows/services/ffmpeg" | ||
"github.com/bcc-code/bcc-media-flows/services/transcode" | ||
"github.com/bcc-code/bcc-media-flows/utils" | ||
"github.com/bcc-code/bcc-media-flows/utils/testutils" | ||
"github.com/davecgh/go-spew/spew" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_H264_WeirdResolutions(t *testing.T) { | ||
testFile := paths.MustParse("./testdata/generated/h264_weird_resolutions.mov") | ||
|
||
testutils.GenerateVideoFile(testFile, testutils.VideoGeneratorParams{ | ||
DAR: "16/9", | ||
SAR: "608/405", | ||
Width: 720, | ||
Height: 608, | ||
Duration: 5, | ||
FrameRate: 25, | ||
}) | ||
|
||
progressCallback := func(i ffmpeg.Progress) { | ||
spew.Dump(i) | ||
} | ||
|
||
r, err := transcode.H264(transcode.H264EncodeInput{ | ||
Bitrate: "320k", | ||
Resolution: &utils.Resolution{ | ||
Width: 320, | ||
Height: 180, | ||
}, | ||
FrameRate: 0, | ||
FilePath: testFile.Local(), | ||
OutputDir: testFile.Dir().Local(), | ||
}, progressCallback) | ||
|
||
assert.NoError(t, err) | ||
assert.NotNil(t, r) | ||
spew.Dump(r) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package testutils | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
|
||
"github.com/bcc-code/bcc-media-flows/paths" | ||
) | ||
|
||
type VideoGeneratorParams struct { | ||
Duration float64 | ||
FrameRate int | ||
Width int | ||
Height int | ||
SAR string | ||
DAR string | ||
} | ||
|
||
func GenerateVideoFile(outFile paths.Path, videoParams VideoGeneratorParams) paths.Path { | ||
args := []string{ | ||
"-f", "lavfi", | ||
"-i", fmt.Sprintf("color=c=blue:s=720x608:d=%f", videoParams.Duration), | ||
"-vf", fmt.Sprintf("setsar=%s, setdar=%s", videoParams.SAR, videoParams.DAR), | ||
"-r", fmt.Sprintf("%d", videoParams.FrameRate), | ||
"-c:v", "prores_ks", | ||
"-profile:v", "3", | ||
"-y", outFile.Local(), | ||
} | ||
|
||
cmd := exec.Command("ffmpeg", args...) | ||
err := cmd.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return outFile | ||
} |