Search code examples
javascriptphphtmlvideo-compression

How can I compress an uploaded video on my server?


I have to make a simple web page on which user can upload a video (max 10 MB) and the page will compress it (to 5 MB or less) and save it to the server.

I have done the front-end part of the webpage using HTML CSS and javascript.

The user should be able to add a video file and my site should compress it on the server side.

So, How can I compress the uploaded video on my server?

screenshot of my page


Solution

  • If you wants to reduce video size without loosing much quality, then you can install and use one of the following programs:

    sudo apt-get install ffmpeg
    ffmpeg -i videoS1.mp4 -r 30 -s 960x540 output-compress.mp4
    

    OR

    sudo apt-get install mencoder
    mencoder input.mp4 -vf scale=720:480 -ovc lavc -o output-compress.mp4
    

    OR

    sudo apt-get install libav-tools 
    avconv -i input.mp4 -s 640x480 output-compress.mp4
    

    Above all commands/programs can be executed using Server side programming language as it's Linux utilities. You may get libraries for various codec support.