Fix tests
This commit is contained in:
parent
f365e978ed
commit
0229b014e0
|
@ -118,11 +118,13 @@ function transcode (options: TranscodeOptions) {
|
||||||
return new Promise<void>(async (res, rej) => {
|
return new Promise<void>(async (res, rej) => {
|
||||||
let fps = await getVideoFileFPS(options.inputPath)
|
let fps = await getVideoFileFPS(options.inputPath)
|
||||||
// On small/medium resolutions, limit FPS
|
// On small/medium resolutions, limit FPS
|
||||||
if (options.resolution !== undefined &&
|
// if (
|
||||||
options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN &&
|
// options.resolution !== undefined &&
|
||||||
fps > VIDEO_TRANSCODING_FPS.AVERAGE) {
|
// options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN &&
|
||||||
fps = VIDEO_TRANSCODING_FPS.AVERAGE
|
// fps > VIDEO_TRANSCODING_FPS.AVERAGE
|
||||||
}
|
// ) {
|
||||||
|
// fps = VIDEO_TRANSCODING_FPS.AVERAGE
|
||||||
|
// }
|
||||||
|
|
||||||
let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING })
|
let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING })
|
||||||
.output(options.outputPath)
|
.output(options.outputPath)
|
||||||
|
@ -321,12 +323,12 @@ async function presetH264 (ffmpeg: ffmpeg, resolution: VideoResolution, fps: num
|
||||||
// https://slhck.info/video/2017/03/01/rate-control.html
|
// https://slhck.info/video/2017/03/01/rate-control.html
|
||||||
// https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
|
// https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
|
||||||
const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
|
const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
|
||||||
localFfmpeg.outputOptions([`-maxrate ${ targetBitrate }`, `-bufsize ${ targetBitrate * 2 }`])
|
localFfmpeg = localFfmpeg.outputOptions([`-maxrate ${ targetBitrate }`, `-bufsize ${ targetBitrate * 2 }`])
|
||||||
|
|
||||||
// Keyframe interval of 2 seconds for faster seeking and resolution switching.
|
// Keyframe interval of 2 seconds for faster seeking and resolution switching.
|
||||||
// https://streaminglearningcenter.com/blogs/whats-the-right-keyframe-interval.html
|
// https://streaminglearningcenter.com/blogs/whats-the-right-keyframe-interval.html
|
||||||
// https://superuser.com/a/908325
|
// https://superuser.com/a/908325
|
||||||
localFfmpeg.outputOption(`-g ${ fps * 2 }`)
|
localFfmpeg = localFfmpeg.outputOption(`-g ${ fps * 2 }`)
|
||||||
|
|
||||||
return localFfmpeg
|
return localFfmpeg
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
nsfwPolicy: NSFWPolicyType
|
nsfwPolicy: NSFWPolicyType
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
|
@Default(true)
|
||||||
@Is('UserWebTorrentEnabled', value => throwIfNotValid(value, isUserWebTorrentEnabledValid, 'WebTorrent enabled'))
|
@Is('UserWebTorrentEnabled', value => throwIfNotValid(value, isUserWebTorrentEnabledValid, 'WebTorrent enabled'))
|
||||||
@Column
|
@Column
|
||||||
webTorrentEnabled: boolean
|
webTorrentEnabled: boolean
|
||||||
|
|
|
@ -50,8 +50,7 @@ function getBaseBitrate (resolution: VideoResolution) {
|
||||||
* getBaseBitrate() * 1.4. All other values are calculated linearly
|
* getBaseBitrate() * 1.4. All other values are calculated linearly
|
||||||
* between these two points.
|
* between these two points.
|
||||||
*/
|
*/
|
||||||
export function getTargetBitrate (resolution: VideoResolution, fps: number,
|
export function getTargetBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) {
|
||||||
fpsTranscodingConstants: VideoTranscodingFPS) {
|
|
||||||
const baseBitrate = getBaseBitrate(resolution)
|
const baseBitrate = getBaseBitrate(resolution)
|
||||||
// The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
|
// The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
|
||||||
// Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
|
// Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
|
||||||
|
@ -71,7 +70,6 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number,
|
||||||
/**
|
/**
|
||||||
* The maximum bitrate we expect to see on a transcoded video in bytes per second.
|
* The maximum bitrate we expect to see on a transcoded video in bytes per second.
|
||||||
*/
|
*/
|
||||||
export function getMaxBitrate (resolution: VideoResolution, fps: number,
|
export function getMaxBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) {
|
||||||
fpsTranscodingConstants: VideoTranscodingFPS) {
|
|
||||||
return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2
|
return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue