diff options
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index e328c49ac..6f5a71b4a 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -3,13 +3,12 @@ import * as ffmpeg from 'fluent-ffmpeg' | |||
3 | import { readFile, remove, writeFile } from 'fs-extra' | 3 | import { readFile, remove, writeFile } from 'fs-extra' |
4 | import { dirname, join } from 'path' | 4 | 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, EncoderOptions, EncoderOptionsBuilder, 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, 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' | ||
13 | 12 | ||
14 | /** | 13 | /** |
15 | * | 14 | * |
@@ -133,7 +132,7 @@ interface BaseTranscodeOptions { | |||
133 | availableEncoders: AvailableEncoders | 132 | availableEncoders: AvailableEncoders |
134 | profile: string | 133 | profile: string |
135 | 134 | ||
136 | resolution: VideoResolution | 135 | resolution: number |
137 | 136 | ||
138 | isPortraitMode?: boolean | 137 | isPortraitMode?: boolean |
139 | 138 | ||
@@ -227,7 +226,7 @@ async function getLiveTranscodingCommand (options: { | |||
227 | 226 | ||
228 | const varStreamMap: string[] = [] | 227 | const varStreamMap: string[] = [] |
229 | 228 | ||
230 | const complexFilter: FilterSpecification[] = [ | 229 | const complexFilter: ffmpeg.FilterSpecification[] = [ |
231 | { | 230 | { |
232 | inputs: '[v:0]', | 231 | inputs: '[v:0]', |
233 | filter: 'split', | 232 | filter: 'split', |
@@ -407,8 +406,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran | |||
407 | async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { | 406 | async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { |
408 | command = command.loop(undefined) | 407 | command = command.loop(undefined) |
409 | 408 | ||
410 | // Avoid "height not divisible by 2" error | 409 | 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 }) | 410 | command = await presetVideo({ command, input: options.audioPath, transcodeOptions: options, scaleFilterValue }) |
413 | 411 | ||
414 | command.outputOption('-preset:v veryfast') | 412 | command.outputOption('-preset:v veryfast') |
@@ -542,7 +540,7 @@ async function getEncoderBuilderResult (options: { | |||
542 | } | 540 | } |
543 | } | 541 | } |
544 | 542 | ||
545 | const result = await builder({ input, resolution: resolution, fps, streamNum }) | 543 | const result = await builder({ input, resolution, fps, streamNum }) |
546 | 544 | ||
547 | return { | 545 | return { |
548 | result, | 546 | result, |
@@ -727,6 +725,11 @@ async function runCommand (options: { | |||
727 | }) | 725 | }) |
728 | } | 726 | } |
729 | 727 | ||
728 | // Avoid "height not divisible by 2" error | ||
729 | function getScaleCleanerValue () { | ||
730 | return 'trunc(iw/2)*2:trunc(ih/2)*2' | ||
731 | } | ||
732 | |||
730 | // --------------------------------------------------------------------------- | 733 | // --------------------------------------------------------------------------- |
731 | 734 | ||
732 | export { | 735 | export { |