mirror of
https://github.com/immich-app/immich.git
synced 2025-12-07 01:10:00 +03:00
Compare commits
2 Commits
feat/ml-ar
...
feat/serve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f48318168b | ||
|
|
dda736840b |
File diff suppressed because it is too large
Load Diff
@@ -188,6 +188,7 @@ export class MediaService {
|
||||
const { image, ffmpeg } = await this.configCore.getConfig();
|
||||
const size = type === AssetPathType.PREVIEW ? image.previewSize : image.thumbnailSize;
|
||||
const path = StorageCore.getImagePath(asset, type, format);
|
||||
const tmpPath = `${StorageCore.getTempPathInDir(dirname(path))}.${format}`;
|
||||
this.storageCore.ensureFolders(path);
|
||||
|
||||
switch (asset.type) {
|
||||
@@ -201,8 +202,11 @@ export class MediaService {
|
||||
const colorspace = this.isSRGB(asset) ? Colorspace.SRGB : image.colorspace;
|
||||
const imageOptions = { format, size, colorspace, quality: image.quality };
|
||||
|
||||
const outputPath = useExtracted ? extractedPath : asset.originalPath;
|
||||
await this.mediaRepository.generateThumbnail(outputPath, path, imageOptions);
|
||||
const inputPath = useExtracted ? extractedPath : asset.originalPath;
|
||||
await this.mediaRepository.generateThumbnail(inputPath, tmpPath, imageOptions);
|
||||
} catch (error) {
|
||||
await this.storageRepository.unlink(tmpPath);
|
||||
throw error;
|
||||
} finally {
|
||||
if (didExtract) {
|
||||
await this.storageRepository.unlink(extractedPath);
|
||||
@@ -221,7 +225,12 @@ export class MediaService {
|
||||
const mainAudioStream = this.getMainStream(audioStreams);
|
||||
const config = ThumbnailConfig.create({ ...ffmpeg, targetResolution: size.toString() });
|
||||
const options = config.getCommand(TranscodeTarget.VIDEO, mainVideoStream, mainAudioStream);
|
||||
await this.mediaRepository.transcode(asset.originalPath, path, options);
|
||||
try {
|
||||
await this.mediaRepository.transcode(asset.originalPath, tmpPath, options);
|
||||
} catch (error) {
|
||||
await this.storageRepository.unlink(tmpPath);
|
||||
throw error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -229,6 +238,9 @@ export class MediaService {
|
||||
throw new UnsupportedMediaTypeException(`Unsupported asset type for thumbnail generation: ${asset.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
await this.storageRepository.rename(tmpPath, path);
|
||||
|
||||
this.logger.log(
|
||||
`Successfully generated ${format.toUpperCase()} ${asset.type.toLowerCase()} ${type} for asset ${asset.id}`,
|
||||
);
|
||||
@@ -340,8 +352,9 @@ export class MediaService {
|
||||
}
|
||||
|
||||
this.logger.log(`Started encoding video ${asset.id} ${JSON.stringify(command)}`);
|
||||
const tmpPath = StorageCore.getTempPathInDir(dirname(output));
|
||||
try {
|
||||
await this.mediaRepository.transcode(input, output, command);
|
||||
await this.mediaRepository.transcode(input, tmpPath, command);
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
if (ffmpeg.accel !== TranscodeHWAccel.DISABLED) {
|
||||
@@ -349,11 +362,20 @@ export class MediaService {
|
||||
`Error occurred during transcoding. Retrying with ${ffmpeg.accel.toUpperCase()} acceleration disabled.`,
|
||||
);
|
||||
}
|
||||
const config = BaseConfig.create({ ...ffmpeg, accel: TranscodeHWAccel.DISABLED });
|
||||
command = config.getCommand(target, mainVideoStream, mainAudioStream);
|
||||
await this.mediaRepository.transcode(input, output, command);
|
||||
|
||||
try {
|
||||
const config = BaseConfig.create({ ...ffmpeg, accel: TranscodeHWAccel.DISABLED });
|
||||
command = config.getCommand(target, mainVideoStream, mainAudioStream);
|
||||
await this.mediaRepository.transcode(input, tmpPath, command);
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
await this.storageRepository.unlink(tmpPath);
|
||||
return JobStatus.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
await this.storageRepository.rename(tmpPath, output);
|
||||
|
||||
this.logger.log(`Successfully encoded ${asset.id}`);
|
||||
|
||||
await this.assetRepository.update({ id: asset.id, encodedVideoPath: output });
|
||||
|
||||
Reference in New Issue
Block a user