diff --git a/video.go b/video.go index 52fa8f9..504013b 100644 --- a/video.go +++ b/video.go @@ -309,6 +309,10 @@ func (video *Video) ReadFrame(n int) error { // Read the N-amount of frames with the given indexes and return them as a slice of buffers. If one of // the indexes is out of range, the function will return an error. The frames are indexes from 0. func (video *Video) ReadFrames(n ...int) ([][]byte, error) { + if len(n) == 0 { + return nil, fmt.Errorf("vidio: no frames indexes specified") + } + for _, nValue := range n { if nValue >= video.frames { return nil, fmt.Errorf("vidio: provided frame index %d is not in frame count range", nValue) diff --git a/vidio_test.go b/vidio_test.go index 5dcfafb..f0cb0cf 100644 --- a/vidio_test.go +++ b/vidio_test.go @@ -341,6 +341,20 @@ func TestReadFrameShouldReturnCorrectFrame(t *testing.T) { } } +func TestReadFramesShouldReturnErrorOnNoFramesSpecified(t *testing.T) { + path := "test/koala.mp4" + + video, err := NewVideo(path) + if err != nil { + t.Errorf("Failed to create the video: %s", err) + } + + _, err = video.ReadFrames() + if err == nil { + t.Error("Error was expected to no be nil") + } +} + func TestReadFramesShouldReturnErrorOnOutOfRangeFrame(t *testing.T) { path := "test/koala.mp4"