Complete bash script for generating DASH and HLS with FFMPEG, Shaka Packager and Shaka Player
First clone this repository and grant execute permissions to the file encoder-single-file-mp4.sh and packager
> git clone https://github.com/leodanisbi/streaming.git > cd streaming > chmod +x encoder-single-file-mp4.sh > chmod +x packager
- The file encoder-single-file-mp4.sh must be executed passing as parameter the name of the video found in the videos folder.
> ./encoder-single-file-mp4.sh SampleVideo_1280x720_1mb.mp4
- We need to install ffmpeg or use Static Builds from official ffmpeg page ffmpeg.
> apt install ffmpeg
-
The file encoder-single-file-mp4.sh encode the video input with ffmpeg to 6 qualities and extract all audios and subtitles stream automaticly, then with shaka-packager generate a VOD for DASH and HLS in the ouput folder.
-
In this example the shaka-packager binary is used which can be downloaded from the official repository shaka-packager-releases, below there is more information about other ways to use shaka-packager.
-
HLS and DASH outputs are located in the output folder as master.m3u8 for HLS and manifest.mpd for DASH
-
Finally we can see the output of the shaka player, we need a web server to load the output of shaka packager.
-
The latest version of shaka player is included in this repository, but it can be used from any CDN like CDN.
-
Inside the shaka-player folder edit the youtube-script.js file the variable
youtube_theme_manifestUriwith the url of the manifest.mpd or master.m3u8. -
A youtube theme was used from the repository https://github.com/lucksy/shaka-player-themes but you can use any other theme.
-
This is a simple example of shaka player, if you want to see some more advanced settings you can visit Shaka-Player-Demo-Docs.
FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.
https://github.com/FFmpeg/FFmpeg
Shaka Packager is a tool and a media packaging SDK for DASH and HLS packaging and encryption. It can prepare and package media content for online streaming.
There are several ways you can get Shaka Packager.
- Using Docker. Instructions are available here.
- Get prebuilt binaries from release.
- Built from source, see Build Instructions for details.
https://github.com/shaka-project/shaka-packager
Shaka Player is an open-source JavaScript library for adaptive media. It plays adaptive media formats (such as DASH and HLS) in a browser, without using plugins or Flash. Instead, Shaka Player uses the open web standards MediaSource Extensions and Encrypted Media Extensions.
https://github.com/shaka-project/shaka-player
Themes for Shaka player.