Sony Camera Video Duration Metadata caculation is wrong #2181

Closed
opened 2026-02-05 05:31:06 +03:00 by OVERLORD · 9 comments
Owner

Originally created by @mingqlin on GitHub (Feb 18, 2024).

Originally assigned to: @jrasm91 on GitHub.

The bug

I have Sony DLSR A7R3. Currently, the duration shown on Home Grid is the value directly from XML (two examples attached), so my video actual 17 seconds, is shown as 525 seconds. The correct duration value should be Duration / Frame Per Second, so the above duration 525 needs to be divided by 29.97 to get the correct duration

<?xml version="1.0" encoding="UTF-8"?> <NonRealTimeMeta xmlns="urn:schemas-professionalDisc:nonRealTimeMeta:ver.2.00" xmlns:lib="urn:schemas-professionalDisc:lib:ver.2.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" lastUpdate="2023-12-30T04:59:18+08:00"> <TargetMaterial umidRef="060A2B340101010501010D4313000000D4663535070306D9A0C9A0FFFE52EAF1"/> <Duration value="525"/> <LtcChangeTable tcFps="30" halfStep="false"> <LtcChange frameCount="0" value="59041204" status="increment"/> <LtcChange frameCount="524" value="43221204" status="end"/> </LtcChangeTable> <CreationDate value="2023-12-30T04:59:18+08:00"/> <VideoFormat> <VideoRecPort port="DIRECT"/> <VideoFrame videoCodec="AVC_3840_2160_HP@L51" captureFps="29.97p" formatFps="29.97p"/> <VideoLayout pixel="3840" numOfVerticalLine="2160" aspectRatio="16:9"/> </VideoFormat> <AudioFormat numOfChannel="2"> <AudioRecPort port="DIRECT" audioCodec="LPCM16" trackDst="CH1"/> <AudioRecPort port="DIRECT" audioCodec="LPCM16" trackDst="CH2"/> </AudioFormat> <Device manufacturer="Sony" modelName="ILCE-7RM3" serialNo="4294967295"/> <RecordingMode type="normal" cacheRec="false"/> <AcquisitionRecord> <Group name="CameraUnitMetadataSet"> <Item name="CaptureGammaEquation" value="rec709-xvycc"/> <Item name="CaptureColorPrimaries" value="rec709"/> <Item name="CodingEquations" value="rec709"/> </Group> <Group name="ExifGPS"> <Item name="VersionID" value="2.2.0.0"/> <Item name="LatitudeRef" value="N"/> <Item name="Latitude" value="22:19:35.817"/> <Item name="LongitudeRef" value="E"/> <Item name="Longitude" value="114:09:15.980"/> <Item name="TimeStamp" value="20:59:10.000"/> <Item name="Status" value="A"/> <Item name="MeasureMode" value="2"/> <Item name="MapDatum" value="WGS-84"/> <Item name="DateStamp" value="2023:12:29"/> <Item name="Differential" value="0"/> </Group> </AcquisitionRecord> </NonRealTimeMeta>
C0001M01.zip

C0040M01.zip

The OS that Immich Server is running on

Unraid

Version of Immich Server

v1.94.1

Version of Immich Mobile App

v1.94.1

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

N/A

Your .env content

N/A

Reproduction steps

N/A

Additional information

No response

Originally created by @mingqlin on GitHub (Feb 18, 2024). Originally assigned to: @jrasm91 on GitHub. ### The bug I have Sony DLSR A7R3. Currently, the duration shown on Home Grid is the value directly from XML <Duration value="525"/> (two examples attached), so my video actual 17 seconds, is shown as 525 seconds. The correct duration value should be Duration / Frame Per Second, so the above duration 525 needs to be divided by 29.97 to get the correct duration `<?xml version="1.0" encoding="UTF-8"?> <NonRealTimeMeta xmlns="urn:schemas-professionalDisc:nonRealTimeMeta:ver.2.00" xmlns:lib="urn:schemas-professionalDisc:lib:ver.2.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" lastUpdate="2023-12-30T04:59:18+08:00"> <TargetMaterial umidRef="060A2B340101010501010D4313000000D4663535070306D9A0C9A0FFFE52EAF1"/> <Duration value="525"/> <LtcChangeTable tcFps="30" halfStep="false"> <LtcChange frameCount="0" value="59041204" status="increment"/> <LtcChange frameCount="524" value="43221204" status="end"/> </LtcChangeTable> <CreationDate value="2023-12-30T04:59:18+08:00"/> <VideoFormat> <VideoRecPort port="DIRECT"/> <VideoFrame videoCodec="AVC_3840_2160_HP@L51" captureFps="29.97p" formatFps="29.97p"/> <VideoLayout pixel="3840" numOfVerticalLine="2160" aspectRatio="16:9"/> </VideoFormat> <AudioFormat numOfChannel="2"> <AudioRecPort port="DIRECT" audioCodec="LPCM16" trackDst="CH1"/> <AudioRecPort port="DIRECT" audioCodec="LPCM16" trackDst="CH2"/> </AudioFormat> <Device manufacturer="Sony" modelName="ILCE-7RM3" serialNo="4294967295"/> <RecordingMode type="normal" cacheRec="false"/> <AcquisitionRecord> <Group name="CameraUnitMetadataSet"> <Item name="CaptureGammaEquation" value="rec709-xvycc"/> <Item name="CaptureColorPrimaries" value="rec709"/> <Item name="CodingEquations" value="rec709"/> </Group> <Group name="ExifGPS"> <Item name="VersionID" value="2.2.0.0"/> <Item name="LatitudeRef" value="N"/> <Item name="Latitude" value="22:19:35.817"/> <Item name="LongitudeRef" value="E"/> <Item name="Longitude" value="114:09:15.980"/> <Item name="TimeStamp" value="20:59:10.000"/> <Item name="Status" value="A"/> <Item name="MeasureMode" value="2"/> <Item name="MapDatum" value="WGS-84"/> <Item name="DateStamp" value="2023:12:29"/> <Item name="Differential" value="0"/> </Group> </AcquisitionRecord> </NonRealTimeMeta> ` [C0001M01.zip](https://github.com/immich-app/immich/files/14324301/C0001M01.zip) [C0040M01.zip](https://github.com/immich-app/immich/files/14324298/C0040M01.zip) ### The OS that Immich Server is running on Unraid ### Version of Immich Server v1.94.1 ### Version of Immich Mobile App v1.94.1 ### Platform with the issue - [ ] Server - [ ] Web - [X] Mobile ### Your docker-compose.yml content ```YAML N/A ``` ### Your .env content ```Shell N/A ``` ### Reproduction steps ```bash N/A ``` ### Additional information _No response_
Author
Owner

@amatheo commented on GitHub (Feb 20, 2024):

Same issue here on the A7IV, web and mobile on latest (1.94.1) version docker

I don't know if it's linked but the compressed raw format (picture) is showing as black thumbnail (failed to generate).

@amatheo commented on GitHub (Feb 20, 2024): Same issue here on the A7IV, web and mobile on latest (1.94.1) version docker I don't know if it's linked but the compressed raw format (picture) is showing as black thumbnail (failed to generate).
Author
Owner

@goyourfly commented on GitHub (Apr 18, 2024):

Same issue on the Sony A7C2

@goyourfly commented on GitHub (Apr 18, 2024): Same issue on the Sony A7C2
Author
Owner

@yodatak commented on GitHub (Apr 19, 2024):

Same with a7iii too

@yodatak commented on GitHub (Apr 19, 2024): Same with a7iii too
Author
Owner

@jrasm91 commented on GitHub (Sep 10, 2024):

I can't use this XML to test anything. Can somebody upload a file I can test with. And/or send the output of

exiftool -struct -json -n path/to/file.jpg
@jrasm91 commented on GitHub (Sep 10, 2024): I can't use this XML to test anything. Can somebody upload a file I can test with. And/or send the output of ``` exiftool -struct -json -n path/to/file.jpg ```
Author
Owner

@yodatak commented on GitHub (Sep 10, 2024):

I already have some issue with this format, https://gitlab.gnome.org/YaLTeR/video-trimmer/-/issues/29

you could normaly find footage here
https://video.stackexchange.com/questions/27600/concatenating-in-sync-mp4-h264pcm-instead-of-aac-from-a-sony-2018-camera

I will do some action later from my linux computer
thanks !

@yodatak commented on GitHub (Sep 10, 2024): I already have some issue with this format, https://gitlab.gnome.org/YaLTeR/video-trimmer/-/issues/29 you could normaly find footage here https://video.stackexchange.com/questions/27600/concatenating-in-sync-mp4-h264pcm-instead-of-aac-from-a-sony-2018-camera I will do some action later from my linux computer thanks !
Author
Owner

@jrasm91 commented on GitHub (Sep 12, 2024):

I cannot reproduce this using the videos from the stackexchange post. If you find a video and this is still an issue, please upload it and I'm happy to reopen this.

@jrasm91 commented on GitHub (Sep 12, 2024): I cannot reproduce this using the videos from the stackexchange post. If you find a video and this is still an issue, please upload it and I'm happy to reopen this.
Author
Owner

@yodatak commented on GitHub (Sep 12, 2024):

Some video footage that seem to be broken it show in my feed as 82:00 when i over i change
Capture d’écran du 2024-09-11 23-53-09

image

exfi command

[{
  "SourceFile": "20240804-teteorvideo-77-C0018.mp4",
  "ExifToolVersion": 12.70,
  "FileName": "20240804-teteorvideo-77-C0018.mp4",
  "Directory": ".",
  "FileSize": 507574580,
  "FileModifyDate": "2024:09:11 23:52:40+02:00",
  "FileAccessDate": "2024:09:11 23:52:38+02:00",
  "FileInodeChangeDate": "2024:09:11 23:52:40+02:00",
  "FilePermissions": 100644,
  "FileType": "MP4",
  "FileTypeExtension": "MP4",
  "MIMEType": "video/mp4",
  "MajorBrand": "XAVC",
  "MinorVersion": "100.1f.ff",
  "CompatibleBrands": ["XAVC","mp42","iso2"],
  "FileFunctionFlags": 536870912,
  "AudioTrackID": 2,
  "AudioCodec": "twos",
  "AudioAttributes": 0,
  "AudioAvgBitrate": 1536000,
  "AudioMaxBitrate": 1536000,
  "VideoTrackID": 1,
  "VideoCodec": "avc1",
  "VideoAttributes": 196610,
  "VideoAvgBitrate": 100000000,
  "VideoMaxBitrate": 100000000,
  "VideoAvgFrameRate": 119.88011,
  "VideoMaxFrameRate": 119.88011,
  "VideoSize": "1920 1080",
  "PixelAspectRatio": "1 1",
  "MediaDataSize": 507510592,
  "MediaDataOffset": 192,
  "MovieHeaderVersion": 0,
  "CreateDate": "2024:08:04 13:39:03",
  "ModifyDate": "2024:08:04 13:39:03",
  "TimeScale": 120000,
  "PreferredRate": 1,
  "PreferredVolume": 1,
  "PreviewTime": 0,
  "PreviewDuration": 0,
  "PosterTime": 0,
  "SelectionTime": 0,
  "SelectionDuration": 0,
  "CurrentTime": 0,
  "NextTrackID": 4,
  "TrackHeaderVersion": 0,
  "TrackCreateDate": "2024:08:04 13:39:03",
  "TrackModifyDate": "2024:08:04 13:39:03",
  "TrackID": 1,
  "TrackDuration": 41.041,
  "TrackLayer": 0,
  "TrackVolume": 0,
  "ImageWidth": 1920,
  "ImageHeight": 1080,
  "GraphicsMode": 0,
  "OpColor": "0 0 0",
  "CompressorID": "avc1",
  "SourceImageWidth": 1920,
  "SourceImageHeight": 1080,
  "XResolution": 72,
  "YResolution": 72,
  "CompressorName": "AVC Coding",
  "BitDepth": 24,
  "VideoFrameRate": 119.88011988012,
  "Balance": 0,
  "AudioChannels": 2,
  "AudioBitsPerSample": 16,
  "AudioSampleRate": 48000,
  "MatrixStructure": "1 0 0 0 1 0 0 0 1",
  "ContentDescribes": 1,
  "MediaHeaderVersion": 0,
  "MediaCreateDate": "2024:08:04 13:39:03",
  "MediaModifyDate": "2024:08:04 13:39:03",
  "MediaTimeScale": 120000,
  "MediaDuration": 41.041,
  "MediaLanguageCode": "und",
  "MetaFormat": "rtmd",
  "Warning": "[minor] The ExtractEmbedded option may find more tags in the media data",
  "TrackProperty": "16 0 0",
  "TimeZone": 60,
  "HandlerType": "nrtm",
  "HandlerDescription": "Non-Real Time Metadata",
  "LastUpdate": "2024:08:04 14:39:03+01:00",
  "TargetMaterial": {
    "UmidRef": "060A2B340101010501010D43130000004253469C260506D1009D6BFFFEB07C43"
  },
  "Duration": {
    "Value": 4920
  },
  "LtcChangeTable": {
    "HalfStep": true,
    "LtcChange": {
      "FrameCount": 4919,
      "Status": "increment",
      "Value": "43B90516"
    },
    "TcFps": 30
  },
  "LtcChangeTableLtcChangeValue": 42580416,
  "LtcChangeTableLtcChangeStatus": "end",
  "CreationDate": {
    "Value": "2024:08:04 14:39:03+01:00"
  },
  "VideoFormat": {
    "VideoFrame": {
      "CaptureFps": "119.88p",
      "FormatFps": "119.88p",
      "VideoCodec": "AVC_1920_1080_HP@L51"
    },
    "VideoLayout": {
      "AspectRatio": "16:9",
      "NumOfVerticalLine": 1080,
      "Pixel": 1920
    },
    "VideoRecPort": {
      "Port": "DIRECT"
    }
  },
  "AudioFormat": {
    "AudioRecPort": {
      "AudioCodec": "LPCM16",
      "Port": "DIRECT",
      "TrackDst": "CH1"
    },
    "NumOfChannel": 2
  },
  "AudioFormatAudioRecPortPort": "DIRECT",
  "AudioFormatAudioRecPortAudioCodec": "LPCM16",
  "AudioFormatAudioRecPortTrackDst": "CH2",
  "Device": {
    "Manufacturer": "Sony",
    "ModelName": "ILCE-7M3",
    "SerialNo": 4294967295
  },
  "RecordingMode": {
    "CacheRec": false,
    "Type": "normal"
  },
  "AcquisitionRecord": {
    "Group": {
      "Item": {
        "Name": "CaptureColorPrimaries",
        "Value": "rec709-xvycc"
      },
      "Name": "CameraUnitMetadataSet"
    }
  },
  "AcquisitionRecordGroupItemName": "CaptureGammaEquation",
  "AcquisitionRecordGroupItemValue": "rec709",
  "ImageSize": "1920 1080",
  "Megapixels": 2.0736,
  "AvgBitrate": 98917889,
  "Rotation": 0
}]

https://fromsmash.com/testvideosonybroken

@yodatak commented on GitHub (Sep 12, 2024): Some video footage that seem to be broken it show in my feed as 82:00 when i over i change ![Capture d’écran du 2024-09-11 23-53-09](https://github.com/user-attachments/assets/a727f9ea-3a4b-490d-b97d-3cac3059b2ed) ![image](https://github.com/user-attachments/assets/bdfd2cfd-0bb3-4056-bd75-16240f4660e2) exfi command ```json [{ "SourceFile": "20240804-teteorvideo-77-C0018.mp4", "ExifToolVersion": 12.70, "FileName": "20240804-teteorvideo-77-C0018.mp4", "Directory": ".", "FileSize": 507574580, "FileModifyDate": "2024:09:11 23:52:40+02:00", "FileAccessDate": "2024:09:11 23:52:38+02:00", "FileInodeChangeDate": "2024:09:11 23:52:40+02:00", "FilePermissions": 100644, "FileType": "MP4", "FileTypeExtension": "MP4", "MIMEType": "video/mp4", "MajorBrand": "XAVC", "MinorVersion": "100.1f.ff", "CompatibleBrands": ["XAVC","mp42","iso2"], "FileFunctionFlags": 536870912, "AudioTrackID": 2, "AudioCodec": "twos", "AudioAttributes": 0, "AudioAvgBitrate": 1536000, "AudioMaxBitrate": 1536000, "VideoTrackID": 1, "VideoCodec": "avc1", "VideoAttributes": 196610, "VideoAvgBitrate": 100000000, "VideoMaxBitrate": 100000000, "VideoAvgFrameRate": 119.88011, "VideoMaxFrameRate": 119.88011, "VideoSize": "1920 1080", "PixelAspectRatio": "1 1", "MediaDataSize": 507510592, "MediaDataOffset": 192, "MovieHeaderVersion": 0, "CreateDate": "2024:08:04 13:39:03", "ModifyDate": "2024:08:04 13:39:03", "TimeScale": 120000, "PreferredRate": 1, "PreferredVolume": 1, "PreviewTime": 0, "PreviewDuration": 0, "PosterTime": 0, "SelectionTime": 0, "SelectionDuration": 0, "CurrentTime": 0, "NextTrackID": 4, "TrackHeaderVersion": 0, "TrackCreateDate": "2024:08:04 13:39:03", "TrackModifyDate": "2024:08:04 13:39:03", "TrackID": 1, "TrackDuration": 41.041, "TrackLayer": 0, "TrackVolume": 0, "ImageWidth": 1920, "ImageHeight": 1080, "GraphicsMode": 0, "OpColor": "0 0 0", "CompressorID": "avc1", "SourceImageWidth": 1920, "SourceImageHeight": 1080, "XResolution": 72, "YResolution": 72, "CompressorName": "AVC Coding", "BitDepth": 24, "VideoFrameRate": 119.88011988012, "Balance": 0, "AudioChannels": 2, "AudioBitsPerSample": 16, "AudioSampleRate": 48000, "MatrixStructure": "1 0 0 0 1 0 0 0 1", "ContentDescribes": 1, "MediaHeaderVersion": 0, "MediaCreateDate": "2024:08:04 13:39:03", "MediaModifyDate": "2024:08:04 13:39:03", "MediaTimeScale": 120000, "MediaDuration": 41.041, "MediaLanguageCode": "und", "MetaFormat": "rtmd", "Warning": "[minor] The ExtractEmbedded option may find more tags in the media data", "TrackProperty": "16 0 0", "TimeZone": 60, "HandlerType": "nrtm", "HandlerDescription": "Non-Real Time Metadata", "LastUpdate": "2024:08:04 14:39:03+01:00", "TargetMaterial": { "UmidRef": "060A2B340101010501010D43130000004253469C260506D1009D6BFFFEB07C43" }, "Duration": { "Value": 4920 }, "LtcChangeTable": { "HalfStep": true, "LtcChange": { "FrameCount": 4919, "Status": "increment", "Value": "43B90516" }, "TcFps": 30 }, "LtcChangeTableLtcChangeValue": 42580416, "LtcChangeTableLtcChangeStatus": "end", "CreationDate": { "Value": "2024:08:04 14:39:03+01:00" }, "VideoFormat": { "VideoFrame": { "CaptureFps": "119.88p", "FormatFps": "119.88p", "VideoCodec": "AVC_1920_1080_HP@L51" }, "VideoLayout": { "AspectRatio": "16:9", "NumOfVerticalLine": 1080, "Pixel": 1920 }, "VideoRecPort": { "Port": "DIRECT" } }, "AudioFormat": { "AudioRecPort": { "AudioCodec": "LPCM16", "Port": "DIRECT", "TrackDst": "CH1" }, "NumOfChannel": 2 }, "AudioFormatAudioRecPortPort": "DIRECT", "AudioFormatAudioRecPortAudioCodec": "LPCM16", "AudioFormatAudioRecPortTrackDst": "CH2", "Device": { "Manufacturer": "Sony", "ModelName": "ILCE-7M3", "SerialNo": 4294967295 }, "RecordingMode": { "CacheRec": false, "Type": "normal" }, "AcquisitionRecord": { "Group": { "Item": { "Name": "CaptureColorPrimaries", "Value": "rec709-xvycc" }, "Name": "CameraUnitMetadataSet" } }, "AcquisitionRecordGroupItemName": "CaptureGammaEquation", "AcquisitionRecordGroupItemValue": "rec709", "ImageSize": "1920 1080", "Megapixels": 2.0736, "AvgBitrate": 98917889, "Rotation": 0 }] ``` https://fromsmash.com/testvideosonybroken
Author
Owner

@jrasm91 commented on GitHub (Sep 12, 2024):

Perfect. We can look at using MediaDuration if it is available.

@jrasm91 commented on GitHub (Sep 12, 2024): Perfect. We can look at using MediaDuration if it is available.
Author
Owner

@jrasm91 commented on GitHub (Sep 12, 2024):

Went down a bit of a rabbit hole. Turns out we get this metadata from ffprobe, so this is likely fixed by #11610. Just re-run metadata extraction on the bad video and see if the duration corrects itself.

@jrasm91 commented on GitHub (Sep 12, 2024): Went down a bit of a rabbit hole. Turns out we get this metadata from `ffprobe`, so this is likely fixed by #11610. Just re-run metadata extraction on the bad video and see if the duration corrects itself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#2181