MP4 TS video view runs out of memory trying to count pdf pages #1946

Closed
opened 2026-10-05 01:01:56 +02:00 by adam · 2 comments
Owner

While I'm trying to view a .ts.mp4 file generated by my phone, Piwigo errors out due to running out of memory. Judging from the stack trace, it seems like it tried to count PDF pages and ran out of memory because it tried to allocate memory for the size of the whole file. Shorter videos from the same phone work fine in Piwigo. I don't have a setup at hand to try this out with Piwigo 14.x, but I do think even large videos used to work fine.

I would expect Piwigo to be able to view videos that are larger than the largest memory allocation allowed for the PHP interpreter. My guess is that this PDF functionality is erroneously triggered for this and maybe other files too.

I'm on Piwigo 15.0.0RC1 running on custom Docker image.

image

Environment details, pardon my Finnish 😎

[Piwigo](https://piwigo.org/) 15.0.0RC1 [Tarkista päivitykset](http://redacted/admin.php?page=maintenance&action=check_upgrade&pwg_token=redacted&tab=env)
    Asennettu 4 Lokakuu 2016, 8 vuodet 1 päivä sitten
    Käyttöjärjestelmä: Linux
    PHP: 8.2.20 ([Näytä tiedot](http://redacted/admin.php?page=maintenance&action=phpinfo&pwg_token=redacted)) [2024-10-06 18:25:41]
    MySQL: 11.2.2-MariaDB-1:11.2.2+maria~ubu2204 [2024-10-06 18:25:41]
    Grafiikkakirjasto: ImageMagick ImageMagick 6.9.11-60
    Välimuistin koko 29991.25 Mo   laskettu 6 kuukausia sitten Virkistä

<!-- github-sync-id:2568813071 -->
While I'm trying to view a .ts.mp4 file generated by my phone, Piwigo errors out due to running out of memory. Judging from the stack trace, it seems like it tried to count PDF pages and ran out of memory because it tried to allocate memory for the size of the whole file. Shorter videos from the same phone work fine in Piwigo. I don't have a setup at hand to try this out with Piwigo 14.x, but I do think even large videos used to work fine. I would expect Piwigo to be able to view videos that are larger than the largest memory allocation allowed for the PHP interpreter. My guess is that this PDF functionality is erroneously triggered for this and maybe other files too. I'm on Piwigo 15.0.0RC1 running on custom Docker image. ![image](https://github.com/user-attachments/assets/9febdf5c-0517-444e-be56-adc43422665e) Environment details, pardon my Finnish :sunglasses: ``` [Piwigo](https://piwigo.org/) 15.0.0RC1 [Tarkista päivitykset](http://redacted/admin.php?page=maintenance&action=check_upgrade&pwg_token=redacted&tab=env) Asennettu 4 Lokakuu 2016, 8 vuodet 1 päivä sitten Käyttöjärjestelmä: Linux PHP: 8.2.20 ([Näytä tiedot](http://redacted/admin.php?page=maintenance&action=phpinfo&pwg_token=redacted)) [2024-10-06 18:25:41] MySQL: 11.2.2-MariaDB-1:11.2.2+maria~ubu2204 [2024-10-06 18:25:41] Grafiikkakirjasto: ImageMagick ImageMagick 6.9.11-60 Välimuistin koko 29991.25 Mo   laskettu 6 kuukausia sitten Virkistä <!-- github-sync-id:2568813071 -->
adam closed this issue 2026-10-05 01:01:57 +02:00
Author
Owner

I made an experimental fix for this in a PR, but I don't know if it follows best practices. At least it addresses the issue, but I will not be offended if you will fix it some other way.

I made an experimental fix for this in a PR, but I don't know if it follows best practices. At least it addresses the issue, but I will not be offended if you will fix it some other way. <!-- github-comment-id:2396131843 -->
Author
Owner

Ah, I think this has appeared in the implementation of #2170. I think picture.php as of now greps through the original file even though there's a cached thumbnail, trying to count PDF page tags. I think this has potential to cause performance regression even with files that are all under the maximum memory limit.

Ah, I think this has appeared in the implementation of #2170. I think picture.php as of now greps through the original file even though there's a cached thumbnail, trying to count PDF page tags. I think this has potential to cause performance regression even with files that are all under the maximum memory limit. <!-- github-comment-id:2396816763 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1946