Fix resolution for portrait videos
This commit is contained in:
parent
2045b57223
commit
dca0fe12ec
|
@ -19,6 +19,7 @@ import './videojs-components/settings-panel'
|
||||||
import './videojs-components/settings-panel-child'
|
import './videojs-components/settings-panel-child'
|
||||||
import './videojs-components/theater-button'
|
import './videojs-components/theater-button'
|
||||||
import videojs from 'video.js'
|
import videojs from 'video.js'
|
||||||
|
|
||||||
import { isDefaultLocale } from '../../../../shared/models/i18n/i18n'
|
import { isDefaultLocale } from '../../../../shared/models/i18n/i18n'
|
||||||
import { VideoFile } from '../../../../shared/models/videos'
|
import { VideoFile } from '../../../../shared/models/videos'
|
||||||
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
|
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
|
||||||
|
@ -300,7 +301,13 @@ export class PeertubePlayerManager {
|
||||||
}
|
}
|
||||||
const hlsjs = {
|
const hlsjs = {
|
||||||
levelLabelHandler: (level: { height: number, width: number }) => {
|
levelLabelHandler: (level: { height: number, width: number }) => {
|
||||||
const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === level.height)
|
const resolution = Math.min(level.height || 0, level.width || 0)
|
||||||
|
|
||||||
|
const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === resolution)
|
||||||
|
if (!file) {
|
||||||
|
console.error('Cannot find video file for level %d.', level.height)
|
||||||
|
return level.height
|
||||||
|
}
|
||||||
|
|
||||||
let label = file.resolution.label
|
let label = file.resolution.label
|
||||||
if (file.fps >= 50) label += file.fps
|
if (file.fps >= 50) label += file.fps
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace audio {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeResolutionsToTranscode (videoFileHeight: number) {
|
function computeResolutionsToTranscode (videoFileResolution: number) {
|
||||||
const resolutionsEnabled: number[] = []
|
const resolutionsEnabled: number[] = []
|
||||||
const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS
|
const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ function computeResolutionsToTranscode (videoFileHeight: number) {
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const resolution of resolutions) {
|
for (const resolution of resolutions) {
|
||||||
if (configResolutions[resolution + 'p'] === true && videoFileHeight > resolution) {
|
if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) {
|
||||||
resolutionsEnabled.push(resolution)
|
resolutionsEnabled.push(resolution)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O
|
||||||
if (videoArg === undefined) return undefined
|
if (videoArg === undefined) return undefined
|
||||||
|
|
||||||
// Outside the transaction (IO on disk)
|
// Outside the transaction (IO on disk)
|
||||||
const { videoFileResolution } = await videoArg.getMaxQualityResolution()
|
const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution()
|
||||||
|
|
||||||
const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
|
const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
|
||||||
// Maybe the video changed in database, refresh it
|
// Maybe the video changed in database, refresh it
|
||||||
|
@ -86,7 +86,7 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O
|
||||||
// Create transcoding jobs if there are enabled resolutions
|
// Create transcoding jobs if there are enabled resolutions
|
||||||
const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution)
|
const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution)
|
||||||
logger.info(
|
logger.info(
|
||||||
'Resolutions computed for video %s and origin file height of %d.', videoDatabase.uuid, videoFileResolution,
|
'Resolutions computed for video %s and origin file resolution of %d.', videoDatabase.uuid, videoFileResolution,
|
||||||
{ resolutions: resolutionsEnabled }
|
{ resolutions: resolutionsEnabled }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -104,14 +104,15 @@ async function onVideoFileOptimizerSuccess (videoArg: MVideoWithFile, payload: O
|
||||||
dataInput = {
|
dataInput = {
|
||||||
type: 'new-resolution' as 'new-resolution',
|
type: 'new-resolution' as 'new-resolution',
|
||||||
videoUUID: videoDatabase.uuid,
|
videoUUID: videoDatabase.uuid,
|
||||||
resolution
|
resolution,
|
||||||
|
isPortraitMode
|
||||||
}
|
}
|
||||||
} else if (CONFIG.TRANSCODING.HLS.ENABLED) {
|
} else if (CONFIG.TRANSCODING.HLS.ENABLED) {
|
||||||
dataInput = {
|
dataInput = {
|
||||||
type: 'hls',
|
type: 'hls',
|
||||||
videoUUID: videoDatabase.uuid,
|
videoUUID: videoDatabase.uuid,
|
||||||
resolution,
|
resolution,
|
||||||
isPortraitMode: false,
|
isPortraitMode,
|
||||||
copyCodecs: false
|
copyCodecs: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue