aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffprobe-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 10:39:40 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 10:39:40 +0200
commitc826f34a45757b324a20f71665b44ed10e6953b5 (patch)
treeff29bdff8b4519bbdbbcd3aa0d68521ce2b06ff5 /server/helpers/ffprobe-utils.ts
parent421ff4618da64f0849353383f690a014024c40da (diff)
downloadPeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.gz
PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.zst
PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.zip
Limit live bitrate
Diffstat (limited to 'server/helpers/ffprobe-utils.ts')
-rw-r--r--server/helpers/ffprobe-utils.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index ef2aa3f89..bc87e49b1 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -175,10 +175,19 @@ async function getMetadataFromFile (path: string, existingProbe?: ffmpeg.Ffprobe
175 return new VideoFileMetadata(metadata) 175 return new VideoFileMetadata(metadata)
176} 176}
177 177
178async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData) { 178async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<number> {
179 const metadata = await getMetadataFromFile(path, existingProbe) 179 const metadata = await getMetadataFromFile(path, existingProbe)
180 180
181 return metadata.format.bit_rate as number 181 let bitrate = metadata.format.bit_rate as number
182 if (bitrate && !isNaN(bitrate)) return bitrate
183
184 const videoStream = await getVideoStreamFromFile(path, existingProbe)
185 if (!videoStream) return undefined
186
187 bitrate = videoStream?.bit_rate
188 if (bitrate && !isNaN(bitrate)) return bitrate
189
190 return undefined
182} 191}
183 192
184async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) { 193async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {