mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
chore: cleanup
This commit is contained in:
@@ -346,8 +346,7 @@ export const columns = {
|
|||||||
'asset.width',
|
'asset.width',
|
||||||
'asset.height',
|
'asset.height',
|
||||||
],
|
],
|
||||||
assetFiles: ['asset_file.id', 'asset_file.path', 'asset_file.type', 'asset_file.isEdited'],
|
assetFiles: [
|
||||||
assetFilesForThumbnail: [
|
|
||||||
'asset_file.id',
|
'asset_file.id',
|
||||||
'asset_file.path',
|
'asset_file.path',
|
||||||
'asset_file.type',
|
'asset_file.type',
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -60,7 +62,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -184,7 +188,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -245,6 +251,55 @@ from
|
|||||||
where
|
where
|
||||||
"asset"."id" = $4
|
"asset"."id" = $4
|
||||||
|
|
||||||
|
-- AssetJobRepository.getForAssetEditProcessing
|
||||||
|
select
|
||||||
|
"asset"."id",
|
||||||
|
"asset"."visibility",
|
||||||
|
"asset"."originalFileName",
|
||||||
|
"asset"."originalPath",
|
||||||
|
"asset"."ownerId",
|
||||||
|
"asset"."thumbhash",
|
||||||
|
"asset"."type",
|
||||||
|
(
|
||||||
|
select
|
||||||
|
coalesce(json_agg(agg), '[]')
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
"asset_file"."id",
|
||||||
|
"asset_file"."path",
|
||||||
|
"asset_file"."type",
|
||||||
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
|
from
|
||||||
|
"asset_file"
|
||||||
|
where
|
||||||
|
"asset_file"."assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" in ($1, $2, $3, $4)
|
||||||
|
) as agg
|
||||||
|
) as "files",
|
||||||
|
(
|
||||||
|
select
|
||||||
|
coalesce(json_agg(agg), '[]')
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
"asset_edit"."action",
|
||||||
|
"asset_edit"."parameters"
|
||||||
|
from
|
||||||
|
"asset_edit"
|
||||||
|
where
|
||||||
|
"asset_edit"."assetId" = "asset"."id"
|
||||||
|
) as agg
|
||||||
|
) as "edits",
|
||||||
|
to_json("asset_exif") as "exifInfo"
|
||||||
|
from
|
||||||
|
"asset"
|
||||||
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
||||||
|
where
|
||||||
|
"asset"."id" = $5
|
||||||
|
|
||||||
-- AssetJobRepository.getForMetadataExtraction
|
-- AssetJobRepository.getForMetadataExtraction
|
||||||
select
|
select
|
||||||
"asset"."id",
|
"asset"."id",
|
||||||
@@ -288,7 +343,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -314,7 +371,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -371,7 +430,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -411,7 +472,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -436,11 +499,12 @@ select
|
|||||||
where
|
where
|
||||||
"asset_file"."assetId" = "asset"."id"
|
"asset_file"."assetId" = "asset"."id"
|
||||||
and "asset_file"."type" = $1
|
and "asset_file"."type" = $1
|
||||||
|
and "asset_file"."isEdited" = $2
|
||||||
) as "previewFile"
|
) as "previewFile"
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
where
|
where
|
||||||
"asset"."id" = $2
|
"asset"."id" = $3
|
||||||
|
|
||||||
-- AssetJobRepository.getForSyncAssets
|
-- AssetJobRepository.getForSyncAssets
|
||||||
select
|
select
|
||||||
@@ -474,7 +538,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -515,7 +581,8 @@ where
|
|||||||
|
|
||||||
-- AssetJobRepository.streamForVideoConversion
|
-- AssetJobRepository.streamForVideoConversion
|
||||||
select
|
select
|
||||||
"asset"."id"
|
"asset"."id",
|
||||||
|
"asset"."isEdited"
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
where
|
where
|
||||||
@@ -546,17 +613,34 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
"asset_file"."assetId" = "asset"."id"
|
"asset_file"."assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" = $1
|
||||||
) as agg
|
) as agg
|
||||||
) as "files"
|
) as "files",
|
||||||
|
(
|
||||||
|
select
|
||||||
|
coalesce(json_agg(agg), '[]')
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
"asset_edit"."action",
|
||||||
|
"asset_edit"."parameters"
|
||||||
|
from
|
||||||
|
"asset_edit"
|
||||||
|
where
|
||||||
|
"asset_edit"."assetId" = "asset"."id"
|
||||||
|
) as agg
|
||||||
|
) as "edits"
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
where
|
where
|
||||||
"asset"."id" = $1
|
"asset"."id" = $2
|
||||||
and "asset"."type" = 'VIDEO'
|
and "asset"."type" = 'VIDEO'
|
||||||
|
|
||||||
-- AssetJobRepository.streamForMetadataExtraction
|
-- AssetJobRepository.streamForMetadataExtraction
|
||||||
@@ -598,7 +682,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -640,7 +726,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -285,7 +285,9 @@ select
|
|||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
"asset_file"."path",
|
"asset_file"."path",
|
||||||
"asset_file"."type",
|
"asset_file"."type",
|
||||||
"asset_file"."isEdited"
|
"asset_file"."isEdited",
|
||||||
|
"asset_file"."isProgressive",
|
||||||
|
"asset_file"."isTransparent"
|
||||||
from
|
from
|
||||||
"asset_file"
|
"asset_file"
|
||||||
where
|
where
|
||||||
@@ -638,12 +640,13 @@ select
|
|||||||
where
|
where
|
||||||
"asset_file"."assetId" = "asset"."id"
|
"asset_file"."assetId" = "asset"."id"
|
||||||
and "asset_file"."type" = $1
|
and "asset_file"."type" = $1
|
||||||
|
and "asset_file"."isEdited" = $2
|
||||||
) as "encodedVideoPath"
|
) as "encodedVideoPath"
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
where
|
where
|
||||||
"asset"."id" = $2
|
"asset"."id" = $3
|
||||||
and "asset"."type" = $3
|
and "asset"."type" = $4
|
||||||
|
|
||||||
-- AssetRepository.getForOcr
|
-- AssetRepository.getForOcr
|
||||||
select
|
select
|
||||||
|
|||||||
@@ -123,15 +123,7 @@ export class AssetJobRepository {
|
|||||||
'asset.thumbhash',
|
'asset.thumbhash',
|
||||||
'asset.type',
|
'asset.type',
|
||||||
])
|
])
|
||||||
.select((eb) =>
|
.select((eb) => withFiles(eb, [AssetFileType.Thumbnail, AssetFileType.Preview, AssetFileType.FullSize]))
|
||||||
jsonArrayFrom(
|
|
||||||
eb
|
|
||||||
.selectFrom('asset_file')
|
|
||||||
.select(columns.assetFilesForThumbnail)
|
|
||||||
.whereRef('asset_file.assetId', '=', 'asset.id')
|
|
||||||
.where('asset_file.type', 'in', [AssetFileType.Thumbnail, AssetFileType.Preview, AssetFileType.FullSize]),
|
|
||||||
).as('files'),
|
|
||||||
)
|
|
||||||
.select(withEdits)
|
.select(withEdits)
|
||||||
.$call(withExifInner)
|
.$call(withExifInner)
|
||||||
.where('asset.id', '=', id)
|
.where('asset.id', '=', id)
|
||||||
@@ -152,19 +144,14 @@ export class AssetJobRepository {
|
|||||||
'asset.type',
|
'asset.type',
|
||||||
])
|
])
|
||||||
.select((eb) =>
|
.select((eb) =>
|
||||||
jsonArrayFrom(
|
withFiles(eb, [
|
||||||
eb
|
AssetFileType.Thumbnail,
|
||||||
.selectFrom('asset_file')
|
AssetFileType.Preview,
|
||||||
.select(columns.assetFilesForThumbnail)
|
AssetFileType.FullSize,
|
||||||
.whereRef('asset_file.assetId', '=', 'asset.id')
|
AssetFileType.EncodedVideo,
|
||||||
.where('asset_file.type', 'in', [
|
]),
|
||||||
AssetFileType.Thumbnail,
|
|
||||||
AssetFileType.Preview,
|
|
||||||
AssetFileType.FullSize,
|
|
||||||
AssetFileType.EncodedVideo,
|
|
||||||
]),
|
|
||||||
).as('files'),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
.select(withEdits)
|
.select(withEdits)
|
||||||
.$call(withExifInner)
|
.$call(withExifInner)
|
||||||
.where('asset.id', '=', id)
|
.where('asset.id', '=', id)
|
||||||
@@ -367,15 +354,7 @@ export class AssetJobRepository {
|
|||||||
return this.db
|
return this.db
|
||||||
.selectFrom('asset')
|
.selectFrom('asset')
|
||||||
.select(['asset.id', 'asset.ownerId', 'asset.originalPath'])
|
.select(['asset.id', 'asset.ownerId', 'asset.originalPath'])
|
||||||
.select((eb) =>
|
.select((eb) => withFiles(eb, AssetFileType.EncodedVideo))
|
||||||
jsonArrayFrom(
|
|
||||||
eb
|
|
||||||
.selectFrom('asset_file')
|
|
||||||
.select(columns.assetFilesForThumbnail)
|
|
||||||
.whereRef('asset_file.assetId', '=', 'asset.id')
|
|
||||||
.where('asset_file.type', '=', sql.lit(AssetFileType.EncodedVideo)),
|
|
||||||
).as('files'),
|
|
||||||
)
|
|
||||||
.select(withEdits)
|
.select(withEdits)
|
||||||
.where('asset.id', '=', id)
|
.where('asset.id', '=', id)
|
||||||
.where('asset.type', '=', sql.lit(AssetType.Video))
|
.where('asset.type', '=', sql.lit(AssetType.Video))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const probe = (input: string, options: string[]): Promise<FfprobeData> =>
|
|||||||
sharp.concurrency(0);
|
sharp.concurrency(0);
|
||||||
sharp.cache({ files: 0 });
|
sharp.cache({ files: 0 });
|
||||||
|
|
||||||
export type ProgressEvent = {
|
type ProgressEvent = {
|
||||||
frames: number;
|
frames: number;
|
||||||
currentFps: number;
|
currentFps: number;
|
||||||
currentKbps: number;
|
currentKbps: number;
|
||||||
@@ -327,7 +327,7 @@ export class MediaRepository {
|
|||||||
|
|
||||||
const { frameCount, percentInterval } = options.progress;
|
const { frameCount, percentInterval } = options.progress;
|
||||||
const frameInterval = Math.ceil(frameCount / (100 / percentInterval));
|
const frameInterval = Math.ceil(frameCount / (100 / percentInterval));
|
||||||
if (frameCount && frameInterval) {
|
if (this.logger.isLevelEnabled(LogLevel.Debug) && frameCount && frameInterval) {
|
||||||
let lastProgressFrame: number = 0;
|
let lastProgressFrame: number = 0;
|
||||||
ffmpegCall.on('progress', (progress: ProgressEvent) => {
|
ffmpegCall.on('progress', (progress: ProgressEvent) => {
|
||||||
if (progress.frames - lastProgressFrame < frameInterval) {
|
if (progress.frames - lastProgressFrame < frameInterval) {
|
||||||
@@ -336,17 +336,12 @@ export class MediaRepository {
|
|||||||
|
|
||||||
lastProgressFrame = progress.frames;
|
lastProgressFrame = progress.frames;
|
||||||
const percent = ((progress.frames / frameCount) * 100).toFixed(2);
|
const percent = ((progress.frames / frameCount) * 100).toFixed(2);
|
||||||
|
const ms = progress.currentFps ? Math.floor((frameCount - progress.frames) / progress.currentFps) * 1000 : 0;
|
||||||
options.progress.callback?.(progress.frames / frameCount, progress.frames);
|
const duration = ms ? Duration.fromMillis(ms).rescale().toHuman({ unitDisplay: 'narrow' }) : '';
|
||||||
|
const outputText = output instanceof Writable ? 'stream' : output.split('/').pop();
|
||||||
if (this.logger.isLevelEnabled(LogLevel.Debug)) {
|
this.logger.debug(
|
||||||
const ms = progress.currentFps ? Math.floor((frameCount - progress.frames) / progress.currentFps) * 1000 : 0;
|
`Transcoding ${percent}% done${duration ? `, estimated ${duration} remaining` : ''} for output ${outputText}`,
|
||||||
const duration = ms ? Duration.fromMillis(ms).rescale().toHuman({ unitDisplay: 'narrow' }) : '';
|
);
|
||||||
const outputText = output instanceof Writable ? 'stream' : output.split('/').pop();
|
|
||||||
this.logger.debug(
|
|
||||||
`Transcoding ${percent}% done${duration ? `, estimated ${duration} remaining` : ''} for output ${outputText}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ export class AssetService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { width: liveWidth, height: liveHeight } = getDimensions(liveAsset);
|
const { width: liveWidth, height: liveHeight } = getDimensions(liveAsset);
|
||||||
console.log(liveWidth, liveHeight);
|
|
||||||
const scaledEdits = scaleEdits(
|
const scaledEdits = scaleEdits(
|
||||||
edits,
|
edits,
|
||||||
{ width: liveWidth, height: liveHeight },
|
{ width: liveWidth, height: liveHeight },
|
||||||
|
|||||||
@@ -116,13 +116,14 @@ export function withFaces(eb: ExpressionBuilder<DB, 'asset'>, withHidden?: boole
|
|||||||
).as('faces');
|
).as('faces');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withFiles(eb: ExpressionBuilder<DB, 'asset'>, type?: AssetFileType) {
|
export function withFiles(eb: ExpressionBuilder<DB, 'asset'>, type?: AssetFileType | AssetFileType[]) {
|
||||||
return jsonArrayFrom(
|
return jsonArrayFrom(
|
||||||
eb
|
eb
|
||||||
.selectFrom('asset_file')
|
.selectFrom('asset_file')
|
||||||
.select(columns.assetFiles)
|
.select(columns.assetFiles)
|
||||||
.whereRef('asset_file.assetId', '=', 'asset.id')
|
.whereRef('asset_file.assetId', '=', 'asset.id')
|
||||||
.$if(!!type, (qb) => qb.where('asset_file.type', '=', type!)),
|
.$if(!!type && typeof type === 'string', (qb) => qb.where('asset_file.type', '=', type!))
|
||||||
|
.$if(!!type && Array.isArray(type), (qb) => qb.where('asset_file.type', 'in', type as AssetFileType[])),
|
||||||
).as('files');
|
).as('files');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user