Cannot read or download a large file / possibly due to memory limit #2083

Open
opened 2026-10-05 01:05:51 +02:00 by adam · 3 comments
Owner

Expectation

Hi. I am using the piwigo-videojs plugin + a few confs to enable video files.

Problem

Sometimes, Piwigo cannot read large file sized videos. Indeed, I uploaded a video file of 74 MB that works, and another one of 240 MB that fails to read and download.

Analysis

My understanding of the problem is that the content is not streamed little by little, but loaded entirely into the server memory before being sent to the browser. And when the limit is reached, the PHP process crashes, and we get a NS_ERROR_NET_PARTIAL_TRANSFER error in Firefox (same failure in Vivaldi) meaning the transfer was incomplete (the header fields content-type and content-length are both correct, they match the complete file specificities).

The URL used for the download button and the <video> tag generated by piwigo-videojs is this one: https://domain/action.php?id=2854&part=e&download so it uses the action.php API to handle the download. (When accessing the file with the /upload/year/month/day/file-hash.mp4 path, the browser reads the video file.)

The right way to handle this issue could be to implement a streamable API.

Available workarounds

  • Compress the media you want to serve to remain under the memory limit when loaded into memory.

    If it's a video file, using Handbrake does the job.

  • Raise the memory limit of the server.
## Expectation Hi. I am using the piwigo-videojs plugin + a few confs to enable video files. ## Problem Sometimes, Piwigo cannot read large file sized videos. Indeed, I uploaded a video file of 74 MB that works, and another one of 240 MB that fails to read and download. ## Analysis My understanding of the problem is that the content is not streamed little by little, but loaded entirely into the server memory before being sent to the browser. And when the limit is reached, the PHP process crashes, and we get a NS_ERROR_NET_PARTIAL_TRANSFER error in Firefox (same failure in Vivaldi) meaning the transfer was incomplete (the header fields content-type and content-length are both correct, they match the complete file specificities). The URL used for the download button and the `<video>` tag generated by piwigo-videojs is this one: `https://domain/action.php?id=2854&part=e&download` so it uses the **action.php** API to handle the download. (When accessing the file with the `/upload/year/month/day/file-hash.mp4` path, the browser reads the video file.) The right way to handle this issue could be to implement a streamable API. ## Available workarounds - Compress the media you want to serve to remain under the memory limit when loaded into memory. > If it's a video file, using Handbrake does the job. - Raise the memory limit of the server. <!-- github-sync-id:3298254754 -->
Author
Owner

I tried to reproduce your problem on my dev environment with a 600 MB video. I had no problems and couldn't reproduce your issue.

Test with bootstrap darkroom theme but without the piwigo-videojs plugin.

  • Status: 206 Partial Content
  • Headers: Accept-Ranges: bytes, Content-Range: bytes 0-.../total, Content-Type: video/mp4
  • I also see the browser requesting further byte ranges as I scrub through the video.

Same test with piwigo-videojs

  • Status: 200 OK
  • Headers: Content-Length: 606274571, Content-Disposition: attachment; filename="..."
  • No Accept-Ranges / Content-Range header
  • The video still plays fine in my browser (progressive download works), even though the server isn’t explicitly advertising byte ranges.
I tried to reproduce your problem on my dev environment with a 600 MB video. I had no problems and couldn't reproduce your issue. Test with bootstrap darkroom theme but without the piwigo-videojs plugin. - Status: `206 Partial Content` - Headers: `Accept-Ranges: bytes, Content-Range: bytes 0-.../total, Content-Type: video/mp4` - I also see the browser requesting further byte ranges as I scrub through the video. Same test with piwigo-videojs - Status: `200 OK` - Headers: `Content-Length: 606274571, Content-Disposition: attachment; filename="..."` - No `Accept-Ranges` / `Content-Range` header - The video still plays fine in my browser (progressive download works), even though the server isn’t explicitly advertising byte ranges. <!-- github-comment-id:3236453617 -->
Author
Owner

After some testing with plg, we discovered that the problem was caused by piwigo-videojs. This is because the plugin uses https://domain/action.php?id=2854&part=e&download instead of the path in the video as in bootstrap darkroom. @EddyLB

After some testing with plg, we discovered that the problem was caused by piwigo-videojs. This is because the plugin uses `https://domain/action.php?id=2854&part=e&download` instead of the path in the video as in bootstrap darkroom. @EddyLB <!-- github-comment-id:3237624558 -->
Author
Owner

To my understanding, the problem is not caused by the plugin but by the browser.
See https://github.com/Piwigo/piwigo-videojs/issues/253#issuecomment-3267698499.

To my understanding, the problem is not caused by the plugin but by the browser. See https://github.com/Piwigo/piwigo-videojs/issues/253#issuecomment-3267698499. <!-- github-comment-id:3267708239 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2083