Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Reencode the video on cut

Chocobozzz20321f2049f4
diff --git a/server/helpers/ffmpeg/ffmpeg-edition.ts b/server/helpers/ffmpeg/ffmpeg-edition.ts
index 78de8f3b35..02c5ea8de9 100644
--- a/server/helpers/ffmpeg/ffmpeg-edition.ts
+++ b/server/helpers/ffmpeg/ffmpeg-edition.ts
@@ -3,7 +3,7 @@ import { VIDEO_FILTERS } from '@server/initializers/constants'
import { AvailableEncoders } from '@shared/models'
import { logger, loggerTagsFactory } from '../logger'
import { getFFmpeg, runCommand } from './ffmpeg-commons'
-import { presetCopy, presetVOD } from './ffmpeg-presets'
+import { presetVOD } from './ffmpeg-presets'
import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS, hasAudioStream } from './ffprobe-utils'
const lTags = loggerTagsFactory('ffmpeg')
@@ -13,25 +13,38 @@ async function cutVideo (options: {
outputPath: string
start?: number
end?: number
+
+ availableEncoders: AvailableEncoders
+ profile: string
}) {
- const { inputPath, outputPath } = options
+ const { inputPath, outputPath, availableEncoders, profile } = options
logger.debug('Will cut the video.', { options, ...lTags() })
+ const mainProbe = await ffprobePromise(inputPath)
+ const fps = await getVideoStreamFPS(inputPath, mainProbe)
+ const { resolution } = await getVideoStreamDimensionsInfo(inputPath, mainProbe)
+
let command = getFFmpeg(inputPath, 'vod')
.output(outputPath)
- command = presetCopy(command)
+ command = await presetVOD({
+ command,
+ input: inputPath,
+ availableEncoders,
+ profile,
+ resolution,
+ fps,
+ canCopyAudio: false,
+ canCopyVideo: false
+ })
if (options.start) {
- // Using -ss as output option is more precise than using it as input option
command.outputOption('-ss ' + options.start)
}
if (options.end) {
- const endSeeking = options.end - (options.start || 0)
-
- command.outputOption('-to ' + endSeeking)
+ command.outputOption('-to ' + options.end)
}
await runCommand({ command })
diff --git a/server/lib/job-queue/handlers/video-studio-edition.ts b/server/lib/job-queue/handlers/video-studio-edition.ts
index 23f9a34ccd..3e208d83df 100644
--- a/server/lib/job-queue/handlers/video-studio-edition.ts
+++ b/server/lib/job-queue/handlers/video-studio-edition.ts
@@ -164,7 +164,10 @@ function processCut (options: TaskProcessorOptions<VideoStudioTaskCutPayload>) {
...pick(options, [ 'inputPath', 'outputPath' ]),
start: task.options.start,
- end: task.options.end
+ end: task.options.end,
+
+ availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
+ profile: CONFIG.TRANSCODING.PROFILE
})
}