aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts26
1 files changed, 19 insertions, 7 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 5d8089328..ab33b7c99 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -52,7 +52,7 @@ import {
52 isVideoStateValid, 52 isVideoStateValid,
53 isVideoSupportValid 53 isVideoSupportValid
54} from '../../helpers/custom-validators/videos' 54} from '../../helpers/custom-validators/videos'
55import { generateImageFromVideoFile, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils' 55import { generateImageFromVideoFile, getVideoFileFPS, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils'
56import { logger } from '../../helpers/logger' 56import { logger } from '../../helpers/logger'
57import { getServerActor } from '../../helpers/utils' 57import { getServerActor } from '../../helpers/utils'
58import { 58import {
@@ -1168,6 +1168,7 @@ export class VideoModel extends Model<VideoModel> {
1168 }, 1168 },
1169 magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs), 1169 magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs),
1170 size: videoFile.size, 1170 size: videoFile.size,
1171 fps: videoFile.fps,
1171 torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp), 1172 torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp),
1172 torrentDownloadUrl: this.getTorrentDownloadUrl(videoFile, baseUrlHttp), 1173 torrentDownloadUrl: this.getTorrentDownloadUrl(videoFile, baseUrlHttp),
1173 fileUrl: this.getVideoFileUrl(videoFile, baseUrlHttp), 1174 fileUrl: this.getVideoFileUrl(videoFile, baseUrlHttp),
@@ -1303,11 +1304,11 @@ export class VideoModel extends Model<VideoModel> {
1303 const newExtname = '.mp4' 1304 const newExtname = '.mp4'
1304 const inputVideoFile = this.getOriginalFile() 1305 const inputVideoFile = this.getOriginalFile()
1305 const videoInputPath = join(videosDirectory, this.getVideoFilename(inputVideoFile)) 1306 const videoInputPath = join(videosDirectory, this.getVideoFilename(inputVideoFile))
1306 const videoOutputPath = join(videosDirectory, this.id + '-transcoded' + newExtname) 1307 const videoTranscodedPath = join(videosDirectory, this.id + '-transcoded' + newExtname)
1307 1308
1308 const transcodeOptions = { 1309 const transcodeOptions = {
1309 inputPath: videoInputPath, 1310 inputPath: videoInputPath,
1310 outputPath: videoOutputPath 1311 outputPath: videoTranscodedPath
1311 } 1312 }
1312 1313
1313 // Could be very long! 1314 // Could be very long!
@@ -1319,10 +1320,13 @@ export class VideoModel extends Model<VideoModel> {
1319 // Important to do this before getVideoFilename() to take in account the new file extension 1320 // Important to do this before getVideoFilename() to take in account the new file extension
1320 inputVideoFile.set('extname', newExtname) 1321 inputVideoFile.set('extname', newExtname)
1321 1322
1322 await renamePromise(videoOutputPath, this.getVideoFilePath(inputVideoFile)) 1323 const videoOutputPath = this.getVideoFilePath(inputVideoFile)
1323 const stats = await statPromise(this.getVideoFilePath(inputVideoFile)) 1324 await renamePromise(videoTranscodedPath, videoOutputPath)
1325 const stats = await statPromise(videoOutputPath)
1326 const fps = await getVideoFileFPS(videoOutputPath)
1324 1327
1325 inputVideoFile.set('size', stats.size) 1328 inputVideoFile.set('size', stats.size)
1329 inputVideoFile.set('fps', fps)
1326 1330
1327 await this.createTorrentAndSetInfoHash(inputVideoFile) 1331 await this.createTorrentAndSetInfoHash(inputVideoFile)
1328 await inputVideoFile.save() 1332 await inputVideoFile.save()
@@ -1360,8 +1364,10 @@ export class VideoModel extends Model<VideoModel> {
1360 await transcode(transcodeOptions) 1364 await transcode(transcodeOptions)
1361 1365
1362 const stats = await statPromise(videoOutputPath) 1366 const stats = await statPromise(videoOutputPath)
1367 const fps = await getVideoFileFPS(videoOutputPath)
1363 1368
1364 newVideoFile.set('size', stats.size) 1369 newVideoFile.set('size', stats.size)
1370 newVideoFile.set('fps', fps)
1365 1371
1366 await this.createTorrentAndSetInfoHash(newVideoFile) 1372 await this.createTorrentAndSetInfoHash(newVideoFile)
1367 1373
@@ -1371,10 +1377,15 @@ export class VideoModel extends Model<VideoModel> {
1371 } 1377 }
1372 1378
1373 async importVideoFile (inputFilePath: string) { 1379 async importVideoFile (inputFilePath: string) {
1380 const { videoFileResolution } = await getVideoFileResolution(inputFilePath)
1381 const { size } = await statPromise(inputFilePath)
1382 const fps = await getVideoFileFPS(inputFilePath)
1383
1374 let updatedVideoFile = new VideoFileModel({ 1384 let updatedVideoFile = new VideoFileModel({
1375 resolution: (await getVideoFileResolution(inputFilePath)).videoFileResolution, 1385 resolution: videoFileResolution,
1376 extname: extname(inputFilePath), 1386 extname: extname(inputFilePath),
1377 size: (await statPromise(inputFilePath)).size, 1387 size,
1388 fps,
1378 videoId: this.id 1389 videoId: this.id
1379 }) 1390 })
1380 1391
@@ -1390,6 +1401,7 @@ export class VideoModel extends Model<VideoModel> {
1390 // Update the database 1401 // Update the database
1391 currentVideoFile.set('extname', updatedVideoFile.extname) 1402 currentVideoFile.set('extname', updatedVideoFile.extname)
1392 currentVideoFile.set('size', updatedVideoFile.size) 1403 currentVideoFile.set('size', updatedVideoFile.size)
1404 currentVideoFile.set('fps', updatedVideoFile.fps)
1393 1405
1394 updatedVideoFile = currentVideoFile 1406 updatedVideoFile = currentVideoFile
1395 } 1407 }