spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.73k stars 1.07k forks source link

Not creating thumbnails #1180

Closed mokhosh closed 6 years ago

mokhosh commented 6 years ago

My project was working fine on the ubuntu device that I was using before. I just moved to a windows device and everything was working fine except uploading videos with medialibrary.

First it didn't find ffmpeg and that was easy, I just published and changed the ffmpeg.binaries config.

But now when I try to upload a video I get this error:

"copy(D:\dev\storage\medialibrary/temp\O2p5uv13ju1HAMUt2Ac2Vrcm2uIrZDKE/1ilQVo9RVkbhWqRx.jpg): failed to open stream: No such file or directory"

1ilQVo9RVkbhWqRx.jpg is the thumbnail file that is expected to be created but it's not, and I don't get any errors before laravel tries to copy it so I can figure out what the problem is.

brendt commented 6 years ago

That will be a difficult issue to debug for us. My recommendation is that you debug on a local project.

First make sure you can reliably reproduce the issue; than start debugging here: https://github.com/spatie/laravel-medialibrary/blob/master/src/ImageGenerators/FileTypes/Video.php#L26

We're using the PHP-FFMpeg package to generate video thumbnails which is not included by default. You should make sure the correct dependencies are installed on your new system. You can read more about it here: https://docs.spatie.be/laravel-medialibrary/v7/converting-other-file-types/using-image-generators#video

I'm closing this issue, as I don't consider it an issue of the medialibrary. But feel free to ask more questions here if needed. Good luck.

mokhosh commented 6 years ago

Thank you for your detailed response. This is what I wrote to test the class you mentioned:

Route::get('test', function() {
    $video = new \Spatie\MediaLibrary\ImageGenerators\FileTypes\Video();
    echo $video->convert('intro.mp4');
});

I put the intro.mp4 video file in my public folder and the thumbnail was created next to the video. Where else do you think I can find the problem?

brendt commented 6 years ago

Hi @mokhosh

I'd start from where the error occurs: the system is unable to copy a temporary file: D:\dev\storage\medialibrary/temp\O2p5uv13ju1HAMUt2Ac2Vrcm2uIrZDKE/1ilQVo9RVkbhWqRx.jpg

It looks like the path uses both forward and backward slashes. I'd add a str_replace("\/", "\\", $path) right before that file is saved (the stack trace should show you where it happens). This code will be in the vendor folder, but obviously it's for debugging only.

mokhosh commented 6 years ago

That's what I expected is what causes the problem at first, but I went to the directory and there is no thumbnail. I tried what you suggested anyway:

$copiedOriginalFile = str_replace("\\", "/", $copiedOriginalFile);

The slashes change but the problem is the same:

copy(D:/dev/storage/medialibrary/temp/Hc8nhzZkT3hCZs7G7qk2KrWpCVEIGGGP/7jR2IISPSXiKM437.jpg):
 failed to open stream: No such file or directory