Hey, how do i set the file width & height of a video file
if i console log video.width & element.width i get the results but when i return albums at the end, they are not set, i dont understand
can someone help me pls
"use strict";
const { sanitizeEntity } = require("strapi-utils");
const path = require("path");
const ffmpeg = require("fluent-ffmpeg");
module.exports = {
async find(ctx) {
let entities;
if (ctx.query._q) {
entities = await strapi.services.albums.search(ctx.query);
} else {
entities = await strapi.services.albums.find(ctx.query);
}
return entities.map((entity) => {
const albums = sanitizeEntity(entity, {
model: strapi.models.albums,
});
albums.media.forEach((video) => {
if (video.width === null || video.height === null) {
const videoFile = path.resolve(
__dirname,
"../../../public" + video.url
);
ffmpeg.ffprobe(videoFile, function (err, metadata) {
if (err) {
console.error(err);
} else {
metadata.streams.forEach((element) => {
video.width = element.width;
video.height = element.height;
});
}
});
}
});
return albums;
});
},
};