Code Monkey home page Code Monkey logo

hlsdl's Introduction

HLS downloader

This is a library to support downloading a m3u8 file. All TS segments will be downloaded into a folder and then joined into a single TS file. The default file name is video.ts

Features:

  • Concurrent download segments with multiple http connections
  • Decrypt HLS-encoded segments
  • Auto-retry download
  • Display downloading progress bar
  • Record a live stream video

Todo:

  • Allow adding http headers

How to integrate this library into your code

Get the library

go get github.com/canhlinh/hlsdl

then import it to your code.

import "github.com/canhlinh/hlsdl"

Sample:

package main

import (
	"fmt"

	"github.com/canhlinh/hlsdl"
)

func main() {
	hlsDL := hlsdl.New("https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit.m3u8", nil, "download", 64, true, "")
	
	filepath, err := hlsDL.Download()
	if err != nil {
		panic(err)
	}

	fmt.Println(filepath)
}

How to build a console application

Build for linux

make build-linux

Build for windows

make build-windows

Run the application

./bin/hlsdl --help
./bin/hlsdl -u https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit.m3u8 -d download -w 10

example

Record a live stream video

./bin/hlsdl --url "http://cdn1.live-tv.od.ua:8081/bbb/bbbtv-abr/bbb/bbbtv-720p/chunks.m3u8?nimblesessionid=62115268" --record true

hlsdl's People

Contributors

canhlinh avatar cristiancll avatar ernesto27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hlsdl's Issues

Error: Get data:text/plain;base64,xxxxxxxxxx=: unsupported protocol scheme "data"

All the segments seemed to download successfully but got an error during merging.

Downloading... 2m35s 269 / 269 100.00% 2m35s
Joining segments
Error: Get data:text/plain;base64,xxxxxxxxxx=: unsupported protocol scheme "data"

The xxxxxxxxxx is a long string of alphanumeric characters. I'm not sure if it contains sensitive information so I redacted it for now.
Hoping someone can help. Thank you!

Default value for IV should be Media Sequence Number

In section 5.2 of RFC8216, it states that

An EXT-X-KEY tag with a KEYFORMAT of "identity" that does not have an
IV attribute indicates that the Media Sequence Number is to be used
as the IV when decrypting a Media Segment, by putting its big-endian
binary representation into a 16-octet (128-bit) buffer and padding
(on the left) with zeros.

However, in decrypt.go,
the IV is simply set to the key, instead of the Media Sequence Number of the segment.

Not able to specify raw AES key value (hexstring) while downloading

I want to download a video file having m3u8 file content

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="k-valstr/t-stamp",IV=0x999zxx1c6914999p408c65cead91ff92
#EXTINF:2.400000,
hls_350k_000.ts
#EXTINF:2.400000,
hls_350k_001.ts
#EXTINF:1.200000,
hls_350k_002.ts
#EXTINF:2.400000,
hls_350k_003.ts
#EXTINF:2.400000,
hls_350k_004.ts
#EXTINF:1.200000,
hls_350k_005.ts
#EXTINF:2.400000,
hls_350k_006.ts
#EXTINF:2.400000,
hls_350k_007.ts
#EXTINF:1.200000,
hls_350k_008.ts
#EXTINF:2.400000,
hls_350k_009.ts
#EXTINF:2.400000,
hls_350k_010.ts
#EXTINF:1.200000,
hls_350k_011.ts
#EXTINF:2.400000,
hls_350k_012.ts
#EXTINF:2.400000,
hls_350k_013.ts
#EXTINF:1.200000,
hls_350k_014.ts
#EXTINF:2.400000,
hls_350k_015.ts
#EXTINF:2.400000,
hls_350k_016.ts
#EXTINF:1.200000,
hls_350k_017.ts
#EXTINF:2.400000,
hls_350k_018.ts
#EXTINF:2.400000,
hls_350k_019.ts
#EXTINF:1.200000,
hls_350k_020.ts
#EXTINF:2.400000,
hls_350k_021.ts
#EXTINF:2.400000,
hls_350k_022.ts
#EXTINF:1.200000,
hls_350k_023.ts
#EXTINF:2.400000,
hls_350k_024.ts
#EXTINF:2.400000,
hls_350k_025.ts
#EXTINF:1.200000,
hls_350k_026.ts
#EXTINF:2.400000,
hls_350k_027.ts
#EXTINF:2.400000,
hls_350k_028.ts
#EXTINF:1.200000,
hls_350k_029.ts
#EXTINF:2.400000,
hls_350k_030.ts
#EXTINF:2.400000,
hls_350k_031.ts
#EXTINF:1.200000,
hls_350k_032.ts
#EXTINF:2.400000,
hls_350k_033.ts
#EXTINF:2.400000,
hls_350k_034.ts
#EXTINF:1.200000,
hls_350k_035.ts
#EXTINF:2.400000,
hls_350k_036.ts
#EXTINF:2.400000,
hls_350k_037.ts
#EXTINF:1.200000,
hls_350k_038.ts
#EXTINF:2.400000,
hls_350k_039.ts
#EXTINF:2.400000,
hls_350k_040.ts
#EXTINF:1.200000,
hls_350k_041.ts
#EXTINF:2.400000,
hls_350k_042.ts
#EXTINF:2.400000,
hls_350k_043.ts
#EXTINF:1.200000,
hls_350k_044.ts
#EXTINF:2.400000,
hls_350k_045.ts
#EXTINF:2.400000,
hls_350k_046.ts
#EXTINF:1.200000,
hls_350k_047.ts
#EXTINF:2.400000,
hls_350k_048.ts
#EXTINF:2.400000,
hls_350k_049.ts
#EXTINF:1.200000,
hls_350k_050.ts
#EXTINF:2.400000,
hls_350k_051.ts
#EXTINF:2.400000,
hls_350k_052.ts
#EXTINF:1.200000,
hls_350k_053.ts
#EXTINF:2.400000,
hls_350k_054.ts
#EXTINF:2.400000,
hls_350k_055.ts
#EXTINF:1.200000,
hls_350k_056.ts
#EXTINF:2.400000,
hls_350k_057.ts
#EXTINF:2.400000,
hls_350k_058.ts
#EXTINF:1.200000,
hls_350k_059.ts
#EXTINF:2.400000,
hls_350k_060.ts
#EXTINF:2.400000,
hls_350k_061.ts
#EXTINF:1.200000,
hls_350k_062.ts
#EXTINF:2.400000,
hls_350k_063.ts
#EXTINF:2.400000,
hls_350k_064.ts
#EXTINF:1.200000,
hls_350k_065.ts
#EXTINF:2.400000,
hls_350k_066.ts
#EXTINF:2.400000,
hls_350k_067.ts
#EXTINF:1.200000,
hls_350k_068.ts
#EXTINF:2.400000,
hls_350k_069.ts
#EXTINF:2.400000,
hls_350k_070.ts
#EXTINF:1.200000,
hls_350k_071.ts
#EXTINF:2.400000,
hls_350k_072.ts
#EXTINF:2.400000,
hls_350k_073.ts
#EXTINF:1.200000,
hls_350k_074.ts
#EXTINF:2.400000,
hls_350k_075.ts
#EXTINF:2.400000,
hls_350k_076.ts
#EXTINF:1.200000,
hls_350k_077.ts
#EXTINF:2.400000,
hls_350k_078.ts
#EXTINF:2.400000,
hls_350k_079.ts
#EXTINF:1.200000,
hls_350k_080.ts
#EXTINF:2.400000,
hls_350k_081.ts
#EXTINF:1.600000,
hls_350k_082.ts
#EXT-X-ENDLIST

Here AES Decryption key is hidden in the site code so I want to pass that decryption key explicitly so is it possible to do that.

Please I would request you if it is not possible than can you please provide me reference of other tools that provide this functionality. Thanks a lot for the help @canhlinh

get progress

any way to get the progress as the video is downloading?
For instance i want to show a progressbar/spinner...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.