aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/server/models/video.js b/server/models/video.js
index 564e362fd..0e84e8986 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -1,5 +1,6 @@
1'use strict' 1'use strict'
2 2
3const Buffer = require('safe-buffer').Buffer
3const createTorrent = require('create-torrent') 4const createTorrent = require('create-torrent')
4const ffmpeg = require('fluent-ffmpeg') 5const ffmpeg = require('fluent-ffmpeg')
5const fs = require('fs') 6const fs = require('fs')
@@ -106,7 +107,7 @@ module.exports = function (sequelize, DataTypes) {
106 classMethods: { 107 classMethods: {
107 associate, 108 associate,
108 109
109 generateThumbnailFromBase64, 110 generateThumbnailFromData,
110 getDurationFromFile, 111 getDurationFromFile,
111 list, 112 list,
112 listForApi, 113 listForApi,
@@ -336,7 +337,7 @@ function toFormatedJSON () {
336function toRemoteJSON (callback) { 337function toRemoteJSON (callback) {
337 const self = this 338 const self = this
338 339
339 // Convert thumbnail to base64 340 // Get thumbnail data to send to the other pod
340 const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) 341 const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
341 fs.readFile(thumbnailPath, function (err, thumbnailData) { 342 fs.readFile(thumbnailPath, function (err, thumbnailData) {
342 if (err) { 343 if (err) {
@@ -351,7 +352,7 @@ function toRemoteJSON (callback) {
351 remoteId: self.id, 352 remoteId: self.id,
352 author: self.Author.name, 353 author: self.Author.name,
353 duration: self.duration, 354 duration: self.duration,
354 thumbnailBase64: new Buffer(thumbnailData).toString('base64'), 355 thumbnailData: thumbnailData.toString('binary'),
355 tags: map(self.Tags, 'name'), 356 tags: map(self.Tags, 'name'),
356 createdAt: self.createdAt, 357 createdAt: self.createdAt,
357 extname: self.extname 358 extname: self.extname
@@ -363,12 +364,12 @@ function toRemoteJSON (callback) {
363 364
364// ------------------------------ STATICS ------------------------------ 365// ------------------------------ STATICS ------------------------------
365 366
366function generateThumbnailFromBase64 (video, thumbnailData, callback) { 367function generateThumbnailFromData (video, thumbnailData, callback) {
367 // Creating the thumbnail for a remote video 368 // Creating the thumbnail for a remote video
368 369
369 const thumbnailName = video.getThumbnailName() 370 const thumbnailName = video.getThumbnailName()
370 const thumbnailPath = constants.CONFIG.STORAGE.THUMBNAILS_DIR + thumbnailName 371 const thumbnailPath = constants.CONFIG.STORAGE.THUMBNAILS_DIR + thumbnailName
371 fs.writeFile(thumbnailPath, thumbnailData, { encoding: 'base64' }, function (err) { 372 fs.writeFile(thumbnailPath, Buffer.from(thumbnailData, 'binary'), function (err) {
372 if (err) return callback(err) 373 if (err) return callback(err)
373 374
374 return callback(null, thumbnailName) 375 return callback(null, thumbnailName)