pull/24644/merge
Timon 2025-12-18 08:01:22 +01:00 committed by GitHub
commit 64b6799bd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 1 deletions

View File

@ -38,6 +38,7 @@ For the full list, refer to the [Immich source code](https://github.com/immich-a
| `MP2T` | `.mts` `.m2ts` `.m2t` | :white_check_mark: | |
| `MP4` | `.mp4` `.insv` | :white_check_mark: | |
| `MPEG` | `.mpg` `.mpe` `.mpeg` | :white_check_mark: | |
| `MXF` | `.mxf` | :white_check_mark: | |
| `QUICKTIME` | `.mov` | :white_check_mark: | |
| `WEBM` | `.webm` | :white_check_mark: | |
| `WMV` | `.wmv` | :white_check_mark: | |

View File

@ -107,6 +107,7 @@ const validVideos = [
'.mp4',
'.mpg',
'.mts',
'.mxf',
'.vob',
'.webm',
'.wmv',

View File

@ -76,6 +76,7 @@ describe('mimeTypes', () => {
{ mimetype: 'image/x-sony-sr2', extension: '.sr2' },
{ mimetype: 'image/x-sony-srf', extension: '.srf' },
{ mimetype: 'image/x3f', extension: '.x3f' },
{ mimetype: 'application/mxf', extension: '.mxf' },
{ mimetype: 'video/3gpp', extension: '.3gp' },
{ mimetype: 'video/3gpp', extension: '.3gpp' },
{ mimetype: 'video/avi', extension: '.avi' },
@ -188,7 +189,7 @@ describe('mimeTypes', () => {
it('should contain only video mime types', () => {
const values = Object.values(mimeTypes.video).flat();
expect(values).toEqual(values.filter((mimeType) => mimeType.startsWith('video/')));
expect(values).toEqual(values.filter((mimeType) => mimeType.startsWith('video/') || mimeType === 'application/mxf'));
});
for (const [extension, v] of Object.entries(mimeTypes.video)) {

View File

@ -94,6 +94,7 @@ const video: Record<string, string[]> = {
'.mpeg': ['video/mpeg'],
'.mpg': ['video/mpeg'],
'.mts': ['video/mp2t'],
'.mxf': ['application/mxf'],
'.vob': ['video/mpeg'],
'.webm': ['video/webm'],
'.wmv': ['video/x-ms-wmv'],
@ -133,6 +134,14 @@ export const mimeTypes = {
/** return an extension (including a leading `.`) for a mime-type */
toExtension,
assetType: (filename: string) => {
// Check file extension first to handle cases like MXF (application/mxf) that are video containers
if (isType(filename, video)) {
return AssetType.Video;
}
if (isType(filename, image)) {
return AssetType.Image;
}
// Fallback to mime type check for any edge cases
const contentType = lookup(filename);
if (contentType.startsWith('image/')) {
return AssetType.Image;