aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/helpers/ffprobe-utils.ts56
-rw-r--r--server/lib/live-manager.ts3
-rw-r--r--server/tests/api/videos/multiple-servers.ts8
-rw-r--r--server/tests/api/videos/single-server.ts2
4 files changed, 36 insertions, 33 deletions
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index 5545ddbbf..d03ab91ac 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -37,38 +37,37 @@ async function getAudioStream (videoPath: string, existingProbe?: ffmpeg.Ffprobe
37} 37}
38 38
39function getMaxAudioBitrate (type: 'aac' | 'mp3' | string, bitrate: number) { 39function getMaxAudioBitrate (type: 'aac' | 'mp3' | string, bitrate: number) {
40 const baseKbitrate = 384 40 const maxKBitrate = 384
41 const toBits = (kbits: number) => kbits * 8000 41 const kToBits = (kbits: number) => kbits * 1000
42
43 // If we did not manage to get the bitrate, use an average value
44 if (!bitrate) return 256
42 45
43 if (type === 'aac') { 46 if (type === 'aac') {
44 switch (true) { 47 switch (true) {
45 case bitrate > toBits(baseKbitrate): 48 case bitrate > kToBits(maxKBitrate):
46 return baseKbitrate 49 return maxKBitrate
47 50
48 default: 51 default:
49 return -1 // we interpret it as a signal to copy the audio stream as is 52 return -1 // we interpret it as a signal to copy the audio stream as is
50 } 53 }
51 } 54 }
52 55
53 if (type === 'mp3') { 56 /*
54 /* 57 a 192kbit/sec mp3 doesn't hold as much information as a 192kbit/sec aac.
55 a 192kbit/sec mp3 doesn't hold as much information as a 192kbit/sec aac. 58 That's why, when using aac, we can go to lower kbit/sec. The equivalences
56 That's why, when using aac, we can go to lower kbit/sec. The equivalences 59 made here are not made to be accurate, especially with good mp3 encoders.
57 made here are not made to be accurate, especially with good mp3 encoders. 60 */
58 */ 61 switch (true) {
59 switch (true) { 62 case bitrate <= kToBits(192):
60 case bitrate <= toBits(192): 63 return 128
61 return 128
62 64
63 case bitrate <= toBits(384): 65 case bitrate <= kToBits(384):
64 return 256 66 return 256
65 67
66 default: 68 default:
67 return baseKbitrate 69 return maxKBitrate
68 }
69 } 70 }
70
71 return undefined
72} 71}
73 72
74async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData) { 73async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData) {
@@ -208,6 +207,9 @@ async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeDat
208 const bitRate = await getVideoFileBitrate(path, probe) 207 const bitRate = await getVideoFileBitrate(path, probe)
209 const resolution = await getVideoFileResolution(path, probe) 208 const resolution = await getVideoFileResolution(path, probe)
210 209
210 // If ffprobe did not manage to guess the bitrate
211 if (!bitRate) return false
212
211 // check video params 213 // check video params
212 if (videoStream == null) return false 214 if (videoStream == null) return false
213 if (videoStream['codec_name'] !== 'h264') return false 215 if (videoStream['codec_name'] !== 'h264') return false
@@ -221,15 +223,15 @@ async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeDat
221async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { 223async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
222 const parsedAudio = await getAudioStream(path, probe) 224 const parsedAudio = await getAudioStream(path, probe)
223 225
224 // check audio params (if audio stream exists) 226 if (!parsedAudio.audioStream) return true
225 if (parsedAudio.audioStream) {
226 if (parsedAudio.audioStream['codec_name'] !== 'aac') return false
227 227
228 const audioBitrate = parsedAudio.bitrate 228 if (parsedAudio.audioStream['codec_name'] !== 'aac') return false
229 229
230 const maxAudioBitrate = getMaxAudioBitrate('aac', audioBitrate) 230 const audioBitrate = parsedAudio.bitrate
231 if (maxAudioBitrate !== -1 && audioBitrate > maxAudioBitrate) return false 231 if (!audioBitrate) return false
232 } 232
233 const maxAudioBitrate = getMaxAudioBitrate('aac', audioBitrate)
234 if (maxAudioBitrate !== -1 && audioBitrate > maxAudioBitrate) return false
233 235
234 return true 236 return true
235} 237}
diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts
index ee0e4de37..d63e79dfc 100644
--- a/server/lib/live-manager.ts
+++ b/server/lib/live-manager.ts
@@ -268,8 +268,7 @@ class LiveManager {
268 ? await getLiveTranscodingCommand({ 268 ? await getLiveTranscodingCommand({
269 rtmpUrl, 269 rtmpUrl,
270 outPath, 270 outPath,
271 resolutions: 271 resolutions: allResolutions,
272 allResolutions,
273 fps, 272 fps,
274 deleteSegments, 273 deleteSegments,
275 availableEncoders, 274 availableEncoders,
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index a62783639..fdd5e33f3 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -216,19 +216,19 @@ describe('Test multiple servers', function () {
216 files: [ 216 files: [
217 { 217 {
218 resolution: 240, 218 resolution: 240,
219 size: 189000 219 size: 270000
220 }, 220 },
221 { 221 {
222 resolution: 360, 222 resolution: 360,
223 size: 278000 223 size: 359000
224 }, 224 },
225 { 225 {
226 resolution: 480, 226 resolution: 480,
227 size: 384000 227 size: 465000
228 }, 228 },
229 { 229 {
230 resolution: 720, 230 resolution: 720,
231 size: 706000 231 size: 788000
232 } 232 }
233 ], 233 ],
234 thumbnailfile: 'thumbnail', 234 thumbnailfile: 'thumbnail',
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 0ae405950..b74bc3e80 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -157,6 +157,8 @@ describe('Test a single server', function () {
157 }) 157 })
158 158
159 it('Should upload the video', async function () { 159 it('Should upload the video', async function () {
160 this.timeout(10000)
161
160 const videoAttributes = { 162 const videoAttributes = {
161 name: 'my super name', 163 name: 'my super name',
162 category: 2, 164 category: 2,