Uploading .mp4 file using the PIWIGO API fails (on pwg.images.add) #656

Closed
opened 2026-10-05 00:09:28 +02:00 by adam · 8 comments
Owner

Hi,
I've got the videoJS plugin installed to allow upload of video files using the standard PIWIGO web page, but when I try and upload the files using the PIWIGO API, the files are not accepted. The error coming back from the server is (summarised a bit) below:

Warning chmod() no such file or directory in /var/www/piwigo/include/ws_functions/pwg.images.php on line 1077.
Warning getimagesize(./upload/buffer/ac-original): failed to open stream: no such file or directory in /var/www/piwigo/admin/include/functions_upload.inc.php on line 226 unexpected file type.

Presumably, the PIWIGO api totally circumvents the plugin architecture as I noticed a different plugin I have installed that allows summarised and long descriptions for categories is not getting a chance to intercept calls to retrieve category details.

Hi, I've got the videoJS plugin installed to allow upload of video files using the standard PIWIGO web page, but when I try and upload the files using the PIWIGO API, the files are not accepted. The error coming back from the server is (summarised a bit) below: Warning chmod() no such file or directory in /var/www/piwigo/include/ws_functions/pwg.images.php on line 1077. Warning getimagesize(./upload/buffer/<boring hex string>ac-original): failed to open stream: no such file or directory in /var/www/piwigo/admin/include/functions_upload.inc.php on line 226 unexpected file type. Presumably, the PIWIGO api totally circumvents the plugin architecture as I noticed a different plugin I have installed that allows summarised and long descriptions for categories is not getting a chance to intercept calls to retrieve category details. <!-- github-sync-id:236303065 -->
adam closed this issue 2026-10-05 00:09:28 +02:00
Author
Owner

Exact. The poster is not generated and getimagesize() fails.

Exact. The poster is not generated and getimagesize() fails. <!-- github-comment-id:327031330 -->
Author
Owner

@EddyLB what do you think of that issue? Plugin side or Piwigo side?

@EddyLB what do you think of that issue? Plugin side or Piwigo side? <!-- github-comment-id:327032150 -->
Author
Owner

With the web GUI, uploading a MP4 video is possible but the poster is not generated properly. One gets an empty image file and getimagesize() fails. This problem is reported in the issues https://github.com/xbgmsharp/piwigo-videojs/issues/103 and https://github.com/xbgmsharp/piwigo-videojs/issues/108.

To my understanding, VideoJS expects a poster of the video to complete its job and that can be fixed with pull request #756. The new FFmpeg command assumes no specific input codec and should therefore be effective in most cases. The fix works well on my Piwigo server and a video icon appears automatically on posters of videos in the web gallery.

If some users still encounter problems when uploading .mp4 videos using the Web API and the proposed fix #756, that will be due to an issue different from the one reported here by @extorn.

With the web GUI, uploading a MP4 video is possible but the poster is not generated properly. One gets an empty image file and getimagesize() fails. This problem is reported in the issues https://github.com/xbgmsharp/piwigo-videojs/issues/103 and https://github.com/xbgmsharp/piwigo-videojs/issues/108. To my understanding, [VideoJS expects a poster of the video](https://github.com/xbgmsharp/piwigo-videojs/wiki/How-to-add-videos#requirement) to complete its job and that can be fixed with pull request #756. The new FFmpeg command assumes no specific input codec and should therefore be effective in most cases. The fix works well on my Piwigo server and a video icon appears automatically on posters of videos in the web gallery. If some users still encounter problems when uploading .mp4 videos using the Web API and the proposed fix #756, that will be due to an issue different from the one reported here by @extorn. <!-- github-comment-id:327117725 -->
Author
Owner

Hi EddyLB. Thanks for looking into this. I've applied your fix to my PIWIGO server but am still getting the identical problem.
To be clear, I perform the following steps:
1.
Upload the video file in chunks using API call pwg.images.addChunk multiple times.
2.
Attempt to re-form the video file on the server using the API call pwg.images.add

The response I get back is an error on the call to pwg.images.add as you described:
chmod() no such file or directory in ...../ws_functions/pwg.images.php on line 1077
getimagesize(./upload/buffer/-original): failed to open stream: No such file or directory in ......./admin/include/function_upload.inc.php on line 226. unexpected file type.

ffmpeg is available at /usr/bin/ffmpeg.

Uploading videos using the web user interface work fine and always have, just not using the restful web API.

I'm happy to look into this more with your assistance, but PHP isn't a strong point of mine. I could upload my debug log file extracted from the server, but I don't think it will help any further.

Hi EddyLB. Thanks for looking into this. I've applied your fix to my PIWIGO server but am still getting the identical problem. To be clear, I perform the following steps: 1. Upload the video file in chunks using API call pwg.images.addChunk multiple times. 2. Attempt to re-form the video file on the server using the API call pwg.images.add The response I get back is an error on the call to pwg.images.add as you described: chmod() no such file or directory in ...../ws_functions/pwg.images.php on line 1077 getimagesize(./upload/buffer/<hex number here>-original): failed to open stream: No such file or directory in ......./admin/include/function_upload.inc.php on line 226. unexpected file type. ffmpeg is available at /usr/bin/ffmpeg. Uploading videos using the web user interface work fine and always have, just not using the restful web API. I'm happy to look into this more with your assistance, but PHP isn't a strong point of mine. I could upload my debug log file extracted from the server, but I don't think it will help any further. <!-- github-comment-id:332838280 -->
Author
Owner

Hi @extorn,

Hum, that will be difficult for me to help you because I do not use pwg.images.add. If you look at the code of the iOS app, you will see that it uses the pwg.images.upload API method followed by pwg.images.setInfo to set the video properties. The upload is managed from this code.

Have you checked the nature of the uploaded file? Have you tried to apply manually the FFmpeg command I've proposed, i.e. ffmpeg -ss 00:00:00 -i video.mp4 -frames:v 1 image.jpg ?

Hi @extorn, Hum, that will be difficult for me to help you because I do not use `pwg.images.add`. If you look at the [code](https://github.com/Piwigo/Piwigo-Mobile/blob/master/piwigo/Upload/Image%20Uploading/UploadService.m) of the [iOS app](https://github.com/Piwigo/Piwigo-Mobile), you will see that it uses the `pwg.images.upload` API method followed by `pwg.images.setInfo` to set the video properties. The upload is managed from this [code](https://github.com/Piwigo/Piwigo-Mobile/blob/master/piwigo/Upload/Image%20Uploading/ImageUploadManager.m). Have you checked the nature of the uploaded file? Have you tried to apply manually the FFmpeg command I've proposed, i.e. `ffmpeg -ss 00:00:00 -i video.mp4 -frames:v 1 image.jpg` ? <!-- github-comment-id:332950304 -->
Author
Owner

I applied the fix #756 change to my Piwigo server if that's what you mean.
I've not tried manually running the ffmpeg command you suggest. I'm not clear what you mean by this step, and the file I have tried uploading via the piwigo.images.add method has been uploaded in the past using the html website interface.

I'll take a look at this again when I get a moment. As it stands, I appreciate that while fix #756 may have solved the issue for your use of pwg.images.upload, it does not affect the use of pwg.images.add following upload of a file using pwg.images.addChunk. It's possible that I've not applied the fix correctly I guess, but I'm pretty confident this isn't the case.

I applied the fix #756 change to my Piwigo server if that's what you mean. I've not tried manually running the ffmpeg command you suggest. I'm not clear what you mean by this step, and the file I have tried uploading via the piwigo.images.add method has been uploaded in the past using the html website interface. I'll take a look at this again when I get a moment. As it stands, I appreciate that while fix #756 may have solved the issue for your use of pwg.images.upload, it does not affect the use of pwg.images.add following upload of a file using pwg.images.addChunk. It's possible that I've not applied the fix correctly I guess, but I'm pretty confident this isn't the case. <!-- github-comment-id:333928475 -->
Author
Owner

Hi @extorn ,
When uploading a file with pwg.images.add, the temporary (incomplete) file is stored in ./upload/buffer (this is what happens with pwg.images.upload). It is then renamed and moved to the ./upload/<year>/<month>/<day> folder. Then, for a video, a pwg_representative folder is created in the same folder and the FFmpeg command produces the poster .

I suspect that you encounter an issue during/after the upload. Can you use a telnet/ssh session to check that the file is uploaded to ./upload/buffer during the upload? Then check that it is renamed and moved to ./upload/<year>/<month>/<day>.

Hi @extorn , When uploading a file with `pwg.images.add`, the temporary (incomplete) file is stored in `./upload/buffer` (this is what happens with `pwg.images.upload`). It is then renamed and moved to the `./upload/<year>/<month>/<day>` folder. Then, for a video, a `pwg_representative` folder is created in the same folder and the FFmpeg command produces the poster . I suspect that you encounter an issue during/after the upload. Can you use a telnet/ssh session to check that the file is uploaded to `./upload/buffer` during the upload? Then check that it is renamed and moved to `./upload/<year>/<month>/<day>`. <!-- github-comment-id:334840080 -->
Author
Owner

I think this issue can be considered resolved now. I can't recall for certain the reason for the error but I'm fairly sure it was because the file extension was not on the name of the upload. - i.e. MyVideo.mp4 was being uploaded as a file named MyVideo. This meant Piwigo was unable to determine file type since it uses the extension to do so.

I think this issue can be considered resolved now. I can't recall for certain the reason for the error but I'm fairly sure it was because the file extension was not on the name of the upload. - i.e. MyVideo.mp4 was being uploaded as a file named MyVideo. This meant Piwigo was unable to determine file type since it uses the extension to do so. <!-- github-comment-id:344678938 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#656