WEBM is a video format designed for use on the web, developed and maintained by Google. It's used for live streaming, video calling, and many kinds of video you consume on the web.
WEBM files are known for their efficient compression, making them suitable for streaming video over the internet while maintaining high quality. Compared to other video formats like MP4, WEBM often results in smaller file sizes without sacrificing video quality.
In case you're wondering why you might want to convert MP4 files to WEBM, here is why:
Web compatibility: Many modern browsers support WEBM. This makes it a good choice for hosting videos on websites. WEBM video files ensure compatibility across different browsers.
Reduced file size: When you convert from other formats to WEBM, it compresses the video and reduces the file size. And the best part is it maintains a high video quality. When video files are small, it leads to faster loading times which improves user experience.
This demo is built using the Shotstack Ingest API, which is used to upload, transform, and store videos and images. One of the Ingest API's transformations includes transcoding from one format to another (e.g., from MP4 to WEBM). You can also use it for resizing, cropping, adjusting frame rates, and more.
The user interface is built with HTML, styled with Bootstrap, and uses a jQuery script to handle the interactivity. The script takes the form input which is either an upload or a URL and sends it via an AJAX call to a Node.js application.
The Node.js backend validates the request, formats the API JSON payload, and POSTs it to the Ingest API. The API then handles the conversion from MP4 to WEBM, saves the new WEBM file online, and provides the download URL.
This demo is an open-source application. You can view the source code on GitHub. And you are free to use it as a foundation to create an automated media conversion tool.
curl --request POST 'https://api.shotstack.io/v1/render' \
--header 'x-api-key: YOUR_API_KEY' \
--data-raw '{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3.amazonaws.com/footage/beach-overhead.mp4"
},
"start": 0,
"length": "auto"
}
]
}
]
},
"output": {
"format": "mp4",
"size": {
"width": 1280,
"height": 720
}
}
}'