1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Fix "height not divisible by 2" ffmpeg error

This commit is contained in:
Chocobozzz 2021-06-08 11:28:51 +02:00
parent 5982ffc4b5
commit 318b0bd0c2
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 31 additions and 8 deletions

View file

@ -5,11 +5,12 @@ import { dirname, join } from 'path'
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos'
import { CONFIG } from '../initializers/config'
import { execPromise, promisify0 } from './core-utils'
import { execPromise, isOdd, promisify0 } from './core-utils'
import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
import { processImage } from './image-utils'
import { logger } from './logger'
import { FilterSpecification } from 'fluent-ffmpeg'
import { findCommentId } from '@shared/extra-utils'
/**
*
@ -133,7 +134,7 @@ interface BaseTranscodeOptions {
availableEncoders: AvailableEncoders
profile: string
resolution: VideoResolution
resolution: number
isPortraitMode?: boolean
@ -407,8 +408,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran
async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) {
command = command.loop(undefined)
// Avoid "height not divisible by 2" error
const scaleFilterValue = 'trunc(iw/2)*2:trunc(ih/2)*2'
const scaleFilterValue = getScaleCleanerValue()
command = await presetVideo({ command, input: options.audioPath, transcodeOptions: options, scaleFilterValue })
command.outputOption('-preset:v veryfast')
@ -542,7 +542,7 @@ async function getEncoderBuilderResult (options: {
}
}
const result = await builder({ input, resolution: resolution, fps, streamNum })
const result = await builder({ input, resolution, fps, streamNum })
return {
result,
@ -727,6 +727,11 @@ async function runCommand (options: {
})
}
// Avoid "height not divisible by 2" error
function getScaleCleanerValue () {
return 'trunc(iw/2)*2:trunc(ih/2)*2'
}
// ---------------------------------------------------------------------------
export {