mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Support encoding profiles
This commit is contained in:
parent
9252a33d11
commit
5a547f69d5
9 changed files with 402 additions and 157 deletions
|
@ -198,9 +198,12 @@ function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod'
|
|||
async function canDoQuickTranscode (path: string): Promise<boolean> {
|
||||
const probe = await ffprobePromise(path)
|
||||
|
||||
// NOTE: This could be optimized by running ffprobe only once (but it runs fast anyway)
|
||||
return await canDoQuickVideoTranscode(path, probe) &&
|
||||
await canDoQuickAudioTranscode(path, probe)
|
||||
}
|
||||
|
||||
async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
|
||||
const videoStream = await getVideoStreamFromFile(path, probe)
|
||||
const parsedAudio = await getAudioStream(path, probe)
|
||||
const fps = await getVideoFileFPS(path, probe)
|
||||
const bitRate = await getVideoFileBitrate(path, probe)
|
||||
const resolution = await getVideoFileResolution(path, probe)
|
||||
|
@ -212,6 +215,12 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
|
|||
if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false
|
||||
if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
|
||||
const parsedAudio = await getAudioStream(path, probe)
|
||||
|
||||
// check audio params (if audio stream exists)
|
||||
if (parsedAudio.audioStream) {
|
||||
if (parsedAudio.audioStream['codec_name'] !== 'aac') return false
|
||||
|
@ -239,11 +248,15 @@ export {
|
|||
getVideoFileResolution,
|
||||
getMetadataFromFile,
|
||||
getMaxAudioBitrate,
|
||||
getVideoStreamFromFile,
|
||||
getDurationFromVideoFile,
|
||||
getAudioStream,
|
||||
getVideoFileFPS,
|
||||
ffprobePromise,
|
||||
getClosestFramerateStandard,
|
||||
computeResolutionsToTranscode,
|
||||
getVideoFileBitrate,
|
||||
canDoQuickTranscode
|
||||
canDoQuickTranscode,
|
||||
canDoQuickVideoTranscode,
|
||||
canDoQuickAudioTranscode
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue