bpatrik / pigallery2

A fast directory-first photo gallery website, with rich UI, optimized for running on low resource servers (especially on raspberry pi)
http://bpatrik.github.io/pigallery2/
MIT License
1.78k stars 204 forks source link

Docker container crashing. Log shows Error: Invalid size parameter: ?xNaN #666

Closed dima-ser closed 3 months ago

dima-ser commented 1 year ago

Running in Docker on Synology. Seems to crash every time it does indexing or some other scheduled process. Very last log entry before container crash:

/app/node_modules/fluent-ffmpeg/lib/recipes.js:150 throw new Error('Invalid size parameter: ' + config.size); ^ Error: Invalid size parameter: ?xNaN at proto.takeScreenshots.proto.thumbnail.proto.thumbnails.proto.screenshot.proto.screenshots (/app/node_modules/fluent-ffmpeg/lib/recipes.js:150:15) at /app/src/backend/model/threading/PhotoWorker.js:79:33 at handleCallback (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:106:9) at handleExit (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:223:11) at Socket. (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:248:9) at Socket.emit (node:events:525:35) at Pipe. (node:net:320:12)

Node.js v18.13.0

Used app version: 1.9.5

dima-ser commented 1 year ago

Any ideas? It appears it's coming from a dependency library fluent-ffmpeg. I was able to trace it to this line of code in that library: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/68d5c948b689b3058e52435e0bc3d4af0eee349e/lib/recipes.js#L150

Is config.size null or something?

bpatrik commented 1 year ago

I will take a look at some point.

I assume some configuration error. did you maybe change the thumbnail sizes? Also can you also try it on nightly?

Until I will have time to take a look (kinda took a break from this project for a few months) In the meantime you can disable video support that will make the app work at least for the photos

-- Sorry for being brief, sent from my phone.

On Wed, 31 May 2023, 19:50 Dima Serhiychuk, @.***> wrote:

Any ideas? It appears it's coming from a dependency library fluent-ffmpeg. I was able to trace it to this line of code in that library: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/68d5c948b689b3058e52435e0bc3d4af0eee349e/lib/recipes.js#L150

Is config.size null or something?

— Reply to this email directly, view it on GitHub https://github.com/bpatrik/pigallery2/issues/666#issuecomment-1570659759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKA5XD5MKOGFXUIXXNRPDXI6AHZANCNFSM6AAAAAAYTBIWF4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dima-ser commented 1 year ago

Thanks, how do I disable video support? I don't really need it so this would solve it for me. EDIT: never mind, found it in the settings, thank you!

I didn't change the thumbnails sizes. Not sure about nightly, I just use the "latest: tag when updating the container.

dima-ser commented 1 year ago

Hmm, so I disabled video, still crashing with the same error. It appears it's crashing on thumbnail generation:

Screenshot 2023-06-01 083326

bpatrik commented 1 year ago

Can you try resetting the database?

Maybe it still contains videos and the app tries to generate thumbnail for them

-- Sorry for being brief, sent from my phone.

On Thu, 1 Jun 2023, 17:30 Dima Serhiychuk, @.***> wrote:

Hmm, so I disabled video, still crashing with the same error. It appears it's still using fluent-ffmpeg for something?

— Reply to this email directly, view it on GitHub https://github.com/bpatrik/pigallery2/issues/666#issuecomment-1572277424, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKA5WNQAE3AKLOJSLW2KTXJCYS3ANCNFSM6AAAAAAYTBIWF4 . You are receiving this because you commented.Message ID: @.***>

dima-ser commented 1 year ago

Did a database reset, still crashing.

I do have a lot of corrupt/suspicious photos/videos that were backed up from various phones over time, so they may be to blame. With that said, I wish pigallery would handle those more gracefully instead of crashing entire Docker container, perhaps just skipping them.

And yes, I can configure Docker container to just restart automatically but then it acts slow again because it has to rebuild all indexes from scratch. So if it crashes nightly, the web app acts as though I'm using it for the first time every day and responds slowly. Once I use it for some time, it's then fast, but then it's slow again the next day after the container crash.

bpatrik commented 1 year ago

If you can send some corrupted images, I can try looking into them and fix if possible.

dima-ser commented 1 year ago

I'm not able to reproduce the issue anymore, it's been running solid for 26 days now. I did some cleanup of bad photos so maybe I removed the offending images. If I run into the issue again, I'll send the images.

On Wed, Jun 28, 2023 at 7:10 AM Patrik J. Braun @.***> wrote:

If you can send some corrupted images, I can try looking into them and fix if possible.

— Reply to this email directly, view it on GitHub https://github.com/bpatrik/pigallery2/issues/666#issuecomment-1611487917, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEFU2CK5Z7QGESBL6WRXJLXNQ3N5ANCNFSM6AAAAAAYTBIWF4 . You are receiving this because you authored the thread.Message ID: @.***>

bpatrik commented 1 year ago

Great to hear! I will close this for now.

zen-tools commented 4 months ago

Hello!

I have the same issue, and it turns out that for some mpg files, ffprobe may add an extra 'x' to the screen size.

$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 20090704140825.mpg 
720x576x

which, after file conversion, looks like this:

$ ffmpeg -i 20090704140825.mpg test.mpg
$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 test.mpg 
720x576
zen-tools commented 4 months ago

@bpatrik can you please reopen this ticket? The issue number is really fitting... :slightly_smiling_face:

bpatrik commented 3 months ago

@zen-tools Can you provide more details? From the first look I'm not sure if its the same issue. How do you run pigallery?

zen-tools commented 3 months ago

I am running pigallery in a docker container, here is the docker-compose.yml file:

version: '3'
services:
  pigallery2:
    image: bpatrik/pigallery2:2.0.0
    container_name: pigallery2
    environment:
      - NODE_ENV=production # set to 'debug' for full debug logging
      # - NODE_OPTIONS=--enable-source-maps # enable source map support on the backend for development
    volumes:
      - "./config:/app/data/config" # CHANGE ME
      - "./database:/app/data/db"
      - "/mnt/data/Photos/:/app/data/images:ro" # CHANGE ME, ':ro' means read-only
      - "./tmp:/app/data/tmp" # CHANGE ME
    ports:
      - "127.0.0.1:7000:80"
    restart: always

I just tried to repeat the issue locally with only this mpg file in the /app/data/images directory and with the NODE_ENV=debug environment variable. Here is the full stack trace:

pigallery2    | 6/28/2024, 7:34:26 PM[INFO_][JOB] Running job : Indexing
pigallery2    | 6/28/2024, 7:34:26 PM[DEBUG] POST /pgapi/admin/jobs/scheduled/Indexing/start 200 16ms
pigallery2    | 6/28/2024, 7:34:26 PM[SILLY][DiskManager] scanning directory: /
pigallery2    | 6/28/2024, 7:34:26 PM[VERBS] GET /pgapi/admin/jobs/scheduled/progress 200 3ms
pigallery2    | 6/28/2024, 7:34:26 PM[INFO_][JOB] Job finished: Indexing
pigallery2    | 6/28/2024, 7:34:26 PM[INFO_][JOB] Running job : Album Cover Filling
pigallery2    | 6/28/2024, 7:34:26 PM[DEBUG][PersonManager] Updating derived persons data
pigallery2    | 6/28/2024, 7:34:26 PM[DEBUG][AlbumManager] Updating derived album data
pigallery2    | 6/28/2024, 7:34:26 PM[INFO_][JOB] Job finished: Album Cover Filling
pigallery2    | 6/28/2024, 7:34:26 PM[INFO_][JOB] Running job : Thumbnail Generation
pigallery2    | 6/28/2024, 7:34:26 PM[SILLY][FileJob] Counting files from db
pigallery2    | 6/28/2024, 7:34:26 PM[SILLY][FileJob] Found:1
pigallery2    | 6/28/2024, 7:34:26 PM[SILLY][FileJob] Loading next batch of files from db. Skipping: 0, looking for more: 1000
pigallery2    | 6/28/2024, 7:34:26 PM[SILLY] [FFmpeg] rendering thumbnail: /app/data/images/20090704140825.mpg
pigallery2    | /app/node_modules/fluent-ffmpeg/lib/recipes.js:150
pigallery2    |         throw new Error('Invalid size parameter: ' + config.size);
pigallery2    |         ^
pigallery2    | 
pigallery2    | Error: Invalid size parameter: ?xNaN
pigallery2    |     at proto.takeScreenshots.proto.thumbnail.proto.thumbnails.proto.screenshot.proto.screenshots (/app/node_modules/fluent-ffmpeg/lib/recipes.js:150:15)
pigallery2    |     at /app/src/backend/model/threading/PhotoWorker.js:78:33
pigallery2    |     at handleCallback (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:106:9)
pigallery2    |     at handleExit (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:223:11)
pigallery2    |     at ChildProcess.<anonymous> (/app/node_modules/fluent-ffmpeg/lib/ffprobe.js:237:11)
pigallery2    |     at ChildProcess.emit (node:events:517:28)
pigallery2    |     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
pigallery2    | 
pigallery2    | Node.js v18.18.1
pigallery2 exited with code 1
bpatrik commented 3 months ago

locally what OS do you use?

Can you maybe share a broken mpg?

zen-tools commented 3 months ago

locally what OS do you use?

The host OS is Debian 12

Can you maybe share a broken mpg?

Yes, I just found another file with the same issue that I can share here - 20090704141507.mpg.zip

bpatrik commented 3 months ago

This video had some weird streams. The last commit should fix this. It will be in :edge in ~40mins.

Please close this issue if you can verify it to be working.

zen-tools commented 3 months ago

This video had some weird streams.

As far as I know, these files were converted to digital from film a long time ago. And I believe it was done with the help of PCI Analog Video Capture Card. Nowadays, kids may not remember that kind of ancient technology. :slightly_smiling_face:

Please close this issue if you can verify it to be working.

I have just checked the pigallery2:edge-alpine container, and the issue is resolved. Thank you!

But, I can't close the ticket, only comment it. So, please close it.