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

Apply rotation transformation from ffprobe to metadata's size

This commit is contained in:
Aleksey Khlebnikov 2020-09-02 14:23:30 +03:00
parent 3deb8e26f5
commit d33e674614
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.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);
}

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');
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);

View File

@ -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);
});
});