immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
44.56k stars 2.17k forks source link

[BUG] Cannot play videos imported via read-only folder #3031

Closed Superpiffer closed 1 year ago

Superpiffer commented 1 year ago

The bug

I'm using the new read only gallery functionality, I can correctly import and view ~12.000 photos but I cannot play any video of any format (AVI, MOV or MP4). Firefox shows this:

image

immich-server shows this message in the log: [Nest] 167 - 06/29/2023, 3:42:20 PM ERROR [AssetService] Error serving VIDEO asset=b0aaf995-3165-4079-b908-c641b977b1bd

I can also find transcoded videos for unsupported formats, so I don't think that's the problem. Videos uploaded via web interface are played correctly. The main differences that I found analyzing the database is the deviceId (CLI or WEB) and the "read_only" flag. As an example these are 2 videos imported via the read-only import and 2 videos imported via browser:

                  id                  |               deviceAssetId               |               ownerId                | deviceId | type  |                         originalPath                          |                                          resizePath                                           |     fileCreatedAt      |     fileModifiedAt     | isFavorite |    mimeType     |   duration   |                                           webpPath                                            |                                          encodedVideoPath                                           |                  checksum                  | isVisible | livePhotoVideoId |           updatedAt           |           createdAt           | isArchived |    originalFileName    | sidecarPath | isReadOnly |                thumbhash                 
--------------------------------------+-------------------------------------------+--------------------------------------+----------+-------+---------------------------------------------------------------+-----------------------------------------------------------------------------------------------+------------------------+------------------------+------------+-----------------+--------------+-----------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------------------------------+-----------+------------------+-------------------------------+-------------------------------+------------+------------------------+-------------+------------+------------------------------------------

 b0aaf995-3165-4079-b908-c641b977b1bd | VID_20200313_185911.mp4-41068988          | 72b61504-0068-4e41-9119-b692c71e5909 | CLI      | VIDEO | /mnt/photos/Phones/Mi 9T Pro/VID_20200313_185911.mp4          | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/b0aaf995-3165-4079-b908-c641b977b1bd.jpeg | 2020-03-13 17:59:11+00 | 2020-03-13 17:59:11+00 | f          | video/mp4       | 00:00:17.697 | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/b0aaf995-3165-4079-b908-c641b977b1bd.webp | /photos/encoded-video/72b61504-0068-4e41-9119-b692c71e5909/b0aaf995-3165-4079-b908-c641b977b1bd.mp4 | \x1aeed96c79732d552f3fe0cf46cbff192771ae19 | t         |                  | 2023-06-29 12:51:59.709303+00 | 2023-06-29 12:39:35.094679+00 | f          | VID_20200313_185911    |             | t          | \x57080e0c029fb68aa7777868776773702a0687
 c3f67cfe-c4b0-4a1b-9cf9-2ff5f11df5ee | PXL_20230412_132903315.mp4-410731683      | 72b61504-0068-4e41-9119-b692c71e5909 | CLI      | VIDEO | /mnt/photos/Phones/Mi 9T Pro/PXL_20230412_132903315.mp4       | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/c3f67cfe-c4b0-4a1b-9cf9-2ff5f11df5ee.jpeg | 2023-04-12 11:33:33+00 | 2023-04-12 11:33:33+00 | f          | video/mp4       | 00:04:29.480 | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/c3f67cfe-c4b0-4a1b-9cf9-2ff5f11df5ee.webp | /photos/encoded-video/72b61504-0068-4e41-9119-b692c71e5909/c3f67cfe-c4b0-4a1b-9cf9-2ff5f11df5ee.mp4 | \x3037f371c16b6c34e1bb3e34f49dd46febbebc5c | t         |                  | 2023-06-29 12:56:08.092178+00 | 2023-06-29 12:39:52.769552+00 | f          | PXL_20230412_132903315 |             | t          | \x1b080a0c02afd98c4774477758a66280490699
 b388af9c-8176-4f1d-8e2a-d41c5b538357 | web-DSCN1377.AVI-1559140492000            | 72b61504-0068-4e41-9119-b692c71e5909 | WEB      | VIDEO | /photos/library/admin/2019/2019-05-29/DSCN1377.avi            | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/b388af9c-8176-4f1d-8e2a-d41c5b538357.jpeg | 2019-05-29 14:34:52+00 | 2019-05-29 14:34:52+00 | f          | video/x-msvideo | 00:00:03.033 | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/b388af9c-8176-4f1d-8e2a-d41c5b538357.webp | /photos/encoded-video/72b61504-0068-4e41-9119-b692c71e5909/b388af9c-8176-4f1d-8e2a-d41c5b538357.mp4 | \xc603d9cf4b33216340fa78b28b590c430c60adf7 | t         |                  | 2023-06-29 13:08:17.158824+00 | 2023-06-29 13:08:14.897003+00 | f          | DSCN1377               |             | f          | \xd2180e0c84566596697989907b944e9ce0f99d
 ec3695c0-3d8d-49b9-93a5-af442bdd87e8 | web-VID_20230628_130611.mp4-1687950388000 | 72b61504-0068-4e41-9119-b692c71e5909 | WEB      | VIDEO | /photos/library/admin/2023/2023-06-28/VID_20230628_130611.mp4 | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/ec3695c0-3d8d-49b9-93a5-af442bdd87e8.jpeg | 2023-06-28 11:06:26+00 | 2023-06-28 11:06:28+00 | f          | video/mp4       | 00:00:13.514 | /photos/thumbs/72b61504-0068-4e41-9119-b692c71e5909/ec3695c0-3d8d-49b9-93a5-af442bdd87e8.webp |                                                                                                     | \x13d8a3c4a49a508af2d20c4c6a1fe40eb1f83257 | t         |                  | 2023-06-29 13:21:31.284796+00 | 2023-06-29 13:21:29.481956+00 | f          | VID_20230628_130611    |             | f          | \x5f680a140c680897689668688798677f630698

Note: mp4 files uploaded via CLI has transcoded video because I tried to transcode all videos, but the error was exactly the same.

The OS that Immich Server is running on

Docker on Fedora CoreOS

Version of Immich Server

v1.64.0

Version of Immich Mobile App

v1.64.0

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - photos_volume:/mnt/photos:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    networks:
      - default
    restart: unless-stopped

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "microservices" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - photos_volume:/mnt/photos:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    networks:
      - default
    restart: unless-stopped

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - ./model-cache:/cache
    env_file:
      - .env
    networks:
      - default
    restart: unless-stopped

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
      - .env
    networks:
      - default
    restart: unless-stopped

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.1
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - ./tsdata:/data
    networks:
      - default
    restart: unless-stopped

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine
    networks:
      - default
    restart: unless-stopped

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

  immich:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    networks:
      - default
      - proxy
    depends_on:
      - immich-server
      - immich-web
    labels:
      traefik.enable: "true"
      traefik.http.services.immich.loadbalancer.server.port: 8080
    restart: unless-stopped

networks:
  proxy:
    external: true

volumes:
  photos_volume:
    name: photos_volume
    driver_opts:
      type: nfs4
      o: addr=192.168.1.30,ro
      device: :/Multimedia/Personal/Photos

Your .env content

IMMICH_VERSION=v1.64.0
TZ=Europe/Rome

UPLOAD_LOCATION=./upload

IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

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

REDIS_HOSTNAME=immich_redis

TYPESENSE_API_KEY=abcdefghijklmnopqrstuvwxyz

Reproduction steps

1. Import a folder using immich-cli with --import flag.
2. Wait for the import and click on a video.

Additional information

No response

alextran1502 commented 1 year ago

Can you play these videos on Chrome?

alextran1502 commented 1 year ago

Also, has the transcoding video job been finished yet?

Superpiffer commented 1 year ago

Same problem with Chrome and yes, the transcoding video job is finished. I also tried to remove all videos and make it transcode only unsupported again, same problemi.

Superpiffer commented 1 year ago

I forgot to mention that when hovering with the mouse on a video shows a red symbol: image

EDIT: @alextran1502 I think I found something using Chrome debugger:

{statusCode: 500,…}
error: "ServeFile"
message: "Failed to serve video asset Error: EROFS: read-only file system, access '/mnt/photos/Phones/Poco F3/VID_20221111_194749.mp4'"
statusCode: 500

For some reason I cannot use :ro for photo volume, I removed that and videos plays correctly! I left "ro" flag for my nfs mount in order to protect my files.

alextran1502 commented 1 year ago

I think this is a bug in our code to check for file permission. We can look to remove it to allow ro flag

uhthomas commented 1 year ago

Fixed by #3046

TheAnachronism commented 9 months ago

I just got the same error. Permissions should be OK, eve tested it with the permissions set to 777.