50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
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)
|
|
})
|
|
}
|