529103462c
Related Issues: - Samsung: Initial support for Motion Photos (#439) - Google: Initial support for Motion Photos (#1739) - Metadata: Flag Samsung/Google Motion Photos as Live Photos (#2788) Related Pull Requests: - Live Photos: Add Support for Samsung Motion Photos (#3588) - Samsung: Improved support for Motion Photos (#3660) - Google: Initial support for Motion Photos (#3709) - Google: Add support for Motion Photos (#3722) Signed-off-by: Michael Mayer <michael@photoprism.app>
50 lines
925 B
Go
50 lines
925 B
Go
package video
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/gabriel-vasile/mimetype"
|
|
)
|
|
|
|
func TestReader(t *testing.T) {
|
|
t.Run("Read", func(t *testing.T) {
|
|
info, probeErr := ProbeFile("testdata/image-isom-avc1.jpg")
|
|
|
|
if probeErr != nil {
|
|
t.Fatal(probeErr)
|
|
}
|
|
|
|
require.NotNil(t, info)
|
|
|
|
reader, readerErr := NewReader(info.FileName, info.VideoOffset)
|
|
|
|
if readerErr != nil {
|
|
t.Fatal(probeErr)
|
|
}
|
|
|
|
defer reader.Close()
|
|
|
|
require.NotNil(t, reader)
|
|
|
|
videoData, ioErr := io.ReadAll(reader)
|
|
|
|
if ioErr != nil {
|
|
t.Fatal(probeErr)
|
|
}
|
|
|
|
stat, statErr := os.Stat(info.FileName)
|
|
|
|
if statErr != nil {
|
|
t.Fatal(probeErr)
|
|
}
|
|
|
|
assert.True(t, int(stat.Size()) > len(videoData))
|
|
assert.Equal(t, int(stat.Size()-info.VideoOffset), len(videoData))
|
|
assert.Equal(t, info.VideoMimeType, mimetype.Detect(videoData).String())
|
|
})
|
|
}
|