immich-app / immich

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

Thumbnail generation failed on very short video #10521

Closed Goodwu closed 1 month ago

Goodwu commented 1 month ago

The bug

Thumbnail cannot be generated when the video is shorter than 1s.

The OS that Immich Server is running on

OMV7

Version of Immich Server

v1.106.4

Version of Immich Mobile App

v1.106.4

Platform with the issue

Your docker-compose.yml content

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    extends:
      file: hwaccel.transcoding.yml
      service: quicksync # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
      - ${EXT_LOCATION}:/media/photos
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:d6c2911ac51b289db208767581a5d154544f2b2fe4914ea5056443f62dc6e900
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready --dbname='${DB_DATABASE_NAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT SUM(checksum_failures) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
      interval: 5m
      start_interval: 30s
      start_period: 5m
    command: ["postgres", "-c" ,"shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"]
    restart: always

volumes:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location where your database files are stored
DB_DATA_LOCATION=./postgres

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
DB_PASSWORD=postgres

EXT_LOCATION=/srv/dev-disk-by-uuid-2bf642cf-adb7-4ec8-9291-13bc77208fb0/store/WuStor_1/photo

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

Reproduction steps

1.Very short video file
2.Generate thumbnail
3.Failed
...

Relevant log output

[Nest] 7  - 06/21/2024, 12:00:19 AM   ERROR [Microservices:MediaRepository] ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
root@omv-new:/srv/dev-disk-by-uuid-2bf642cf-adb7-4ec8-9291-13bc77208fb0/immich-app/library# cat a.txt |less -r
root@omv-new:/srv/dev-disk-by-uuid-2bf642cf-adb7-4ec8-9291-13bc77208fb0/immich-app/library# vi a.txt
root@omv-new:/srv/dev-disk-by-uuid-2bf642cf-adb7-4ec8-9291-13bc77208fb0/immich-app/library# cat a.txt
[Nest] 7  - 06/21/2024, 12:00:19 AM   ERROR [Microservices:MediaRepository] ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/media/photos/Camera Uploads/DCIM/Camera/2024/05/VID_20240509_123622.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2024-05-09T04:36:22.000000Z
    location        : +40.1713+116.5744/
    location-eng    : +40.1713+116.5744/
    com.android.version: 12
    com.android.manufacturer: HUAWEI
    com.android.model: ALN-AL10
    com.android.marketing_name: HUAWEI Mate 60 Pro+
  Duration: 00:00:00.88, start: 0.000000, bitrate: 34709 kb/s
  Stream #0:0[0x1](eng): Video: hevc (Main), 1 reference frame (hvc1 / 0x31637668), yuv420p(tv, bt709, left), 3840x2160, 30716 kb/s, 59.99 fps, 60 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2024-05-09T04:36:22.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -90.00 degrees
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 196 kb/s (default)
    Metadata:
      creation_time   : 2024-05-09T04:36:22.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> webp (libwebp_anim))
Press [q] to stop, [?] for help
[Parsed_thumbnail_1 @ 0x2de9e163900] batch size: 12 frames
[Parsed_scale_5 @ 0x2de9e163c00] w:250 h:-2 flags:'lanczos+accurate_rnd+full_chroma_int' interl:0
[graph 0 input from stream 0:0 @ 0x2de9e163d80] w:3840 h:2160 pixfmt:yuv420p tb:1/90000 fr:60/1 sar:0/1
[transpose @ 0x2de9e163f00] w:3840 h:2160 dir:1 -> w:2160 h:3840 rotation:clockwise vflip:0
[Parsed_fps_0 @ 0x2de9e163840] fps=12/1
[Parsed_scale_5 @ 0x2de9e163c00] w:2160 h:3840 fmt:yuv420p sar:0/1 -> w:250 h:444 fmt:yuv420p sar:0/1 flags:0x00042200
EOF in input file 0
Terminating demuxer thread 0
[Parsed_fps_0 @ 0x2de9e163840] Set first pts to 1
Output #0, webp, to 'upload/thumbs/0ef79aea-c9d6-4f20-b7d2-bc3a01408cb6/06/2d/062dd77d-bcf5-4701-848d-efaedfde62f5-thumbnail.webp':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    com.android.marketing_name: HUAWEI Mate 60 Pro+
    location        : +40.1713+116.5744/
    location-eng    : +40.1713+116.5744/
    com.android.version: 12
    com.android.manufacturer: HUAWEI
    com.android.model: ALN-AL10
    encoder         : Lavf60.3.100
  Stream #0:0(eng): Video: webp, 1 reference frame, yuv420p, 250x444 (0x0), q=2-31, 200 kb/s, 12 fps, 1k tbn (default)
    Metadata:
      creation_time   : 2024-05-09T04:36:22.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 libwebp_anim
    Side data:
      displaymatrix: rotation of -0.00 degrees
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A
No more output streams to write to, finishing.
[libwebp encoder @ 0x2de9e1d0680] WebPAnimEncoderAssemble() failed with error: 1
[vost#0:0/libwebp_anim @ 0x2de9e158280] Error submitting video frame to the encoder
[Parsed_fps_0 @ 0x2de9e163840] 1 frames in, 0 frames out; 1 frames dropped, 0 frames duplicated.
[out#0/webp @ 0x2de9e120780] All streams finished
[out#0/webp @ 0x2de9e120780] Terminating muxer thread
[AVIOContext @ 0x2de9e1d0900] Statistics: 0 bytes written, 0 seeks, 0 writeouts
[AVIOContext @ 0x2de9e180180] Statistics: 3474680 bytes read, 3 seeks
Conversion failed!

Additional information

No response

mertalev commented 1 month ago

This should already be fixed with #10477, which will be in the next release.