diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/video-transcoding.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 03bc21559..4fd1d62a9 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -105,7 +105,7 @@ async function mergeAudioVideofile (video: MVideoWithAllFiles, resolution: Video | |||
105 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR | 105 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR |
106 | const newExtname = '.mp4' | 106 | const newExtname = '.mp4' |
107 | 107 | ||
108 | const inputVideoFile = video.getMaxQualityFile() | 108 | const inputVideoFile = video.getMinQualityFile() |
109 | 109 | ||
110 | const audioInputPath = getVideoFilePath(video, inputVideoFile) | 110 | const audioInputPath = getVideoFilePath(video, inputVideoFile) |
111 | const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname) | 111 | const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname) |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 73e0d2345..af6fae0b6 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { maxBy } from 'lodash' | 2 | import { maxBy, minBy } from 'lodash' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { | 4 | import { |
5 | CountOptions, | 5 | CountOptions, |
@@ -1802,9 +1802,9 @@ export class VideoModel extends Model<VideoModel> { | |||
1802 | this.VideoChannel.Account.isBlocked() | 1802 | this.VideoChannel.Account.isBlocked() |
1803 | } | 1803 | } |
1804 | 1804 | ||
1805 | getMaxQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo { | 1805 | getQualityFileBy <T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) { |
1806 | if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) { | 1806 | if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) { |
1807 | const file = maxBy(this.VideoFiles, file => file.resolution) | 1807 | const file = fun(this.VideoFiles, file => file.resolution) |
1808 | 1808 | ||
1809 | return Object.assign(file, { Video: this }) | 1809 | return Object.assign(file, { Video: this }) |
1810 | } | 1810 | } |
@@ -1813,13 +1813,21 @@ export class VideoModel extends Model<VideoModel> { | |||
1813 | if (Array.isArray(this.VideoStreamingPlaylists) && this.VideoStreamingPlaylists.length !== 0) { | 1813 | if (Array.isArray(this.VideoStreamingPlaylists) && this.VideoStreamingPlaylists.length !== 0) { |
1814 | const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this }) | 1814 | const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this }) |
1815 | 1815 | ||
1816 | const file = maxBy(streamingPlaylistWithVideo.VideoFiles, file => file.resolution) | 1816 | const file = fun(streamingPlaylistWithVideo.VideoFiles, file => file.resolution) |
1817 | return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo }) | 1817 | return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo }) |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | return undefined | 1820 | return undefined |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | getMaxQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo { | ||
1824 | return this.getQualityFileBy(maxBy) | ||
1825 | } | ||
1826 | |||
1827 | getMinQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo { | ||
1828 | return this.getQualityFileBy(minBy) | ||
1829 | } | ||
1830 | |||
1823 | getWebTorrentFile <T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo { | 1831 | getWebTorrentFile <T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo { |
1824 | if (Array.isArray(this.VideoFiles) === false) return undefined | 1832 | if (Array.isArray(this.VideoFiles) === false) return undefined |
1825 | 1833 | ||