diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-08 11:28:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-08 11:28:51 +0200 |
commit | 318b0bd0c2ff575f35d51d97327f77abfecd6b86 (patch) | |
tree | 095a464dc053c06bc7a9c1e6a50a18ac9a7e4dce /server/helpers/ffmpeg-utils.ts | |
parent | 5982ffc4b5c926ea51f5bb3ca48f0f2f8f5bd621 (diff) | |
download | PeerTube-318b0bd0c2ff575f35d51d97327f77abfecd6b86.tar.gz PeerTube-318b0bd0c2ff575f35d51d97327f77abfecd6b86.tar.zst PeerTube-318b0bd0c2ff575f35d51d97327f77abfecd6b86.zip |
Fix "height not divisible by 2" ffmpeg error
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 15 |
1 files changed, 10 insertions, 5 deletions
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' | |||
5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' | 5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' |
6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos' | 6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos' |
7 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
8 | import { execPromise, promisify0 } from './core-utils' | 8 | import { execPromise, isOdd, promisify0 } from './core-utils' |
9 | import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' | 9 | import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' |
10 | import { processImage } from './image-utils' | 10 | import { processImage } from './image-utils' |
11 | import { logger } from './logger' | 11 | import { logger } from './logger' |
12 | import { FilterSpecification } from 'fluent-ffmpeg' | 12 | import { FilterSpecification } from 'fluent-ffmpeg' |
13 | import { findCommentId } from '@shared/extra-utils' | ||
13 | 14 | ||
14 | /** | 15 | /** |
15 | * | 16 | * |
@@ -133,7 +134,7 @@ interface BaseTranscodeOptions { | |||
133 | availableEncoders: AvailableEncoders | 134 | availableEncoders: AvailableEncoders |
134 | profile: string | 135 | profile: string |
135 | 136 | ||
136 | resolution: VideoResolution | 137 | resolution: number |
137 | 138 | ||
138 | isPortraitMode?: boolean | 139 | isPortraitMode?: boolean |
139 | 140 | ||
@@ -407,8 +408,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran | |||
407 | async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { | 408 | async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { |
408 | command = command.loop(undefined) | 409 | command = command.loop(undefined) |
409 | 410 | ||
410 | // Avoid "height not divisible by 2" error | 411 | const scaleFilterValue = getScaleCleanerValue() |
411 | const scaleFilterValue = 'trunc(iw/2)*2:trunc(ih/2)*2' | ||
412 | command = await presetVideo({ command, input: options.audioPath, transcodeOptions: options, scaleFilterValue }) | 412 | command = await presetVideo({ command, input: options.audioPath, transcodeOptions: options, scaleFilterValue }) |
413 | 413 | ||
414 | command.outputOption('-preset:v veryfast') | 414 | command.outputOption('-preset:v veryfast') |
@@ -542,7 +542,7 @@ async function getEncoderBuilderResult (options: { | |||
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | const result = await builder({ input, resolution: resolution, fps, streamNum }) | 545 | const result = await builder({ input, resolution, fps, streamNum }) |
546 | 546 | ||
547 | return { | 547 | return { |
548 | result, | 548 | result, |
@@ -727,6 +727,11 @@ async function runCommand (options: { | |||
727 | }) | 727 | }) |
728 | } | 728 | } |
729 | 729 | ||
730 | // Avoid "height not divisible by 2" error | ||
731 | function getScaleCleanerValue () { | ||
732 | return 'trunc(iw/2)*2:trunc(ih/2)*2' | ||
733 | } | ||
734 | |||
730 | // --------------------------------------------------------------------------- | 735 | // --------------------------------------------------------------------------- |
731 | 736 | ||
732 | export { | 737 | export { |