Videos on real server - Laravel

Viewed 29

I have a website where I upload videos from 100mb to 1gb. I have a server from a hostinger with 6gb ram, cpu 4 cores, 250gb ssd and I use Laravel.

If I start the video on my localhost, everything works correctly. If on the server, When I scroll forward/backward the video on timeline, it always takes a terribly long time to load. Is it a problem to have larger videos placed directly on the server or should I look for a problem in the code (but I don't have this problem on localhost)?

There is no problem with the internet connection. I don't have much experience with this. thanks in advance for the advice

code

view

<video autoplay >
   <source src="{{ route('getVideo', $video->id)  }}" type="video/mp4">
</video>

controller

public function getVideo($videoID)
    {
        $video = Video::where('id',$videoID)->first();

        $file_path = 'uploads/' . $video->path;
        $filesize = filesize($file_path);
        header('Content-Length: ' . $filesize);
        header('Content-Type: video/mp4');
        header('Accept-Ranges: bytes');
        readfile($file_path);
      }

route

Route::get('get-video/{video}', [VideoController::class, 'getVideo'])->name('getVideo');

I'm using a simple video player that I wrote in JS

0 Answers
Related