@@ -354,7 +354,7 @@ export class MetadataService {
354
354
}
355
355
356
356
private async applyMotionPhotos ( asset : AssetEntity , tags : ImmichTags ) {
357
- if ( asset . type !== AssetType . IMAGE || asset . livePhotoVideoId ) {
357
+ if ( asset . type !== AssetType . IMAGE ) {
358
358
return ;
359
359
}
360
360
@@ -381,7 +381,11 @@ export class MetadataService {
381
381
length = videoOffset ;
382
382
}
383
383
384
- if ( ! length ) {
384
+ if (
385
+ length === 0 &&
386
+ tags . MotionPhotoVideo === undefined &&
387
+ ( tags . EmbeddedVideoFile === undefined || tags . EmbeddedVideoType !== 'MotionPhoto_Data' )
388
+ ) {
385
389
return ;
386
390
}
387
391
@@ -392,11 +396,11 @@ export class MetadataService {
392
396
const position = stat . size - length - padding ;
393
397
let video : Buffer ;
394
398
// Samsung MotionPhoto video extraction
395
- // HEIC-encoded
399
+ // HEIC-encoded
396
400
if ( tags . MotionPhotoVideo ) {
397
401
video = await this . repository . extractBinaryTag ( asset . originalPath , 'MotionPhotoVideo' ) ;
398
402
}
399
- // JPEG-encoded; HEIC also contains these tags, so this conditional must come second
403
+ // JPEG-encoded; HEIC also contains these tags, so this conditional must come second
400
404
else if ( tags . EmbeddedVideoType === 'MotionPhoto_Data' && tags . EmbeddedVideoFile ) {
401
405
video = await this . repository . extractBinaryTag ( asset . originalPath , 'EmbeddedVideoFile' ) ;
402
406
}
@@ -436,6 +440,11 @@ export class MetadataService {
436
440
await this . jobRepository . queue ( { name : JobName . METADATA_EXTRACTION , data : { id : motionAsset . id } } ) ;
437
441
}
438
442
443
+ if ( asset . livePhotoVideoId ) {
444
+ await this . jobRepository . queue ( { name : JobName . ASSET_DELETION , data : { id : asset . livePhotoVideoId } } ) ;
445
+ this . logger . log ( `Removed old motion photo video asset (${ asset . livePhotoVideoId } )` ) ;
446
+ }
447
+
439
448
await this . assetRepository . save ( { id : asset . id , livePhotoVideoId : motionAsset . id } ) ;
440
449
441
450
this . logger . debug ( `Finished motion photo video extraction (${ asset . id } )` ) ;
0 commit comments