diff options
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 9 | ||||
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 9 |
3 files changed, 15 insertions, 7 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 7fa84e195..f12fb09ae 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -19,6 +19,7 @@ import './videojs-components/settings-panel' | |||
19 | import './videojs-components/settings-panel-child' | 19 | import './videojs-components/settings-panel-child' |
20 | import './videojs-components/theater-button' | 20 | import './videojs-components/theater-button' |
21 | import videojs from 'video.js' | 21 | import videojs from 'video.js' |
22 | |||
22 | import { isDefaultLocale } from '../../../../shared/models/i18n/i18n' | 23 | import { isDefaultLocale } from '../../../../shared/models/i18n/i18n' |
23 | import { VideoFile } from '../../../../shared/models/videos' | 24 | import { VideoFile } from '../../../../shared/models/videos' |
24 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | 25 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' |
@@ -300,7 +301,13 @@ export class PeertubePlayerManager { | |||
300 | } | 301 | } |
301 | const hlsjs = { | 302 | const hlsjs = { |
302 | levelLabelHandler: (level: { height: number, width: number }) => { | 303 | levelLabelHandler: (level: { height: number, width: number }) => { |
303 | const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === level.height) | 304 | const resolution = Math.min(level.height || 0, level.width || 0) |
305 | |||
306 | const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === resolution) | ||
307 | if (!file) { | ||
308 | console.error('Cannot find video file for level %d.', level.height) | ||
309 | return level.height | ||
310 | } | ||
304 | 311 | ||
305 | let label = file.resolution.label | 312 | let label = file.resolution.label |
306 | if (file.fps >= 50) label += file.fps | 313 | if (file.fps >= 50) label += file.fps |
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 0cfc51775..7bfd5d44a 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -74,7 +74,7 @@ namespace audio { | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | function computeResolutionsToTranscode (videoFileHeight: number) { | 77 | function computeResolutionsToTranscode (videoFileResolution: number) { |
78 | const resolutionsEnabled: number[] = [] | 78 | const resolutionsEnabled: number[] = [] |
79 | const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS | 79 | const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS |
80 | 80 | ||
@@ -90,7 +90,7 @@ function computeResolutionsToTranscode (videoFileHeight: number) { | |||
90 | ] | 90 | ] |
91 | 91 | ||
92 | for (const resolution of resolutions) { | 92 | for (const resolution of resolutions) { |
93 | if (configResolutions[resolution + 'p'] === true && videoFileHeight > resolution) { | 93 | if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) { |
94 | resolutionsEnabled.push(resolution) | 94 | resolutionsEnabled.push(resolution) |
95 | } | 95 | } |
96 | } | 96 | } |
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index ce1c419e7..7ebef46b4 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -75,7 +75,7 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O | |||
75 | if (videoArg === undefined) return undefined | 75 | if (videoArg === undefined) return undefined |
76 | 76 | ||
77 | // Outside the transaction (IO on disk) | 77 | // Outside the transaction (IO on disk) |
78 | const { videoFileResolution } = await videoArg.getMaxQualityResolution() | 78 | const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution() |
79 | 79 | ||
80 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { | 80 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { |
81 | // Maybe the video changed in database, refresh it | 81 | // Maybe the video changed in database, refresh it |
@@ -86,7 +86,7 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O | |||
86 | // Create transcoding jobs if there are enabled resolutions | 86 | // Create transcoding jobs if there are enabled resolutions |
87 | const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution) | 87 | const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution) |
88 | logger.info( | 88 | logger.info( |
89 | 'Resolutions computed for video %s and origin file height of %d.', videoDatabase.uuid, videoFileResolution, | 89 | 'Resolutions computed for video %s and origin file resolution of %d.', videoDatabase.uuid, videoFileResolution, |
90 | { resolutions: resolutionsEnabled } | 90 | { resolutions: resolutionsEnabled } |
91 | ) | 91 | ) |
92 | 92 | ||
@@ -104,14 +104,15 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O | |||
104 | dataInput = { | 104 | dataInput = { |
105 | type: 'new-resolution' as 'new-resolution', | 105 | type: 'new-resolution' as 'new-resolution', |
106 | videoUUID: videoDatabase.uuid, | 106 | videoUUID: videoDatabase.uuid, |
107 | resolution | 107 | resolution, |
108 | isPortraitMode | ||
108 | } | 109 | } |
109 | } else if (CONFIG.TRANSCODING.HLS.ENABLED) { | 110 | } else if (CONFIG.TRANSCODING.HLS.ENABLED) { |
110 | dataInput = { | 111 | dataInput = { |
111 | type: 'hls', | 112 | type: 'hls', |
112 | videoUUID: videoDatabase.uuid, | 113 | videoUUID: videoDatabase.uuid, |
113 | resolution, | 114 | resolution, |
114 | isPortraitMode: false, | 115 | isPortraitMode, |
115 | copyCodecs: false | 116 | copyCodecs: false |
116 | } | 117 | } |
117 | } | 118 | } |