mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server): split generated content into a separate folder (#2047)
* feat: organize media folders * fix: tests
This commit is contained in:
parent
b862c20e8e
commit
2400004f41
19 changed files with 113 additions and 91 deletions
|
|
@ -1,11 +1,13 @@
|
|||
import {
|
||||
APP_UPLOAD_LOCATION,
|
||||
IAssetJob,
|
||||
IAssetRepository,
|
||||
IBaseJob,
|
||||
IJobRepository,
|
||||
IStorageRepository,
|
||||
JobName,
|
||||
QueueName,
|
||||
StorageCore,
|
||||
StorageFolder,
|
||||
SystemConfigService,
|
||||
WithoutProperty,
|
||||
} from '@app/domain';
|
||||
|
|
@ -14,15 +16,18 @@ import { Process, Processor } from '@nestjs/bull';
|
|||
import { Inject, Logger } from '@nestjs/common';
|
||||
import { Job } from 'bull';
|
||||
import ffmpeg, { FfprobeData } from 'fluent-ffmpeg';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
@Processor(QueueName.VIDEO_CONVERSION)
|
||||
export class VideoTranscodeProcessor {
|
||||
readonly logger = new Logger(VideoTranscodeProcessor.name);
|
||||
private storageCore = new StorageCore();
|
||||
|
||||
constructor(
|
||||
@Inject(IAssetRepository) private assetRepository: IAssetRepository,
|
||||
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
||||
private systemConfigService: SystemConfigService,
|
||||
@Inject(IStorageRepository) private storageRepository: IStorageRepository,
|
||||
) {}
|
||||
|
||||
@Process({ name: JobName.QUEUE_VIDEO_CONVERSION, concurrency: 1 })
|
||||
|
|
@ -43,14 +48,12 @@ export class VideoTranscodeProcessor {
|
|||
@Process({ name: JobName.VIDEO_CONVERSION, concurrency: 2 })
|
||||
async handleVideoConversion(job: Job<IAssetJob>) {
|
||||
const { asset } = job.data;
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
const encodedVideoPath = `${basePath}/${asset.ownerId}/encoded-video`;
|
||||
|
||||
if (!existsSync(encodedVideoPath)) {
|
||||
mkdirSync(encodedVideoPath, { recursive: true });
|
||||
}
|
||||
const encodedVideoPath = this.storageCore.getFolderLocation(StorageFolder.ENCODED_VIDEO, asset.ownerId);
|
||||
|
||||
const savedEncodedPath = `${encodedVideoPath}/${asset.id}.mp4`;
|
||||
this.storageRepository.mkdirSync(encodedVideoPath);
|
||||
|
||||
const savedEncodedPath = join(encodedVideoPath, `${asset.id}.mp4`);
|
||||
|
||||
await this.runVideoEncode(asset, savedEncodedPath);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue