mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 19:19:37 +02:00
fix(server): queue android motion assets for transcoding (#17781)
This commit is contained in:
parent
2a95eccf6a
commit
92ac1193e6
4 changed files with 29 additions and 14 deletions
server/src/services
|
@ -230,7 +230,7 @@ describe(JobService.name, () => {
|
|||
expect(mocks.logger.error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
const tests: Array<{ item: JobItem; jobs: JobName[] }> = [
|
||||
const tests: Array<{ item: JobItem; jobs: JobName[]; stub?: any }> = [
|
||||
{
|
||||
item: { name: JobName.SIDECAR_SYNC, data: { id: 'asset-1' } },
|
||||
jobs: [JobName.METADATA_EXTRACTION],
|
||||
|
@ -258,14 +258,22 @@ describe(JobService.name, () => {
|
|||
{
|
||||
item: { name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1' } },
|
||||
jobs: [],
|
||||
stub: [assetStub.image],
|
||||
},
|
||||
{
|
||||
item: { name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1' } },
|
||||
jobs: [],
|
||||
stub: [assetStub.video],
|
||||
},
|
||||
{
|
||||
item: { name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1', source: 'upload' } },
|
||||
jobs: [JobName.SMART_SEARCH, JobName.FACE_DETECTION],
|
||||
stub: [assetStub.livePhotoStillAsset],
|
||||
},
|
||||
{
|
||||
item: { name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1', source: 'upload' } },
|
||||
jobs: [JobName.SMART_SEARCH, JobName.FACE_DETECTION, JobName.VIDEO_CONVERSION],
|
||||
},
|
||||
{
|
||||
item: { name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-live-image', source: 'upload' } },
|
||||
jobs: [JobName.SMART_SEARCH, JobName.FACE_DETECTION, JobName.VIDEO_CONVERSION],
|
||||
stub: [assetStub.video],
|
||||
},
|
||||
{
|
||||
item: { name: JobName.SMART_SEARCH, data: { id: 'asset-1' } },
|
||||
|
@ -281,14 +289,10 @@ describe(JobService.name, () => {
|
|||
},
|
||||
];
|
||||
|
||||
for (const { item, jobs } of tests) {
|
||||
for (const { item, jobs, stub } of tests) {
|
||||
it(`should queue ${jobs.length} jobs when a ${item.name} job finishes successfully`, async () => {
|
||||
if (item.name === JobName.GENERATE_THUMBNAILS && item.data.source === 'upload') {
|
||||
if (item.data.id === 'asset-live-image') {
|
||||
mocks.asset.getByIdsWithAllRelationsButStacks.mockResolvedValue([assetStub.livePhotoStillAsset as any]);
|
||||
} else {
|
||||
mocks.asset.getByIdsWithAllRelationsButStacks.mockResolvedValue([assetStub.livePhotoMotionAsset as any]);
|
||||
}
|
||||
if (stub) {
|
||||
mocks.asset.getByIdsWithAllRelationsButStacks.mockResolvedValue(stub);
|
||||
}
|
||||
|
||||
mocks.job.run.mockResolvedValue(JobStatus.SUCCESS);
|
||||
|
|
|
@ -297,8 +297,6 @@ export class JobService extends BaseService {
|
|||
|
||||
if (asset.type === AssetType.VIDEO) {
|
||||
jobs.push({ name: JobName.VIDEO_CONVERSION, data: item.data });
|
||||
} else if (asset.livePhotoVideoId) {
|
||||
jobs.push({ name: JobName.VIDEO_CONVERSION, data: { id: asset.livePhotoVideoId } });
|
||||
}
|
||||
|
||||
await this.jobRepository.queueAll(jobs);
|
||||
|
|
|
@ -598,6 +598,10 @@ describe(MetadataService.name, () => {
|
|||
livePhotoVideoId: fileStub.livePhotoMotion.uuid,
|
||||
});
|
||||
expect(mocks.asset.update).toHaveBeenCalledTimes(3);
|
||||
expect(mocks.job.queue).toHaveBeenCalledExactlyOnceWith({
|
||||
name: JobName.VIDEO_CONVERSION,
|
||||
data: { id: assetStub.livePhotoMotionAsset.id },
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract the EmbeddedVideo tag from Samsung JPEG motion photos', async () => {
|
||||
|
@ -652,6 +656,10 @@ describe(MetadataService.name, () => {
|
|||
livePhotoVideoId: fileStub.livePhotoMotion.uuid,
|
||||
});
|
||||
expect(mocks.asset.update).toHaveBeenCalledTimes(3);
|
||||
expect(mocks.job.queue).toHaveBeenCalledExactlyOnceWith({
|
||||
name: JobName.VIDEO_CONVERSION,
|
||||
data: { id: assetStub.livePhotoMotionAsset.id },
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract the motion photo video from the XMP directory entry ', async () => {
|
||||
|
@ -706,6 +714,10 @@ describe(MetadataService.name, () => {
|
|||
livePhotoVideoId: fileStub.livePhotoMotion.uuid,
|
||||
});
|
||||
expect(mocks.asset.update).toHaveBeenCalledTimes(3);
|
||||
expect(mocks.job.queue).toHaveBeenCalledExactlyOnceWith({
|
||||
name: JobName.VIDEO_CONVERSION,
|
||||
data: { id: assetStub.livePhotoMotionAsset.id },
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete old motion photo video assets if they do not match what is extracted', async () => {
|
||||
|
|
|
@ -576,6 +576,7 @@ export class MetadataService extends BaseService {
|
|||
this.logger.log(`Wrote motion photo video to ${motionAsset.originalPath}`);
|
||||
|
||||
await this.handleMetadataExtraction({ id: motionAsset.id });
|
||||
await this.jobRepository.queue({ name: JobName.VIDEO_CONVERSION, data: { id: motionAsset.id } });
|
||||
}
|
||||
|
||||
this.logger.debug(`Finished motion photo video extraction for asset ${asset.id}: ${asset.originalPath}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue