1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Merge pull request #176 from axlbdev/respect-video-rotate

Fix dimesions of rotated videos in metadata
This commit is contained in:
Patrik J. Braun 2020-09-05 15:39:53 +02:00 committed by GitHub
commit 187e021463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 1 deletions

View File

@ -50,6 +50,12 @@ export class MetadataLoader {
metadata.size.width = data.streams[i].width; metadata.size.width = data.streams[i].width;
metadata.size.height = data.streams[i].height; metadata.size.height = data.streams[i].height;
if (Utils.isInt32(parseInt(data.streams[i].rotation, 10)) &&
(Math.abs(parseInt(data.streams[i].rotation, 10)) / 90) % 2 === 1) {
metadata.size.width = data.streams[i].height;
metadata.size.height = data.streams[i].width;
}
if (Utils.isInt32(Math.floor(parseFloat(data.streams[i].duration) * 1000))) { if (Utils.isInt32(Math.floor(parseFloat(data.streams[i].duration) * 1000))) {
metadata.duration = Math.floor(parseFloat(data.streams[i].duration) * 1000); metadata.duration = Math.floor(parseFloat(data.streams[i].duration) * 1000);
} }

View File

@ -0,0 +1,11 @@
{
"bitRate": 11464,
"creationDate": 1550265200000,
"duration": 13666,
"fileSize": 242601,
"fps": 15,
"size": {
"height": 80,
"width": 60
}
}

Binary file not shown.

View File

@ -11,7 +11,7 @@ describe('DiskMangerWorker', () => {
Config.Server.Media.folder = path.join(__dirname, '/../../../assets'); Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets'); ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
const dir = await DiskMangerWorker.scanDirectory('/'); const dir = await DiskMangerWorker.scanDirectory('/');
expect(dir.media.length).to.be.equals(5); expect(dir.media.length).to.be.equals(6);
const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json')); const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json'));
expect(Utils.clone(dir.media[2].name)).to.be.deep.equal('test image öüóőúéáű-.,.jpg'); expect(Utils.clone(dir.media[2].name)).to.be.deep.equal('test image öüóőúéáű-.,.jpg');
expect(Utils.clone(dir.media[2].metadata)).to.be.deep.equal(expected); expect(Utils.clone(dir.media[2].metadata)).to.be.deep.equal(expected);

View File

@ -44,5 +44,10 @@ describe('MetadataLoader', () => {
expect(Utils.clone(data)).to.be.deep.equal(expected); expect(Utils.clone(data)).to.be.deep.equal(expected);
}); });
it('should respect mp4 rotate transformation', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/video_rotate.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/video_rotate.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
}); });