This commit is contained in:
49
backend_v1/pkg/utils/ffmpeg_test.go
Normal file
49
backend_v1/pkg/utils/ffmpeg_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/rogeecn/fabfile"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func Test_GetMediaDuration(t *testing.T) {
|
||||
Convey("test_get_media_duration", t, func() {
|
||||
target := fabfile.MustFind("fixtures/input.mp4")
|
||||
duration, err := GetMediaDuration(target)
|
||||
So(err, ShouldBeNil)
|
||||
t.Logf("duration is: %d", duration)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CutMedia(t *testing.T) {
|
||||
Convey("test_cut_media", t, func() {
|
||||
input := fabfile.MustFind("fixtures/input.mp4")
|
||||
output := fabfile.MustFind("fixtures/output.mp4")
|
||||
|
||||
t.Logf("INPUT: %s", input)
|
||||
t.Logf("OUTPUT: %s", output)
|
||||
|
||||
err := CutMedia(input, output, 0, 10)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// check output duration
|
||||
duration, err := GetMediaDuration(output)
|
||||
So(err, ShouldBeNil)
|
||||
t.Logf("output duration is: %d", duration)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_GetFrameImageFromVideo(t *testing.T) {
|
||||
Convey("test_get_frame_image_from_video", t, func() {
|
||||
input := fabfile.MustFind("fixtures/input.mp4")
|
||||
output := filepath.Join(filepath.Dir(input), "output.jpg")
|
||||
|
||||
t.Logf("INPUT: %s", input)
|
||||
t.Logf("OUTPUT: %s", output)
|
||||
|
||||
err := GetFrameImageFromVideo(input, output, 1)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user