API
The Gcore Customer Portal is being updated. Screenshots may not show the current version.
Video Streaming
Video Streaming
Chosen image
Home/Video Streaming/Video Hosting/HLS and MP4

HLS and MP4

What is the HLS format for streaming?

The HLS format is the most common format for delivering videos online. This format allows you to:

  • Use adaptive bitrate. This provides viewers with video content at a quality level determined by the speed of their internet connection.
  • Slice into chunks. Video content is chunked into 2–3 second segments and cached for fast delivery worldwide using CDNs.
  • Reduce the cost. You don’t pay for the complete duration of the video, only the part that the user watched.

Video content delivered in HLS format contains a manifest (.m3u8) which tells browsers the order in which they should play the chunks into which the video is divided.

Here is the format of the link to get the master manifest:

https://domain.com/videos/{client_id}_{video_id}/master[-min-N][-max-N][-img].m3u8

Where:

  • {client_id}: your account ID
  • {video_id}: identifier of the video
  • -min-N: special suffix that specifies the lower available video quality limit
  • -max-N: special suffix that specifies the upper available video quality limit
  • -img: special suffix, information about preview files is added to the manifest when specified. Read more in the article Timeline hover previews: use with players and Roku devices

Example of the manifest link: https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/master.m3u8

What is the MP4 format used for?

Video can be streamed and downloaded using the .mp4 file format when you want to handle the whole file at once instead of in chunks. So MP4 format allows users to:

  • Watch videos offline on mobile devices
  • Download video files for local modification
  • Play videos even on very outdated devices
  • Share videos on social networks and other streaming services

When using the MP4 format, users can work with each available video resolution separately. For example, select the video quality version (720p) and download only that version: https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/720.mp4

Example usage:

<video width="100%" height="auto" autoplay="autoplay" loop="true" playsinline="" oncanplay="this.play()">
     <source type="video/mp4" src="https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/720.mp4"/>
</video>

Gcore supports regular download requests for entire MP4 file downloads. We also support range requests specifying the HTTP "Range" header.

curl -v 'https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/720.mp4' -H 'range: bytes=4259840-'   

> GET /videos/2675_FnlHXwA16ZMxmUr/720.mp4 HTTP/2 
> Host: demo-public.gvideo.io 
> range: bytes=4259840-   

< HTTP/2 206 < content-type: video/mp4 
< content-length: 43497712 
< content-range: bytes 4259840-47757551/47757552

Note: Video protection via the Security Tokens feature is available for MP4 files.

How to enable MP4 support

Gcore Video Streaming provides HLS by default. If you want to enable MP4 support, contact our support team.

You can get links to videos in two ways: in the Gcore Customer Portal or via the API.

Customer Portal

Select the video in the Video Hosting section, open the "Export" tab, and copy the following links.

Gcore Customer Portal

API

To get information about the video, call a method:

https://api.gcore.com/docs/streaming#tag/Videos/operation/get_api_videos_id

Example request:

GET https://api.gcore.com/streaming/videos/2474723 

Example response:

{
    "id": 2474723,
    "name": "Coffee Run - Blender Open Movie",
    ...
    "hls_url": "https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/master.m3u8",
    "iframe_url": "https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr",
    "iframe_embed_code": "<iframe width="560" height="315" src="https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr" frameborder="0" allowfullscreen></iframe>",
    "converted_videos": [
        {
            "name": "vod720n",
            "width": 1720,
            "height": 720,
            "mp4_url": "https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/720.mp4"
        },
        {
            "name": "vod480n",
            "width": 1146,
            "height": 480,
            "mp4_url": "https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/480.mp4"
        },
       ...
    ]
} 

Where:

  • iframe_url contains a web player link
  • iframe_embed_code contains web player embed code
  • hls_url contains the HLS link
  • mp4_url contains the MP4 link

Limitation of the lowest and highest quality in HLS adaptive bitrate

The manifest file (.m3u8) contains all possible video qualities by default. If you want to limit the quality for old devices, non-paying users, or a quick view, you can specify a suffix indicating the minimum and/or maximum allowed resolution:

  • -min-N: minimum resolution not less than specified
  • -max-N: maximum resolution not exceeding than specified

N is a resolution (height or width) from 240 to 9999. If the video is horizontally oriented, the resolution is its height. If it's vertically oriented, it should be width.

Here’s an example of how to get two qualities only—360 and 480—instead of the full set:

curl https://demo-public.gvideo.io/videos/2675_FnlHXwA16ZMxmUr/master-min-360-max-719-img.m3u8 

The response is:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=928000,RESOLUTION=1148x480,FRAME-RATE=24.000,CODECS="avc1.4d401f,mp4a.40.2",VIDEO-RANGE=SDR
index-svod480n-v1-a1.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=514000,RESOLUTION=860x360,FRAME-RATE=24.000,CODECS="avc1.42c01e,mp4a.40.2",VIDEO-RANGE=SDR
index-svod360n-v1-a1.m3u8

#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=71839,RESOLUTION=1148x480,CODECS="avc1.4d401f",URI="iframes-svod480n-v1-a1.m3u8",VIDEO-RANGE=SDR
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=35296,RESOLUTION=860x360,CODECS="avc1.42c01e",URI="iframes-svod360n-v1-a1.m3u8",VIDEO-RANGE=SDR

Was this article helpful?

Not a Gcore user yet?

Explore the Streaming Platform by Gcore

Go to the product page