Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Streaming

No security coverage Under active development 21 sites

This module transcodes videos into adaptive bitrate streaming formats like HLS and DASH, allowing for flexible video playback. It can generate thumbnails, support multiple bitrates and resolutions, and manage subtitles.

This module is a service that transcodes a .mp4 video into an adaptive bitrate streaming format. This module supports transcoding to the two most popular formats: HLS and DASH.

Two dependencies are used for transcoding video files:

Note: this is a backend module and it does video conversion.
For the frontend player you can build it easily with the tools provided by Drupal,
or you can reuse the player provided by the streaming_media_views sub-moule.

The module has several options:

  • Repository, you can choose where to save the encoded video in a local location (public:// or private://), or on a cloud.
  • Choice of HLS or DASH streaming technique.
  • Choice of bit-rates in which each video will be fragmented (144p, 240p, 360p, 480p, 720p, 1080p, 2k or 4k).
  • Duration in seconds of each video fragment.
  • Extraction of thumbnails (.jpg and .gif) for each video segment.
  • Choice of output video format: .ts, .fmp4 or .mp4.
  • Choice of encoding: H.264 or VP9.
  • Support of subtitles (WebVTT) in different languages.

1 - Installation

1. Install FFMpeg in your system.
2. Install and enable PHP FFmpeg Drupal module.

$ composer require drupal/php_ffmpeg
$ drush en php_ffmpeg

3. correctly configure the php_ffmpeg module (/admin/config/development/php-ffmpeg).
For example if you use a common Linux distribution:

ffmpeg_library: /usr/bin/ffmpeg
ffprobe_binary: /usr/bin/ffprobe
timeout: 3600
threads: 12

4. Install PHP-FFmpeg-video-streaming library

$ composer require aminyazdanpanah/php-ffmpeg-video-streaming

5. Install and enable this module

$ composer require drupal/streaming
$ drush en streaming

2 - How to use

You can use this module in different ways and in different scenarios.

2.1 - The simplest way

  1. Install and enable this module;
  2. activate the Streaming Media Views sub-module (Media and Views modules are used to build the UI);
  3. Add new video: "Content" -> "Media" -> "Add Media" -> "Streaming Video", leave the `playlist` and` poster` fields blank, save;
  4. from "Content -> Media" you can convert your videos;
  5. choose the poster if necessary and save;
  6. use streaming/modules/streaming_media_views/templates/media--streaming-video.html.twig as an example of a player for the frontend (VideoJS 7).

2.2 - Players

If you want to customize the frontend, below is a list of compatible players.

2.2.1 - Web players

DASH and HLS

Only DASH

Only HLS

2.2.2 - Android player

ExoPlayer DASH and HLS

2.2.3 - IOS player

DASH

HLS
Player

2.2.4 - GNU/Linux Distro, MacOsX, Windows

DASH and HLS

2.3 - Customizations

If you need to create a more complex user interface or have a more complex infrastructure, you can use this module as a service.

Prepare the data to be sent as follows:

$settings = [
  'video-data' => [
    'uri'  => path|url,      // /path/v.mp4 or https://example.com/v.mp4
    'name' => string,        // movie.mp4
    'id'   => null|string    // "1" or "video-id"
    'uuid' => null|string    // uuid string
  ],
  'subtitles' => [
    'key-language' => [      // 'italian', 'english', 'spanish', 'chinese'
      'path' => string,       // /pat/to/sub/*.vtt (WebVTT format)
      'lang-name' => string,  // 'Italiano', 'English', 'Español', '中文'
      'lang-code' => string,  // 'it', 'en', 'es', 'ch'
      'default' => bool
    ],
    ...
  ],
  'custom-settings' => null|Drupal\Core\Config\Config,
  'refresh-if-exists' => null|true|false,
];

Send the data to the streaming.transcode service

$result = \Drupal::service('streaming.transcode')->video($settings);

You will receive the results in the following format:

[
  'status' => bool,
  'message' => string
  'playlist' => [
    'file_name' => string
    'path' => [
      'relative_base_path' => string
      'real_base_path' => string
      'module_folder' => string
      'video_folder' => string
      'folder_relative_path' => string
      'folder_real_path' => string
      'playlist_relative_path' => string
      'playlist_real_path' => string
    ],
    'url' => [
      'base_url' => string
      'folder_relative' => string
      'folder_real' => string
      'playlist_real_url' => string
    ],
  ],
  'thumbnails' => [
    'jpg' => [
      [ 'relative_path' => string, 'real_path' => string, 'url' => string ]
      [ ... ]
    ],
    'gif' => [
      [ 'relative_path' => string, 'real_path' => string, 'url' => string ]
      [ ... ]
    ],
  ],
  'settings' => [ ... ]
];

If you want to delete saved data, use the delete() method in the same way as video().

$result = \Drupal::service('streaming.transcode')->delete($settings);

3 - Similar module

  • Cloudflare Stream, require Cloudflare account, only HLS and Cloudflare encode video
  • Rokka, require Rokka account, only HLS and Rokka encode video and generate thumbnails.

4 - Working Example

Ask your assistant about Streaming

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Sep 2023
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.0.0-rc1 Pre-release 10 Sep 26, 2026
2.0.0-beta1 Pre-release 9–10 Jul 23, 2024
2.0.0-alpha1 Pre-release 9–10 May 25, 2024
2.x-dev Dev 10 Sep 1, 2023