Build your own Twitch using MPEG-DASH and HLS live streaming

After several requests from our customers we have enabled MPEG-DASH and HLS live streaming with bitcodin. Our live streaming seamlessly integrates with our VoD encoding concepts such as outputs and encoding profiles. This means that you can create live streams with arbitrary resolutions and bitrates for MPEG-DASH and HLS. You could then connect this livestream with an output, i.e. Google Cloud Storage (GCS) and all segments as well as the manifests will be written to that storage. Currently we only support GCS but future releases will add support for AWS S3, AzureBlob, FTP, SFTP, etc. (basically everything that is already available with our VoD encoders). You could use this output storage as origin for your CDN or for multiple CDNs. This works really well with GCS as Google offers a CDN Interconnect for several CDNs such as Fastly, Level3, HighWinds and CloudFlare.

Live streaming in the bitcodin portal

Our live streaming feature is available through our API but also through the web interface. Just select “Create new Live Stream” under Live to create a live stream for MPEG-DASH and HLS. You need to configure the live stream name, stream key, timeshift, encoding profile and output.

bitcodin mpeg-dash hls live streaming

The configuration variables have the following meaning:

  • Livestream-Name: Arbitrary name to identify your livestream
  • Stream-Key: The stream key identifies your stream in the bitcodin encoding service
  • Timeshift: Timeshift buffer in seconds that enables live DVR for your clients
  • Encoding Profile: The encoding configuration for MPEG-DASH and HLS that contains the resolutions and bitrates of your encoded stream
  • Output: An output location such as Google Cloud Storage to which all segments and the manifests are transfered

API based MPEG-DASH and HLS live streaming

Our live streaming could be fully controlled through our REST-API or through one of our API clients, for example Python. In the following we will describe a simple example with Python to setup your live stream using the Python API client:

  1. Follow the instructions on github to setup bitcodin-python.
  2. Make sure to set the correct API key:
    bitcodin.api_key = 'INSERT YOUR API KEY'
  3. Create an Google Cloud Storage Output where the MPEG-DASH and HLS files will be transferred to
            date =
            prefix = "%s%d%d%d%d%d%d" % ('livestream', date.year, date.month,, date.hour, date.minute, date.second)
            output = bitcodin.GCSOutput(
            name='Livesteam Output',
            access_key='Your GCS access key',
            secret_key='Your GCS secret key',
            bucket='Your bucket name',
            output = bitcodin.create_output(output)
  4. Create an Encoding Profile for MPEG-DASH and HLS Output
    video_configs = list()
    # 3 MBIT, 1920x1080, FULL HD
    # 1,5 MBIT, 1280x720, 720p
    # 1 MBIT, 640x480, 480p
    audio_configs = list()
    # 256 kbps
    live_profile = bitcodin.EncodingProfile('Live Stream profile', video_configs, audio_configs)
    live_profile = bitcodin.create_encoding_profile(live_profile)
  5. Set your stream key and the timeshift buffer and start your live stream
    stream_key = "stream"
    time_shift = 120
    live_stream = bitcodin.LiveStream("test live stream",
    live_stream = bitcodin.create_live_instance(live_stream)
  6. Get the RTMP input url and the MPD/M3U8 manifest urls for playback
    while live_stream.status != 'RUNNING':
        live_stream = bitcodin.get_live_instance(
        if live_stream.status == 'ERROR':
            print("Error occurred during live stream creation!")
    print("Ready to stream. RTMP URL: %s" % live_stream.rtmp_push_url)
    print("MPD URL: %snHLS URL: %snSTREAM KEY: %sn" % (live_stream.mpd_url, live_stream.hls_url, live_stream.stream_key))

RTMP Input Examples

To input a video stream into our live stream encoders you can use any client (ffmpeg, Open Broadcaster, etc.) or encoder (Elemental, Envivio, Cisco, etc.) that supports RTMP push!


Here is an example ffmpeg command that can be used to input a video stream into our live stream encoders:

ffmpeg -re -i  -c copy -f flv 

Open Broadcaster

Open Broadcaster could also be used to ingest videos into the bitcodin live streaming encoders. The important settings are under Broadcast settings. Basically you will have to select the Live Stream mode and Streaming Service is custom so that you are able to input the RTMP push url that you get from the bitcodin live streaming encoders. The stream key must be set to the value that has been provided during the live streaming setup with bitcodin.

open broadcaster stream setup mpeg-dash hls live streaming

Under encoding it is most important to set the correct audio sample rate (Format) according to the sample rate that has been set in the encoding profile. If the sample rate of the input stream and the encoding profile differ this could lead to synchronization issues of audio and video. If no sample rate is set in the encoding profile, bitcodin chooses the sample rate automatically based on the input stream.

open broadcaster encoding settings mpeg-dash hls live streaming

Another important setting is under Video. Same as for audio it is important to set the same frame rate (FPS) rate for video as set in the bitcodin encoding profile because otherwise synchronization issues of audio and video could occur. If no frame rate is set in the encoding profile, bitcodin chooses the frame rate automatically based on the input stream.

open broadcaster video settings mpeg-dash hls live streaming

Playback your MPEG-DASH and HLS live stream

Playback your video stream with an MPEG-DASH and/or HLS compatible player such as bitdash, dash.js, JWPlayer or Flowplayer. The first step is that you enable CORS on your origin, which allows streaming through HTML5 and also add a crossdomain.xml to enable Flash based streaming. If you want to know more why this is important you can take a look at our CORS and Crossdomain.xml – What you need to know blog post.

Enable CORS and crossdomain.xml on GCS

To enable MPEG-DASH streaming through HTML5 you need to enable “Cross-Origin Resource Sharing” (CORS). Just follow the google documentation. An example CORS configuration could look like the following:

    "origin": ["*"],
    "responseHeader": ["application/json"],
    "method": ["GET","HEAD"],
    "maxAgeSeconds": 3600

To enable MPEG-DASH & HLS playback in Flash, add a crossdomain.xml in the root directory of your GCS Bucket.


If you want to simply test your video stream if everything is working as expected you can use the following URLs for MPEG-DASH or HLS and test it on the dash-player website directly:

Setup your live stream playback with bitdash

Get your Free bitdash Player

To playback your content download the bitdash MPEG-DASH & HLS player at You just need to enter your email address and the domain name as configured on GCS or on your CDN, which is connected with GCS.

bitdash bitcodin mpeg-dash hls live streaming

After hitting DOWNLOAD FOR FREE you will be forwarded to the bitmovin player portal and your personal player is generated. Once the generation is finished (usually takes a few seconds), you are able to download the player files, by selecting Download self-hosted player and clicking Download Player.

bitdash bitcodin mpeg-dash hls live streaming

The downloaded .zip package contains all necessary player files. The unpacked files should be placed on Google Cloud Storage. Please make sure to place all files within the same folder.

Prepare a Sample Page

Next step is to download a pre-configured sample page (using the Download Code button), which demonstrates the player setup.

bitdash bitcodin mpeg-dash hls live streaming

To ensure, your self-hosted player files are loaded, just insert the correct URL to bitdash.min.js at line 6 of the sample page.


To configure the player with your live stream, you simply have to change the player config object (lines 2-4 within the sample page). Just replace the values for mpd, hls, and poster (not needed entries can be deleted) pointing to the location of live stream encoded with bitcodin and served through GCS or a CDN.

source: {
      dash:        '//path/to/your/dash-manifest.mpd',
      hls:         '//path/to/your/hls-manifest.m3u8',
      poster:      '//path/to/your/poster.jpg'


Last step is to upload your sample page to Google Cloud Storage with the domain you specified at the player generation.

Once you open the page, you will see your live stream playing through MPEG-DASH or HLS (based on your browser) with low startup-delay, no buffering and in the best possible quality!


If you want to create some MPEG-DASH and HLS live streams you can use our bitcodin encoding service that offers a free plan with 2.5GB encoding output per month. That’s great for testing and playing around with our live streaming feature. If you are missing something in our live streaming feature just drop us a line we are always interested in your feedback, which helps us improving our service.

DASH & HLS Live Streaming

Original URL:  

Original article

Introducing the IBM Swift Sandbox

Hi, I’m John Petitto, one of IBM’s Swift developers located at IBM’s Mobile Innovation Lab in Austin. We love Swift here and thought you would too so we are making our IBM Swift Sandbox available to developers on developerWorks.

The IBM Swift Sandbox is an interactive website that lets you write Swift code and execute it in a server environment – on top of Linux! Each sandbox runs on IBM Cloud in a Docker container. In addition, both the latest versions of Swift and its standard library are available for you to use.

IBM Swift Sandbox

We know you’re as excited as we are to start using this tool, so please bear with us during the initial launch of the sandbox. With that in mind, let’s get started!

Hello Swift!

To begin, let’s write a simple Swift program together. In the left window labeled source code, enter the following line of code:

print("Hello Swift!")

New to Swift? Check out the official language guide.

Hit the blue run button located at the top to execute the program. If everything was entered correctly, “Hello Swift!” should appear under output in the results window.

If we edit the previous example and omit the closing parenthesis at the end of the line, an error should get flagged by the editor. Hover over the red marker that appears next to the line number to examine the error message. Error messages are also listed in the output.

Screen Shot 2015-12-01 at 4.59.52 PM

Swift Meets Linux

We’ve provided a collection of sample programs for you to experiment with. Click Source Samples in the upper left corner to see the list of available sample programs. For instance, select filestat.swift and run the program. The output generated should be similar to what’s seen below:

/bin/bash is 1037464 bytes

If we try changing the value of filename on line 12 from “/bin/bash” to “/tmp”, we should see a different number of bytes printed.

You may have noticed that this program is calling stat from glibc (The GNU C Library). Since the sandbox runs on top of Linux, we can write Swift code that interacts directly with the system. Take a look at some of the other samples for more examples of using glibc.

What’s Next

With the movement of Swift to open source, we’re opening the doors on what we are working on at IBM with Swift. The IBM Swift Sandbox barely scratches the surface of what’s possible. To stay up to date with the open source efforts around Swift, head on over to Swift @ IBM.

Original URL:  

Original article

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: