3

I have included video upload feature in my javascript project. Selecting the video from local storage in the project is uploading, but I want the size of the video file to be compressed and uploaded. My main focus is to upload recorded video from camera and mobile phone which is of very large size. I have used HTML 5 to select the video file.

<input type= "file" id="fileselect" name="uploadvideo" accept=".mp4, .mov, .webm"/>

The size of the video file should be compressed before it is uploaded.

MANISH SHARMA
  • 33
  • 1
  • 8
  • 2
    **(1)** To compress file bytes look at `bz2` or even `xz` compression via Javascript. Test via some program that uses either method on your "large" file. If you like the reduced size then use same compression method in your JS code ... **(2)** Another way is to re-encode the video data itself with different settings (_eg:_ a smaller resolution, less fps, etc) for a new smaller video file to upload. This means your user has to wait for converting to complete (and it could be after few minutes) depending on input video. To re-encode you need to find a JS based mp4/webm/mov encoder. – VC.One Jan 27 '22 at 02:39

1 Answers1

6

An mp4 file is a container which will have video and audio tracks in it - these tracks will typically already be compressed by the encoder depending on which codec is used, h.264 for example.

If you want to further compress or re-encode the video it is possible, for example using a browser based ffmpeg solution, but even though these solutions may leverage the latest web assembly language technology this will not be quick and may not give you either the compression or quality you are looking for.

You can see some example here to experiment with: https://github.com/ffmpegwasm/ffmpeg.wasm

Mick
  • 24,231
  • 1
  • 54
  • 120
  • Thank you for suggest me. The size of mp4 video is compressed but I want to compress the recorded video from mobile and camera before uploading which is very large in size. – MANISH SHARMA Jan 25 '22 at 06:11
  • 1
    If ffmpeg is used in javascript then tell me the solution how to use it. I don't have much knowledge of Javascript. – MANISH SHARMA Jan 25 '22 at 06:19