Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot upload video with .MOV extension - wrong MIME type #1913

Closed
2 of 3 tasks
w00tlarr opened this issue Mar 1, 2023 · 13 comments · Fixed by #2213
Closed
2 of 3 tasks

[BUG] Cannot upload video with .MOV extension - wrong MIME type #1913

w00tlarr opened this issue Mar 1, 2023 · 13 comments · Fixed by #2213

Comments

@w00tlarr
Copy link

w00tlarr commented Mar 1, 2023

The bug

Uploading .MOV files will throw a 400undefined error notification. File uploaded from Windows 11 Microsoft Edge and Chrome. Although interestingly enough, if I copied the file from PC to my Android phone and uploaded it, it'll work with Android Samsung Internet browser. In logs, no matter both PC and mobile Adroid - this error is on the server logs:

[Nest] 1 - 03/01/2023, 2:03:02 PM ERROR [AssetUploadConfig] Unsupported file type .MOV file MIME type video/mov
[Nest] 1 - 03/01/2023, 2:03:11 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)
[Nest] 1 - 03/01/2023, 2:11:54 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)
[Nest] 1 - 03/01/2023, 2:11:57 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)
[Nest] 1 - 03/01/2023, 2:11:57 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)
[Nest] 1 - 03/01/2023, 2:11:57 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)
[Nest] 1 - 03/01/2023, 2:11:58 PM ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:372:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:142:30)
at ServerResponse.emit (node:events:539:35)
at Socket.onServerResponseClose (node:_http_server:236:23)
at Socket.emit (node:events:539:35)
at TCP. (node:net:709:12)

The OS that Immich Server is running on

Docker - Linux de524314c912 6.1.14-0-virt #1-Alpine SMP PREEMPT_DYNAMIC Sat, 25 Feb 2023 20:58:04 +0000 x86_64 Linux. Host is in Hyper-v: Linux docker 6.1.14-0-virt #1-Alpine SMP PREEMPT_DYNAMIC Sat, 25 Feb 2023 20:58:04 +0000 x86_64 Linux

Version of Immich Server

v1.49.0

Version of Immich Mobile App

v1.49.0

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: altran1502/immich-machine-learning:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - mobile-cache
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - database
    restart: always

  immich-web:
    container_name: immich_web
    image: altran1502/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: altran1502/immich-proxy:release
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    logging:
      driver: none
    depends_on:
      - immich-server
    restart: always

volumes:
  pgdata:
  mobile-cache:

Your .env content

###################################################################################
# Database
###################################################################################

DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich

# Optional Database settings:
# DB_PORT=5432

###################################################################################
# Redis
###################################################################################

REDIS_HOSTNAME=immich_redis

# Optional Redis settings:
# REDIS_PORT=6379
# REDIS_DBINDEX=0
# REDIS_PASSWORD=
# REDIS_SOCKET=

###################################################################################
# Upload File Config
###################################################################################

UPLOAD_LOCATION=/Users/plex/Photos

###################################################################################
# Log message level - [simple|verbose]
###################################################################################

LOG_LEVEL=simple

###################################################################################
# Reverse Geocoding
####################################################################################

# DISABLE_REVERSE_GEOCODING=false

# Reverse geocoding is done locally which has a small impact on memory usage
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
# This ranges from 0-3 with 3 being the most precise
# 3 - Cities > 500 population: ~200MB RAM
# 2 - Cities > 1000 population: ~150MB RAM
# 1 - Cities > 5000 population: ~80MB RAM
# 0 - Cities > 15000 population: ~40MB RAM

REVERSE_GEOCODING_PRECISION=3

####################################################################################
# WEB - Optional
####################################################################################

# Custom message on the login page, should be written in HTML form.
# For example PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email <i>demo@demo.de</i><br>Password: <i>demo</i>"

Reproduction steps

1. Upload a .MOV file regardless of size in Microsoft Edge or Chrome in PC
2. Got Notification - Error Cannot upload file IMG_0032.MOV  Request failed with status code 400undefined
3. Checked immich-server logs

Additional information

Unsupported file type .MOV file MIME type video/mov. This seems to have taken the file extension and place as video/>fileextension<. It should be "video/quicktime" as MIME type. File was extracted from iPhone to PC using Windows Photos.

@w00tlarr
Copy link
Author

w00tlarr commented Mar 1, 2023

Forgot to mention - if I renamed the file with a .qt extension - it works without errors. Also my *.MOV filename is all in caps if it matters.

@alextran1502 alextran1502 changed the title [BUG] <title> [BUG] Unable to upload MOV file on the web. Mar 1, 2023
@w00tlarr w00tlarr changed the title [BUG] Unable to upload MOV file on the web. [BUG] Cannot upload video with .MOV extension. Mar 1, 2023
@alextran1502
Copy link
Contributor

Is the file something you can share with us for troubleshooting?

@w00tlarr w00tlarr changed the title [BUG] Cannot upload video with .MOV extension. [BUG] Cannot upload video with .MOV extension - wrong MIME type Mar 1, 2023
@w00tlarr
Copy link
Author

w00tlarr commented Mar 1, 2023

LOL! interestingly I can't upload it to github as .MOV so I've zipped it up.
ITFZ2686.zip

It does play OK with Media Player Classic in Windows 11.

@michelheusschen
Copy link
Contributor

michelheusschen commented Mar 1, 2023

Might be something funky with MOV as container format going on, possibly in combination with the H.265 codec. When I rename this file to just .mp4 it gets uploaded via web without issues and on the server it corrects the MIME type to video/quicktime.

Edit: it doesn't correct to video/quicktime, but saves it as video/mp4. Playback is then possible because the file gets transcoded.

@jrasm91
Copy link
Contributor

jrasm91 commented Mar 1, 2023

At the end of the day you can only upload files that pass our content type check. video/mov will be denied with a bad request, while video/quicktime will be accepted. The content type is determined by the client. In chrome (for linux), uploading to the web, the file works perfectly, and chrome sends the expected mimetype of video/quicktime.

image

The question or "issue", more generally, is "why does x send video/mov instead of video/quicktime" and the answer comes down to different clients have different ways of inferring (guessing) the correct content type and it looks like not all of them are getting this one right.

Looks like there is even an exif tag for mime type and it is set to video/quicktime:

image

@samip5
Copy link
Contributor

samip5 commented Mar 1, 2023

Hmm, I wonder if there actually is some MOV's that are actually non-quicktime videos according to exiftool..
I think we should be accepting video/mov as well.

@jrasm91
Copy link
Contributor

jrasm91 commented Mar 1, 2023

Yeah, there's a few different ways to address the issue, which I did not give an opinion about, but that's what is happening and why it is happening 😄

@w00tlarr
Copy link
Author

w00tlarr commented Mar 2, 2023

LOL! I must check my ADHD on these things... Googled high and low and found this gem:
https://stackoverflow.com/questions/1201945/how-is-mime-type-of-an-uploaded-file-determined-by-browser

So - I did what it said and is indeed very OS specific. In Windows, need to update Registry at:
Computer \ HKEY_CLASSES_ROOT \ .mov

The current key I have for Content Type is video/mov. Changed it to video/quicktime and reloaded the video at my Immich web instance and it worked!

So it is very OS/client specific then. May have to consider to allow video/mov or check with exiftool during upload.

Loving Immich so far! Thanks for a great app.

@jrasm91
Copy link
Contributor

jrasm91 commented Mar 2, 2023

I think accepting video/mov would be an acceptable solution.

@w00tlarr
Copy link
Author

w00tlarr commented Mar 11, 2023

Ouch - I ran into the same for .AVI files which is video/avi instead of video/x-msvideo.
Any advice for Windows if need to install apps or codecs that will update the registry to its proper mimetype?

I guess I have to go thru the registry to set it up manually then. At least on the videos and images that I care to upload to Immich.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

@jrasm91
Copy link
Contributor

jrasm91 commented Mar 27, 2023

We can probably add support this this one as well. Can you open a separate issue to track it?

@samip5
Copy link
Contributor

samip5 commented Apr 8, 2023

Support for MOV should be implemented as of #2045, eg included in Immich version 1.52.0.

@Monarsoft
Copy link

Unable to upload recorded video format to MP4, this cup of Android 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants