<commit_before>package lazyquicktime

import (
	"image"
	"testing"
	"net/url"
	"github.com/amarburg/go-lazyfs"
	"github.com/amarburg/go-lazyfs-testfiles"
	"github.com/amarburg/go-lazyfs-testfiles/http_server"
)

func doExtractFrame(t *testing.T, src lazyfs.FileSource) (image.Image, error) {
	mov, _ := LoadMovMetadata(src)

	if mov.NumFrames() != 31 {
		t.Errorf("Movie has incorrect number of frames (%d)", mov.NumFrames())
	}

	//fmt.Println("Movie has", mov.NumFrames(), "frames and is ", mov.Duration(), " seconds long")

	// Try extracting a frame
	frame := 2
	img, err := mov.ExtractFrame(frame)

	if err != nil {
		t.Errorf("Error decoding frame: %s", err.Error())
	}

	// Check the frame

	return img, err
}

// Test extracting a frame from a local file
//
func TestExtractFrameLocalFileSource(t *testing.T) {<commit_msg>Check image size in test.<commit_after>package lazyquicktime

import (
	"image"
	"testing"
	"net/url"
	"github.com/amarburg/go-lazyfs"
	"github.com/amarburg/go-lazyfs-testfiles"
	"github.com/amarburg/go-lazyfs-testfiles/http_server"
)

func doExtractFrame(t *testing.T, src lazyfs.FileSource) (image.Image, error) {
	mov, _ := LoadMovMetadata(src)

	if mov.NumFrames() != 31 {
		t.Errorf("Movie has incorrect number of frames (%d)", mov.NumFrames())
	}

	//fmt.Println("Movie has", mov.NumFrames(), "frames and is ", mov.Duration(), " seconds long")

	// Try extracting a frame
	frame := 2
	img, err := mov.ExtractFrame(frame)

	if err != nil {
		t.Errorf("Error decoding frame: %s", err.Error())
	}

	bounds := img.Bounds()
	width := bounds.Max.X - bounds.Min.X
	height := bounds.Max.Y - bounds.Min.Y

	// Check the frame
	if width != lazyfs_testfiles.TestMovieWidth {
			t.Errorf("Image is not expected width (%d != %d)", width, lazyfs_testfiles.TestMovieWidth)
	}

	if height != lazyfs_testfiles.TestMovieHeight {
			t.Errorf("Image is not expected height (%d != %d)", height, lazyfs_testfiles.TestMovieHeight)
	}

	return img, err
}

// Test extracting a frame from a local file
//
func TestExtractFrameLocalFileSource(t *testing.T) {
{'fraction_non_alphanumeric': 0.15087040618955513, 'fraction_numerical': 0.0029013539651837525, 'mean_word_length': 4.108641975308642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6236814', 'n_tokens_mistral': 769, 'n_tokens_neox': 724, 'n_words': 180}