From 318b0bd0c2ff575f35d51d97327f77abfecd6b86 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Jun 2021 11:28:51 +0200 Subject: Fix "height not divisible by 2" ffmpeg error --- server/helpers/ffmpeg-utils.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'server/helpers/ffmpeg-utils.ts') diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index e328c49ac..d20ca5d56 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -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 { -- cgit v1.2.3