diff --git a/assets/examples/gopher-video.json b/assets/examples/gopher-video.json new file mode 100644 index 000000000..47d41a57f --- /dev/null +++ b/assets/examples/gopher-video.json @@ -0,0 +1,85 @@ +[{ + "SourceFile": "/Users/michael/Downloads/20200511-141648-Berlin-Germany-2020-3ku.mp4", + "ExifToolVersion": 11.85, + "FileName": "gopher-video.mp4", + "Directory": "/Users/michael/Downloads", + "FileSize": "4.4 MB", + "FileModifyDate": "2020:05:14 14:02:58+02:00", + "FileAccessDate": "2020:05:14 14:02:58+02:00", + "FileInodeChangeDate": "2020:05:14 14:02:58+02:00", + "FilePermissions": "rw-r--r--", + "FileType": "MP4", + "FileTypeExtension": "mp4", + "MIMEType": "video/mp4", + "MajorBrand": "MP4 v2 [ISO 14496-14]", + "MinorVersion": "0.0.0", + "CompatibleBrands": ["isom","mp42"], + "MovieHeaderVersion": 0, + "CreateDate": "2020:05:11 14:16:48", + "ModifyDate": "2020:05:11 14:16:48", + "TimeScale": 1000, + "Duration": "2.42 s", + "PreferredRate": 1, + "PreferredVolume": "100.00%", + "PreviewTime": "0 s", + "PreviewDuration": "0 s", + "PosterTime": "0 s", + "SelectionTime": "0 s", + "SelectionDuration": "0 s", + "CurrentTime": "0 s", + "NextTrackID": 3, + "GPSCoordinates": "52 deg 27' 34.56\" N, 13 deg 19' 18.48\" E", + "AndroidVersion": 10, + "TrackHeaderVersion": 0, + "TrackCreateDate": "2020:05:11 14:16:48", + "TrackModifyDate": "2020:05:11 14:16:48", + "TrackID": 1, + "TrackDuration": "2.42 s", + "TrackLayer": 0, + "TrackVolume": "0.00%", + "ImageWidth": 1920, + "ImageHeight": 1080, + "GraphicsMode": "srcCopy", + "OpColor": "0 0 0", + "CompressorID": "avc1", + "SourceImageWidth": 1920, + "SourceImageHeight": 1080, + "XResolution": 72, + "YResolution": 72, + "BitDepth": 24, + "PixelAspectRatio": "65536:65536", + "ColorRepresentation": "nclx 1 1 1", + "VideoFrameRate": 28.101, + "MatrixStructure": "1 0 0 0 1 0 0 0 1", + "MediaHeaderVersion": 0, + "MediaCreateDate": "2020:05:11 14:16:48", + "MediaModifyDate": "2020:05:11 14:16:48", + "MediaTimeScale": 48000, + "MediaDuration": "2.41 s", + "HandlerType": "Audio Track", + "HandlerDescription": "SoundHandle", + "Balance": 0, + "AudioFormat": "mp4a", + "AudioChannels": 2, + "AudioBitsPerSample": 16, + "AudioSampleRate": 48000, + "MediaDataSize": 3818513, + "MediaDataOffset": 810340, + "ImageSize": "1920x1080", + "Megapixels": 2.1, + "AvgBitrate": "12.6 Mbps", + "GPSLatitude": "52 deg 27' 34.56\" N", + "GPSLongitude": "13 deg 19' 18.48\" E", + "Rotation": 90, + "GPSPosition": "52 deg 27' 34.56\" N, 13 deg 19' 18.48\" E", + "Title": "Blue Gopher", + "Description": "Cute gopher", + "Comment": "We love go", + "Subject": "gopher", + "Keywords": "blue, desk", + "Artist": "Micha", + "CameraOwner": "Micha", + "CameraSerial": "123", + "DocumentID": "12398365", + "InstanceID": "9058055", +}] diff --git a/internal/photoprism/index_mediafile_test.go b/internal/photoprism/index_mediafile_test.go new file mode 100644 index 000000000..30eeca90a --- /dev/null +++ b/internal/photoprism/index_mediafile_test.go @@ -0,0 +1,53 @@ +package photoprism + +import ( + "github.com/photoprism/photoprism/internal/classify" + "github.com/photoprism/photoprism/internal/config" + "github.com/photoprism/photoprism/internal/nsfw" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestIndex_MediaFile(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + t.Run("/gopher-video.mp4", func(t *testing.T) { + conf := config.TestConfig() + + conf.InitializeTestData(t) + + tf := classify.New(conf.AssetsPath(), conf.TensorFlowOff()) + nd := nsfw.New(conf.NSFWModelPath()) + convert := NewConvert(conf) + + ind := NewIndex(conf, tf, nd, convert) + indexOpt := IndexOptionsAll() + mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/gopher-video.mp4") + if err != nil { + t.Fatal(err) + } + assert.Equal(t, "", mediaFile.metaData.Title) + + result := ind.MediaFile(mediaFile, indexOpt, "gopher-video.mp4") + assert.Equal(t, "Blue Gopher", mediaFile.metaData.Title) + assert.Equal(t, IndexStatus("added"), result.Status) + }) + t.Run("error", func(t *testing.T) { + conf := config.TestConfig() + + conf.InitializeTestData(t) + + tf := classify.New(conf.AssetsPath(), conf.TensorFlowOff()) + nd := nsfw.New(conf.NSFWModelPath()) + convert := NewConvert(conf) + + ind := NewIndex(conf, tf, nd, convert) + indexOpt := IndexOptionsAll() + + result := ind.MediaFile(nil, indexOpt, "gopher-video.mp4") + assert.Equal(t, IndexStatus("failed"), result.Status) + }) + +}