diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-17 13:10:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-17 13:10:58 +0200 |
commit | 0229b014e0101844df028342b8d4dd9ae4e887a4 (patch) | |
tree | 5c42c40499e4298ee241203c8e055dbbd9438739 | |
parent | f365e978ed08e8fc7adf0607271c4071915629ee (diff) | |
download | PeerTube-0229b014e0101844df028342b8d4dd9ae4e887a4.tar.gz PeerTube-0229b014e0101844df028342b8d4dd9ae4e887a4.tar.zst PeerTube-0229b014e0101844df028342b8d4dd9ae4e887a4.zip |
Fix tests
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 16 | ||||
-rw-r--r-- | server/models/account/user.ts | 1 | ||||
-rw-r--r-- | shared/models/videos/video-resolution.enum.ts | 6 |
3 files changed, 12 insertions, 11 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 17f35fe8d..a53a7bae4 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -118,11 +118,13 @@ function transcode (options: TranscodeOptions) { | |||
118 | return new Promise<void>(async (res, rej) => { | 118 | return new Promise<void>(async (res, rej) => { |
119 | let fps = await getVideoFileFPS(options.inputPath) | 119 | let fps = await getVideoFileFPS(options.inputPath) |
120 | // On small/medium resolutions, limit FPS | 120 | // On small/medium resolutions, limit FPS |
121 | if (options.resolution !== undefined && | 121 | // if ( |
122 | options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && | 122 | // options.resolution !== undefined && |
123 | fps > VIDEO_TRANSCODING_FPS.AVERAGE) { | 123 | // options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && |
124 | fps = VIDEO_TRANSCODING_FPS.AVERAGE | 124 | // fps > VIDEO_TRANSCODING_FPS.AVERAGE |
125 | } | 125 | // ) { |
126 | // fps = VIDEO_TRANSCODING_FPS.AVERAGE | ||
127 | // } | ||
126 | 128 | ||
127 | let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING }) | 129 | let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING }) |
128 | .output(options.outputPath) | 130 | .output(options.outputPath) |
@@ -321,12 +323,12 @@ async function presetH264 (ffmpeg: ffmpeg, resolution: VideoResolution, fps: num | |||
321 | // https://slhck.info/video/2017/03/01/rate-control.html | 323 | // https://slhck.info/video/2017/03/01/rate-control.html |
322 | // https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate | 324 | // https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate |
323 | const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) | 325 | const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) |
324 | localFfmpeg.outputOptions([`-maxrate ${ targetBitrate }`, `-bufsize ${ targetBitrate * 2 }`]) | 326 | localFfmpeg = localFfmpeg.outputOptions([`-maxrate ${ targetBitrate }`, `-bufsize ${ targetBitrate * 2 }`]) |
325 | 327 | ||
326 | // Keyframe interval of 2 seconds for faster seeking and resolution switching. | 328 | // Keyframe interval of 2 seconds for faster seeking and resolution switching. |
327 | // https://streaminglearningcenter.com/blogs/whats-the-right-keyframe-interval.html | 329 | // https://streaminglearningcenter.com/blogs/whats-the-right-keyframe-interval.html |
328 | // https://superuser.com/a/908325 | 330 | // https://superuser.com/a/908325 |
329 | localFfmpeg.outputOption(`-g ${ fps * 2 }`) | 331 | localFfmpeg = localFfmpeg.outputOption(`-g ${ fps * 2 }`) |
330 | 332 | ||
331 | return localFfmpeg | 333 | return localFfmpeg |
332 | } | 334 | } |
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 4b4a562fa..34aafa1a7 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -109,6 +109,7 @@ export class UserModel extends Model<UserModel> { | |||
109 | nsfwPolicy: NSFWPolicyType | 109 | nsfwPolicy: NSFWPolicyType |
110 | 110 | ||
111 | @AllowNull(false) | 111 | @AllowNull(false) |
112 | @Default(true) | ||
112 | @Is('UserWebTorrentEnabled', value => throwIfNotValid(value, isUserWebTorrentEnabledValid, 'WebTorrent enabled')) | 113 | @Is('UserWebTorrentEnabled', value => throwIfNotValid(value, isUserWebTorrentEnabledValid, 'WebTorrent enabled')) |
113 | @Column | 114 | @Column |
114 | webTorrentEnabled: boolean | 115 | webTorrentEnabled: boolean |
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index 2eee03843..7da5e7100 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts | |||
@@ -50,8 +50,7 @@ function getBaseBitrate (resolution: VideoResolution) { | |||
50 | * getBaseBitrate() * 1.4. All other values are calculated linearly | 50 | * getBaseBitrate() * 1.4. All other values are calculated linearly |
51 | * between these two points. | 51 | * between these two points. |
52 | */ | 52 | */ |
53 | export function getTargetBitrate (resolution: VideoResolution, fps: number, | 53 | export function getTargetBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) { |
54 | fpsTranscodingConstants: VideoTranscodingFPS) { | ||
55 | const baseBitrate = getBaseBitrate(resolution) | 54 | const baseBitrate = getBaseBitrate(resolution) |
56 | // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX | 55 | // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX |
57 | // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: | 56 | // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: |
@@ -71,7 +70,6 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number, | |||
71 | /** | 70 | /** |
72 | * The maximum bitrate we expect to see on a transcoded video in bytes per second. | 71 | * The maximum bitrate we expect to see on a transcoded video in bytes per second. |
73 | */ | 72 | */ |
74 | export function getMaxBitrate (resolution: VideoResolution, fps: number, | 73 | export function getMaxBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) { |
75 | fpsTranscodingConstants: VideoTranscodingFPS) { | ||
76 | return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2 | 74 | return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2 |
77 | } | 75 | } |