Skip to main content

Client to download all files from HLS streams

Project description

This is a simple Python HTTP Live Streaming Client. It consumes a list of remote playlists, and saves all needed files to serve the playlist locally: the key, segments, and a modified m3u8 with paths normalized.

It also supports backups, i.e., if the same playlist is available on more than one server, it will track each server status and will switch to the backup if needed.

Through the config.ini it’s possible to customize where the files will be saved and what is the URL that provides servers info via JSON.

The JSON must be something like:

{
    "streams": [
        "nasa": {
            "input-path": "/msfc/Edge.m3u8",
            servers: [
                "http://liveips.nasa.gov.edgesuite.net"
            ]
        }
    ]
}

Variant Playlist Generation

hlslcient can consume multiple playlists and generate a variant playlists grouping then.

To do so, include a bandwidth for each stream and add an action to combine them in the JSON:

{
    "streams": {
        "Nasa-low": {
            "input-path": "/msfc/Edge.m3u8",
            "servers": ["http://liveips.nasa.gov.edgesuite.net"],
            "bandwidth": 254082
        },
        "Nasa-medium": {
            "input-path": "/msfc/3G.m3u8",
            "servers": ["http://liveips.nasa.gov.edgesuite.net"],
            "bandwidth": 460658
        },
        "Nasa-high": {
            "input-path": "/msfc/Wifi.m3u8",
            "servers": ["http://liveips.nasa.gov.edgesuite.net"],
            "bandwidth": 1080434
        }
    },

    "actions": [
        {
            "type": "combine",
            "input": ["Nasa-low", "Nasa-medium", "Nasa-high"],
            "output": "/msfc/nasa_mbr.m3u8"
        }
    ]
}

Transcoding

hlsclient is also able to create an audio only track from a video stream using FFMPEG.

To do so, add a transcode action an include the new stream on a combine action:

"actions": [
    {
        "type": "combine",
        "input": ["Nasa-audio-only", "Nasa-low", "Nasa-medium", "Nasa-high"],
        "output": "/msfc/nasa_mbr.m3u8"
    },
    {
        "type": "transcode",
        "input": "Nasa-low",
        "output": {
            "audio": {
                "Nasa-audio-only": {
                    "path": "Nasa-audio-only.m3u8",
                    "audio-bitrate": 64000,
                    "bitrate": 65000
                }
            }
        }
    }
]

Encryption

If you set encryption=true in the config file, hlsclient will automatically encrypt all streams with a random AES-128 cipher.

Running

To run the client, simply run:

$ python -m hlsclient

Running tests

We use py.test for testing.

$ py.test

FFmpeg Installation

In order to use the current version of hlsclient with transcoding support, you must have ffmpeg installed with libaac and libx264. Download them and compile FFfmpeg like this:

  • libaac:

    ./configure && make && sudo make install
  • libx264:

    ./configure --enable-shared && make && sudo make install
  • FFmpeg:

    ./configure --enable-libx264 --enable-gpl --enable-libfaac --enable-nonfree --enable-shared && make && sudo make install

The tested versions were:

  • libaac: faac-1.28

  • libx264: x264-snapshot-20121030-2245

  • FFmpeg: N-46213-g976175f

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hlsclient-0.4.5.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file hlsclient-0.4.5.tar.gz.

File metadata

  • Download URL: hlsclient-0.4.5.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hlsclient-0.4.5.tar.gz
Algorithm Hash digest
SHA256 d58a592234458d9e6cc3014ae323d9463641d7f20d2590d8541f7f7cea266034
MD5 7699dec0ba9a81e904123ad7c5238fd1
BLAKE2b-256 905dd093ca69a9f3039f95be095b2e2970e1aa87aeb9c3582765f8f964749c3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page