diff --git a/backend/model/threading/MetadataLoader.ts b/backend/model/threading/MetadataLoader.ts index d8885783..b8decde0 100644 --- a/backend/model/threading/MetadataLoader.ts +++ b/backend/model/threading/MetadataLoader.ts @@ -53,7 +53,7 @@ export class MetadataLoader { } if (Utils.isInt32(parseInt(data.streams[i].bit_rate, 10))) { - metadata.duration = parseInt(data.streams[i].bit_rate, 10) || null; + metadata.bitRate = parseInt(data.streams[i].bit_rate, 10) || null; } metadata.creationDate = Date.parse(data.streams[i].tags.creation_time); break; diff --git a/test/backend/unit/assets/video.json b/test/backend/unit/assets/video.json new file mode 100644 index 00000000..2a5afc94 --- /dev/null +++ b/test/backend/unit/assets/video.json @@ -0,0 +1,10 @@ +{ + "bitRate": 11464, + "creationDate": 1550265200000, + "duration": 13666, + "fileSize": 251571, + "size": { + "height": 60, + "width": 80 + } +} diff --git a/test/backend/unit/assets/video.mp4 b/test/backend/unit/assets/video.mp4 new file mode 100644 index 00000000..a4f6ee5d Binary files /dev/null and b/test/backend/unit/assets/video.mp4 differ diff --git a/test/backend/unit/model/threading/DiskMangerWorker.spec.ts b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts index b045bb95..6ca7997e 100644 --- a/test/backend/unit/model/threading/DiskMangerWorker.spec.ts +++ b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts @@ -11,7 +11,7 @@ describe('DiskMangerWorker', () => { Config.Server.imagesFolder = path.join(__dirname, '/../../assets'); ProjectPath.ImageFolder = path.join(__dirname, '/../../assets'); const dir = await DiskMangerWorker.scanDirectory('/'); - expect(dir.media.length).to.be.equals(3); + expect(dir.media.length).to.be.equals(4); const expected = require(path.join(__dirname, '/../../assets/test image öüóőúéáű-.,.json')); expect(Utils.clone(dir.media[1].name)).to.be.deep.equal('test image öüóőúéáű-.,.jpg'); expect(Utils.clone(dir.media[1].metadata)).to.be.deep.equal(expected); diff --git a/test/backend/unit/model/threading/MetaDataLoader.spec.ts b/test/backend/unit/model/threading/MetaDataLoader.spec.ts index 468fa9ff..e271bec4 100644 --- a/test/backend/unit/model/threading/MetaDataLoader.spec.ts +++ b/test/backend/unit/model/threading/MetaDataLoader.spec.ts @@ -31,4 +31,12 @@ describe('MetadataLoader', () => { expect(Utils.clone(data)).to.be.deep.equal(expected); }); + + it('should load mp4', async () => { + const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../assets/video.mp4')); + const expected = require(path.join(__dirname, '/../../assets/video.json')); + expect(Utils.clone(data)).to.be.deep.equal(expected); + }); + + });