From edb4ffc7e0b13659d7c73b120f2c87b27e4c26a1 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 8 Oct 2018 09:26:04 -0500 Subject: Set bitrate limits for transcoding (fixes #638) (#1135) * Set bitrate limits for transcoding (fixes #638) * added optimization script and test, changed stuff * fix test, improve docs * re-add optimize-old-videos script * added documentation * Don't optimize videos without valid UUID, or redundancy videos * move getUUIDFromFilename * fix tests? * update torrent and file size, some more fixes/improvements * use higher bitrate for high fps video, adjust bitrates * add test video * don't throw error if resolution is undefined * generate test fixture on the fly * use random noise video for bitrate test, add promise * shorten test video to avoid timeout * use existing function to optimize video * various fixes * increase test timeout * limit test fixture size, add link * test fixes * add await * more test fixes, add -b:v parameter * replace ffmpeg wiki link * fix ffmpeg params * fix unit test * add test fixture to .gitgnore * add video transcoding fps model * add missing file --- server/helpers/utils.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 6228fec04..39afb4e7b 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -77,6 +77,20 @@ async function getVersion () { return require('../../../package.json').version } +/** + * From a filename like "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3.mp4", returns + * only the "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3" part. If the filename does + * not contain a UUID, returns null. + */ +function getUUIDFromFilename (filename: string) { + const regex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ + const result = filename.match(regex) + + if (!result || Array.isArray(result) === false) return null + + return result[0] +} + // --------------------------------------------------------------------------- export { @@ -86,5 +100,6 @@ export { getSecureTorrentName, getServerActor, getVersion, - generateVideoTmpPath + generateVideoTmpPath, + getUUIDFromFilename } -- cgit v1.2.3 From 7ad9b9846c44d198a736183fb186c2039f5236b5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Oct 2018 15:26:04 +0200 Subject: Add ability for users to block an account/instance on server side --- server/helpers/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 39afb4e7b..049c3f8bc 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -40,7 +40,10 @@ const getServerActor = memoizee(async function () { const application = await ApplicationModel.load() if (!application) throw Error('Could not load Application from database.') - return application.Account.Actor + const actor = application.Account.Actor + actor.Account = application.Account + + return actor }) function generateVideoTmpPath (target: string | ParseTorrent) { -- cgit v1.2.3 From 1b5e2d72900c8ceaf76940b72839d3c424ac96e8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 23 Nov 2018 11:06:10 +0100 Subject: Optimize config endpoint --- server/helpers/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 049c3f8bc..5c9d6fe2f 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -57,7 +57,7 @@ function getSecureTorrentName (originalName: string) { return sha256(originalName) + '.torrent' } -async function getVersion () { +async function getServerCommit () { try { const tag = await execPromise2( '[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', @@ -77,7 +77,7 @@ async function getVersion () { logger.debug('Cannot get version from git HEAD.', { err }) } - return require('../../../package.json').version + return '' } /** @@ -102,7 +102,7 @@ export { getFormattedObjects, getSecureTorrentName, getServerActor, - getVersion, + getServerCommit, generateVideoTmpPath, getUUIDFromFilename } -- cgit v1.2.3 From 6040f87d143a5fa01db79867ece8197c3ce7be47 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Dec 2018 16:02:49 +0100 Subject: Add tmp and redundancy directories --- server/helpers/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 5c9d6fe2f..9b89e3e61 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -46,11 +46,11 @@ const getServerActor = memoizee(async function () { return actor }) -function generateVideoTmpPath (target: string | ParseTorrent) { +function generateVideoImportTmpPath (target: string | ParseTorrent) { const id = typeof target === 'string' ? target : target.infoHash const hash = sha256(id) - return join(CONFIG.STORAGE.VIDEOS_DIR, hash + '-import.mp4') + return join(CONFIG.STORAGE.TMP_DIR, hash + '-import.mp4') } function getSecureTorrentName (originalName: string) { @@ -103,6 +103,6 @@ export { getSecureTorrentName, getServerActor, getServerCommit, - generateVideoTmpPath, + generateVideoImportTmpPath, getUUIDFromFilename } -- cgit v1.2.3 From a4101923e699e49ceb9ff36e971c75417fafc9f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 Jan 2019 15:14:29 +0100 Subject: Implement contact form on server side --- server/helpers/utils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 9b89e3e61..3c3406e38 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -7,6 +7,7 @@ import { join } from 'path' import { Instance as ParseTorrent } from 'parse-torrent' import { remove } from 'fs-extra' import * as memoizee from 'memoizee' +import { isArray } from './custom-validators/misc' function deleteFileAsync (path: string) { remove(path) @@ -19,10 +20,7 @@ async function generateRandomString (size: number) { return raw.toString('hex') } -interface FormattableToJSON { - toFormattedJSON (args?: any) -} - +interface FormattableToJSON { toFormattedJSON (args?: any) } function getFormattedObjects (objects: T[], objectsTotal: number, formattedArg?: any) { const formattedObjects: U[] = [] -- cgit v1.2.3 From 4c280004ce62bf11ddb091854c28f1e1d54a54d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Feb 2019 15:08:19 +0100 Subject: Use a single file instead of segments for HLS --- server/helpers/utils.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 3c3406e38..cb0e823c5 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -7,7 +7,6 @@ import { join } from 'path' import { Instance as ParseTorrent } from 'parse-torrent' import { remove } from 'fs-extra' import * as memoizee from 'memoizee' -import { isArray } from './custom-validators/misc' function deleteFileAsync (path: string) { remove(path) -- cgit v1.2.3