Convert an MP4 video to MKV (Matroska) format
Download your converted MP4 to MKV file here when ready.
In this demo you can upload an MP4 video or provide the link to an MP4 video online. When the Convert Video button is clicked, the video is uploaded or fetched and the conversion process is started. After a few seconds to minutes, depending on the videos duration, the converted MKV file will be available for download.
MKV videos are not usually supported in web browsers so it will need to be downloaded and can be played back using most popular desktop and mobile video players.
The MP4 format is a widely-used digital multimedia container format, primarily for storing video and audio. It can also hold other data like subtitles and still images. Known for its broad compatibility with various devices and media players, MP4 maintains a high compression to quality ratio, allowing for small file sizes without compromising visual quality. This makes it ideal for online video playback and streaming.
MP4 files typically use separate compression methods for video and audio tracks. The video is usually encoded using the H.264 codec (AVC) or the newer x265 codec (HEVC), while audio is compressed using the AAC codec.
The Matroska (MKV) format is a versatile, open standard multimedia container that can hold an unlimited number of video, audio, picture, or subtitle tracks in one file. This format is known for its capability to store high-quality video content, including 4K and 3D videos.
MKV files are popular among enthusiasts and professionals for their ability to hold different types and unlimited quantities of multimedia streams. They support various codecs and have extensive subtitle support, making them a preferred choice for movies and TV shows.
MKV files, though not as universally compatible as MP4, are supported by a range of media players and are often used for storing high-definition content.
The Maroska container was invented in 2002 by Steve Lhomme and Lasse Kärkkäinen, and is named after the Russian word matryoshka, the famous wooden nesting dolls. Like the dolls, MKV files can contain many files within them.
Converting from MP4 to MKV may be desirable for several reasons. For example, if you need to incorporate multiple audio tracks, subtitles, or chapters within a single video file, MKV's structure allows for such complex arrangements.
Also, MKV file formats support for lossless audio and video codecs make it suitable for archival purposes or high-quality video editing ensuring no quality is lost in the transcoding process.
This demo is built on top of the Shotstack Ingest API, which enables video and image uploading, transformation, and storage to be managed using a simple to use, cloud based API.
A key transformation is the ability to transcode between formats (e.g., from MP4 to MKV), alongside resizing, cropping, frame rate adjustments, and more.
The user interface is built using an HTML form, styled with Bootstrap and a jQuery script. The script handles the uploading of files and captures the form input, the URL of the file and sends it via AJAX to a Node.js Express application. The backend validates the request, prepares the JSON payload in the correct format and POSTs it to the Ingest API, which then manages the video conversion, saves the new MKV file online, and provides a download URL.
The open-source code for this project is available on GitHub, offering a starting point for those interested in building their own media conversion tools or video editing application.
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
}
}
}'