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:
commit
187e021463
@ -50,6 +50,12 @@ export class MetadataLoader {
|
||||
metadata.size.width = data.streams[i].width;
|
||||
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))) {
|
||||
metadata.duration = Math.floor(parseFloat(data.streams[i].duration) * 1000);
|
||||
}
|
||||
|
11
test/backend/assets/video_rotate.json
Normal file
11
test/backend/assets/video_rotate.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"bitRate": 11464,
|
||||
"creationDate": 1550265200000,
|
||||
"duration": 13666,
|
||||
"fileSize": 242601,
|
||||
"fps": 15,
|
||||
"size": {
|
||||
"height": 80,
|
||||
"width": 60
|
||||
}
|
||||
}
|
BIN
test/backend/assets/video_rotate.mp4
Normal file
BIN
test/backend/assets/video_rotate.mp4
Normal file
Binary file not shown.
@ -11,7 +11,7 @@ describe('DiskMangerWorker', () => {
|
||||
Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
|
||||
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
||||
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'));
|
||||
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);
|
||||
|
@ -44,5 +44,10 @@ describe('MetadataLoader', () => {
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user