+async function buildTargetBitrate (options: {
+ input: string
+ resolution: VideoResolution
+ fps: number
+
+}) {
+ const { input, resolution, fps } = options
+ const probe = await ffprobePromise(input)
+
+ const videoStream = await getVideoStreamFromFile(input, probe)
+ if (!videoStream) return undefined
+
+ const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
+
+ // Don't transcode to an higher bitrate than the original file
+ const fileBitrate = await getVideoFileBitrate(input, probe)
+ return Math.min(targetBitrate, fileBitrate)
+}