immich-app / immich

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

FFMPEG errors due to invalid video file location (primarily with iOS live photos) #9198

Open raisinbear opened 4 months ago

raisinbear commented 4 months ago

The bug

Hi,

after #8410 has been closed as likely being caused corrupt videos, I thought I'd open a new issue about that. Pretty much every time, I upload a live photo (iOS), I see the error signature posted below.

The only times I get away without this showing up is when uploading larger bulks and the server is occupied with handling face detection for other assets and transcoding other videos. I have all job concurrency set to 1, but to me that still has the flavor of a race condition as it looks like the video files were already moved from the upload/ (temporary) location to the library/ folder. Also the filename seems a bit weird with the duplicate .mov!?

Anyways, seeing this gives me a bad feeling, however, I cannot detect a consequence of the failure. The motion part is - in the cases I checkedd - successfully encoded at some point after the error.

Thanks once more for the great work!

The OS that Immich Server is running on

Raspbian

Version of Immich Server

v1.103.1

Version of Immich Mobile App

v1.103.0

Platform with the issue

Your docker-compose.yml content

default

Your .env content

default

Reproduction steps

1. Upload (iOS) live photo
2. Observe server logs

Relevant log output

immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [MediaRepository] ffmpeg ver
sion 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
immich_microservices     |   built with gcc 12 (Debian 12.2.0-14)
immich_microservices     |   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 --enabl
e-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-l
ibdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --en
able-libzvbi --enable-libzimg --enable-libfdk-aac --arch=arm64 --cross-prefix=/usr/bin/aarch64-lin
ux-gnu- --toolchain=hardened --enable-cross-compile --enable-rkmpp --enable-rkrga
immich_microservices     |   libavutil      58.  2.100 / 58.  2.100
immich_microservices     |   libavcodec     60.  3.100 / 60.  3.100
immich_microservices     |   libavformat    60.  3.100 / 60.  3.100
immich_microservices     |   libavdevice    60.  1.100 / 60.  1.100
immich_microservices     |   libavfilter     9.  3.100 /  9.  3.100
immich_microservices     |   libswscale      7.  1.100 /  7.  1.100
immich_microservices     |   libswresample   4. 10.100 /  4. 10.100
immich_microservices     |   libpostproc    57.  1.100 / 57.  1.100
immich_microservices     | upload/library/ea8f7f01-33a1-4b8a-85d4-15ab6689bc27/2024/04/IMG_4359.MO
V.mov: No such file or directory
immich_microservices     |
immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [MediaService] Error: ffmpeg exited with code 1: upload/library/ea8f7f01-33a1-4b8a-85d4-15ab6689bc27/2024/04/IMG_4359.MOV.mov: No such file or directory
immich_microservices     |
immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [MediaRepository] ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
immich_microservices     |   built with gcc 12 (Debian 12.2.0-14)
immich_microservices     |   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=arm64 --cross-prefix=/usr/bin/aarch64-linux-gnu- --toolchain=hardened --enable-cross-compile --enable-rkmpp --enable-rkrga
immich_microservices     |   libavutil      58.  2.100 / 58.  2.100
immich_microservices     |   libavcodec     60.  3.100 / 60.  3.100
immich_microservices     |   libavformat    60.  3.100 / 60.  3.100
immich_microservices     |   libavdevice    60.  1.100 / 60.  1.100
immich_microservices     |   libavfilter     9.  3.100 /  9.  3.100
immich_microservices     |   libswscale      7.  1.100 /  7.  1.100
immich_microservices     |   libswresample   4. 10.100 /  4. 10.100
immich_microservices     |   libpostproc    57.  1.100 / 57.  1.100
immich_microservices     | upload/library/ea8f7f01-33a1-4b8a-85d4-15ab6689bc27/2024/04/IMG_4359.MOV.mov: No such file or directory
immich_microservices     |
immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [JobService] Unable to run job handler (videoConversion/video-conversion): Error: ffmpeg exited with code 1: upload/library/ea8f7f01-33a1-4b8a-85d4-15ab6689bc27/2024/04/IMG_4359.MOV.mov: No such file or directory
immich_microservices     |
immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [JobService] Error: ffmpeg exited with code 1: upload/library/ea8f7f01-33a1-4b8a-85d4-15ab6689bc27/2024/04/IMG_4359.MOV.mov: No such file or directory
immich_microservices     |
immich_microservices     |     at ChildProcess.<anonymous> (/usr/src/app/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
immich_microservices     |     at ChildProcess.emit (node:events:518:28)
immich_microservices     |     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
immich_microservices     | [Nest] 6  - 05/01/2024, 8:46:19 AM   ERROR [JobService] Object:
immich_microservices     | {
immich_microservices     |   "id": "80b33b94-4970-4245-af74-c7c672b0e694",
immich_microservices     |   "source": "upload"
immich_microservices     | }
immich_microservices     |

Additional information

May be a race condition, so reproduction steps may not work for everyone.

schmitzkr commented 3 weeks ago

Did you ever get this sorted out? I am seeing similar behaviour. I do not have any iOS devices uploading assets. I noticed that in the assets table

originalPath is like this upload/encoded-video/d912d84d-4a83-4fa0-8596-535ba5f5c8f1/8f/69/8f698edf-fa6c-4e15-ab28-60863a522d2c-MP.mp4 and that path does not exist specifically encoded-videos is no longer there originalFilename is like this 20230818_153914.mp4 in the timeline I can find the file although the motion picture does not play. And I get lots of errors logging as described in the original post.

raisinbear commented 3 weeks ago

Did you ever get this sorted out? I am seeing similar behaviour. I do not have any iOS devices uploading assets. I noticed that in the assets table

originalPath is like this upload/encoded-video/d912d84d-4a83-4fa0-8596-535ba5f5c8f1/8f/69/8f698edf-fa6c-4e15-ab28-60863a522d2c-MP.mp4 and that path does not exist specifically encoded-videos is no longer there originalFilename is like this 20230818_153914.mp4 in the timeline I can find the file although the motion picture does not play. And I get lots of errors logging as described in the original post.

Hey, to be honest I stopped checking at some point, since on the surface everything works or at least seems to. My live photos play without issue in the app and on the web from the re-encoded video stream. Also I seem to have made a wrong assumption, since the leading „upload/„ is afaik the container internal path your actual library root would be bound to. So you would need to omit the „upload/„ part when looking for the file.

schmitzkr commented 3 weeks ago

Thanks for the response. Thinking a bit harder about this, I think when I restored a backup or migrated I changed the mountpoint from /encoded-videos to /videos or something? I can find the file at another path, but the database reference is to and old path I guess. I've been running immich for quite some time now and so I could have made another change I am forgetting about. So I am happy to Ignore them since everything else seems to work. Its only motion pictures, and the image part is accessible just cant play. I think new ones work as well. It would be great if there was some way to clean these up though. Maybe that is what the 'repair' function was/is for.