mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(web/server): Add options to rerun job on all assets (#1422)
This commit is contained in:
parent
6ea91b2dde
commit
788b435f9b
17 changed files with 234 additions and 185 deletions
|
|
@ -216,7 +216,7 @@ export class MetadataExtractionProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
await this.exifRepository.save(newExif);
|
||||
await this.exifRepository.upsert(newExif, { conflictPaths: ['assetId'] });
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Error extracting EXIF ${error}`, error?.stack);
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ export class MetadataExtractionProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
await this.exifRepository.save(newExif);
|
||||
await this.exifRepository.upsert(newExif, { conflictPaths: ['assetId'] });
|
||||
await this.assetRepository.update({ id: asset.id }, { duration: durationString, createdAt: createdAt });
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { Repository } from 'typeorm';
|
|||
|
||||
@Processor(QueueName.VIDEO_CONVERSION)
|
||||
export class VideoTranscodeProcessor {
|
||||
readonly logger = new Logger(VideoTranscodeProcessor.name);
|
||||
constructor(
|
||||
@InjectRepository(AssetEntity)
|
||||
private assetRepository: Repository<AssetEntity>,
|
||||
|
|
@ -20,7 +21,6 @@ export class VideoTranscodeProcessor {
|
|||
@Process({ name: JobName.VIDEO_CONVERSION, concurrency: 2 })
|
||||
async videoConversion(job: Job<IVideoConversionProcessor>) {
|
||||
const { asset } = job.data;
|
||||
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
const encodedVideoPath = `${basePath}/${asset.userId}/encoded-video`;
|
||||
|
||||
|
|
@ -30,17 +30,14 @@ export class VideoTranscodeProcessor {
|
|||
|
||||
const savedEncodedPath = `${encodedVideoPath}/${asset.id}.mp4`;
|
||||
|
||||
if (!asset.encodedVideoPath) {
|
||||
// Put the processing into its own async function to prevent the job exist right away
|
||||
await this.runVideoEncode(asset, savedEncodedPath);
|
||||
}
|
||||
await this.runVideoEncode(asset, savedEncodedPath);
|
||||
}
|
||||
|
||||
async runFFProbePipeline(asset: AssetEntity): Promise<FfprobeData> {
|
||||
return new Promise((resolve, reject) => {
|
||||
ffmpeg.ffprobe(asset.originalPath, (err, data) => {
|
||||
if (err || !data) {
|
||||
Logger.error(`Cannot probe video ${err}`, 'mp4Conversion');
|
||||
this.logger.error(`Cannot probe video ${err}`, 'runFFProbePipeline');
|
||||
reject(err);
|
||||
}
|
||||
|
||||
|
|
@ -88,14 +85,14 @@ export class VideoTranscodeProcessor {
|
|||
])
|
||||
.output(savedEncodedPath)
|
||||
.on('start', () => {
|
||||
Logger.log('Start Converting Video', 'mp4Conversion');
|
||||
this.logger.log('Start Converting Video');
|
||||
})
|
||||
.on('error', (error) => {
|
||||
Logger.error(`Cannot Convert Video ${error}`, 'mp4Conversion');
|
||||
this.logger.error(`Cannot Convert Video ${error}`);
|
||||
reject();
|
||||
})
|
||||
.on('end', async () => {
|
||||
Logger.log(`Converting Success ${asset.id}`, 'mp4Conversion');
|
||||
this.logger.log(`Converting Success ${asset.id}`);
|
||||
await this.assetRepository.update({ id: asset.id }, { encodedVideoPath: savedEncodedPath });
|
||||
resolve();
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue