GithubHelp home page GithubHelp logo

selsta / hlsdl Goto Github PK

View Code? Open in Web Editor NEW
607.0 44.0 156.0 337 KB

C program to download VoD HLS (.m3u8) files

License: MIT License

C 96.80% Makefile 0.90% Roff 2.02% Dockerfile 0.27%
hls hls-stream m3u8

hlsdl's Introduction

hlsdl

This program converts .m3u8 playlists (using fragmented MPEG-2 Transport Streams) to a .ts video. It supports decryption of both AES-128 and SAMPLE-AES encryption.

Requirements

This program requires libcurl and libcrypto libraries.

Build

hlsdl build

Linux: make && make install && make clean

Windows: https://github.com/selsta/hlsdl/blob/master/msvc/BUID_WINDOWS.txt

Docker: docker build -t hlsdl:latest .

Usage and Options

./hlsdl [options] url

docker run -v ./data:/var/hlsdl/data --rm -it hlsdl:latest hlsdl [options] url

-b ... Automatically choose the best quality.

-W ... Choose largest width lower or equal than this.

-H ... Choose largest height lower or equal than this.

-A ... Select audio language.

-v ... Verbose more information.

-o ... Choose name of output file ("-" alias for stdout).

-u ... Set custom HTTP User-Agent header.

-h ... Set custom HTTP header.

-p ... Set proxy uri.

-k ... Allow to replace part of AES key uri - old.

-n ... Allow to replace part of AES key uri - new.

-f ... Force overwriting the output file.

-F ... Force ignore detection of DRM.

-K ... Force AES key value (hexstring)

-q ... Print less to the console.

-d ... Print the openssl decryption command.

-t ... Print the links to the .ts files.

-s ... Set live start offset in seconds.

-i ... Set live stream download duration in seconds.

-e ... Set refresh delay in seconds.

-r ... Set max retries at open.

-w ... Set max download segment retries.

-a ... Set additional url to the audio media playlist.

-c ... Treat HTTP code 206 as 200 even if request was made without range header.

-C ... the file name of file holding cookie data in the old Netscape / Mozilla cookie data format.

ToDo

  • support for Fragmented MPEG-4 playlist
  • support for EXT-X-MAP in the MPEG-2 Transport Streams playlist

Ideas

  • Multithreading

License

MIT License

hlsdl's People

Contributors

artemmolotov avatar ddittert avatar e2iplayer avatar edisan27 avatar ganqiuye avatar gilbsgilbs avatar mengmo avatar ngaullier avatar palmarci avatar phunkyfish avatar pzhlkj6612 avatar rabinovic avatar reino17 avatar selsta avatar sgerwk 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  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

hlsdl's Issues

AES CBC padding not removed before dumping to TS file

Hello,

Segments encrypted with AES CBC mode (AES-128) are padded before encryption.
This padding should be removed after decryption. At now padding is dumped to the output file and this couse manny errors during processing TS.

How to reproduce the problem:

  1. Download encrypted in AES-128 mode test stream: https://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8
  2. Analize downloaded output file with TS analizer for example with free DVBinspector-1.10.1

Expected result:
The should not be any parsing errors like: "Did not find sync byte, resyncing"

Current result:
There is manny parsing error because in the output file there are trash

AES128 enc segfault

hlsdl "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/m3u8s/11331.m3u8"

Help

01: ./hlsdl https://theater.kktv.com.tw/70/03000170010002_56a74815777321af3e492de24f555238/15033908132d5444cd08_hls.m3u8
1: Bandwidth: 4020000, Resolution: 1920x1080, Codecs: unknown
2: Bandwidth: 2181600, Resolution: 1280x720, Codecs: unknown
3: Bandwidth: 1371600, Resolution: 852x480, Codecs: unknown
4: Bandwidth: 805200, Resolution: 640x360, Codecs: unknown
5: Bandwidth: 559200, Resolution: 640x360, Codecs: unknown
6: Bandwidth: 374400, Resolution: 426x240, Codecs: unknown
Which Quality should be downloaded? 1

START media_playlist_get_links
END media_playlist_get_links
HLS Stream is SAMPLE-AES encrypted.
File already exists. Overwrite? (y/n) y
{"d_t":"vod"}
{"t_d":3951,"d_d":0, "d_s":0}
Downloading part 0
Error: Getting key-file [https://theater.kktv.com.tw/70/03000170010002_56a74815777321af3e492de24f555238/15033908132d5444cd08_hls/1080p_3192k.m3u8/../skd://8be594463ff19eda4a0f1fb53aa5a0a9+1196e36ba6d73c3ef1c21d2803235ae3] failed http_code[403].
{"t_d":3951,"d_d":5,"d_s":2271416}
Downloading part 1
Error: Getting key-file [https://theater.kktv.com.tw/70/03000170010002_56a74815777321af3e492de24f555238/15033908132d5444cd08_hls/1080p_3192k.m3u8/../skd://8be594463ff19eda4a0f1fb53aa5a0a9+1196e36ba6d73c3ef1c21d2803235ae3] failed http_code[403].
{"t_d":3951,"d_d":10,"d_s":4874652}
Downloading part 2

02: $ ./hlsdl http://fppmdasia.foxplay.com/FoxPlus_Asia_DP/421/983/1024791107891-1540271615794-master.m3u8
1: Bandwidth: 3282000, Resolution: 1280x960, Codecs: avc1.4D4028,mp4a.40.2
2: Bandwidth: 2490000, Resolution: 1280x960, Codecs: avc1.4D4028,mp4a.40.2
3: Bandwidth: 828000, Resolution: 640x480, Codecs: avc1.42C01E,mp4a.40.2
4: Bandwidth: 399000, Resolution: 480x360, Codecs: avc1.42C01E,mp4a.40.2
5: Bandwidth: 1716000, Resolution: 960x720, Codecs: avc1.4D401F,mp4a.40.2
Which Quality should be downloaded? 1
1: Name: Mandarin, Language: cmn
2: Name: Cantonese, Language: yue
Which Language should be downloaded? 1

START media_playlist_get_links
END media_playlist_get_links
START media_playlist_get_links
END media_playlist_get_links
HLS Stream is SAMPLE-AES encrypted.
File already exists. Overwrite? (y/n) y
{"d_t":"vod"}
{"t_d":1120,"d_d":0, "d_s":0}
Downloading part 0
Error: Getting key-file [http://fppmdasia.foxplay.com/FoxPlus_Asia_DP/421/983/layer_4_x92e1e74422ad4bad99e731c296cacc64/MC10352262CT_x92e1e74422ad4bad99e731c296cacc64_4.m3u8/../skd://fairplay.entitlement.theplatform.com/fpls/web/FairPlay] failed http_code[404].
Downloading part 0
Error: Merged PMT to long for one TS packet!Error: Invalid context!
{"t_d":1120,"d_d":6,"d_s":0}
Downloading part 1
Error: Getting key-file [http://fppmdasia.foxplay.com/FoxPlus_Asia_DP/421/983/layer_4_x92e1e74422ad4bad99e731c296cacc64/MC10352262CT_x92e1e74422ad4bad99e731c296cacc64_4.m3u8/../skd://fairplay.entitlement.theplatform.com/fpls/web/FairPlay] failed http_code[404].
Downloading part 1
03:
./hlsdl https://sg01-vod-cfd.tvbanywhere.com.sg/fpsvods3/_definst_/smil:ints3/tvboverseas-media/mytvsuper15/38538/3853765/mps_000002781643.smil/playlist.m3u8
Error: https://sg01-vod-cfd.tvbanywhere.com.sg/fpsvods3/_definst_/smil:ints3/tvboverseas-media/mytvsuper15/38538/3853765/mps_000002781643.smil/playlist.m3u8 403 tries[3]
Error: https://sg01-vod-cfd.tvbanywhere.com.sg/fpsvods3/_definst_/smil:ints3/tvboverseas-media/mytvsuper15/38538/3853765/mps_000002781643.smil/playlist.m3u8 403 tries[2]
Error: https://sg01-vod-cfd.tvbanywhere.com.sg/fpsvods3/_definst_/smil:ints3/tvboverseas-media/mytvsuper15/38538/3853765/mps_000002781643.smil/playlist.m3u8 403 tries[1]
{"error_code":403, "error_msg":""}
Warning: Not a valid M3U8 file. Exiting.

04:
http://hk4-edge11-1.edgeware.tvb.com/session/f3cf5d6a-eea9-11e9-b60b-005056b12cf7/5qqpe5/mpsdrmv/_definst_/smil:vipo/34/6321/632011/mps_000000789889.smil/playlist.m3u8?token=b9be00149ef381c463b15400b48dad8c_1571161328_1571161328
1: Bandwidth: 1404000, Resolution: unknown, Codecs: unknown
Which Quality should be downloaded? 1
1: Name: Cantonese, Language: Cantonese
Which Language should be downloaded? 1

START media_playlist_get_links
END media_playlist_get_links
START media_playlist_get_links
END media_playlist_get_links
HLS Stream is AES-128 encrypted.
File already exists. Overwrite? (y/n) y
{"d_t":"vod"}
{"t_d":1555,"d_d":0, "d_s":0}
Downloading part 0
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 1804624, out_size: 1804608
{"t_d":1555,"d_d":10,"d_s":1804608}
Downloading part 1
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 1712688, out_size: 1712672
{"t_d":1555,"d_d":20,"d_s":3517280}
Downloading part 2
Error: AES128_CBC_DecryptUpdate failed: 0, in_size: 1768336, out_size: 1768320
{"t_d":1555,"d_d":30,"d_s":5285600}

What should I do?

How to install this?

Hiya,

Not an expert so really don't understand how to install this. Is it possible to use this on MacOS? I tried using my windows computer but i couldn't figure out how to install as the instructions were not clear for a noob like me.

install at Debian 10 (buster)

Cheers!
I try to install your tool at Debian 10 and get with error on make

cc -D_GNU_SOURCE=1 -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -DPREFIX='"/usr/local"' -c src/main.c -o src/main.o
src/main.c:18:10: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
^~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:47: src/main.o] Error 1

What am I doing wrong?

As well can you be specified about dependencies - This program requires libcurl and libcrypto libraries.

I find libcurl4 in debian 10 - is it right lib?
But for libcrypto i got huge list - which one should i install?

android-libcrypto-utils - Android crypto-utils library
android-libcrypto-utils-dev - Android crypto-utils library - Development files
libcrypto-equality-clojure - Clojure library protecting against timing attacks
libcrypto-random-clojure - secure random generator for Clojure
libcryptokit-ocaml - cryptographic algorithm library for OCaml - runtime
libcryptokit-ocaml-dev - cryptographic algorithm library for OCaml - development
libcrypto++-dev - General purpose cryptographic library - C++ development
libcrypto++-doc - General purpose cryptographic library - documentation
libcrypto++-utils - General purpose cryptographic library - utilities and data files
libcrypto++6 - General purpose cryptographic library - shared library
libcrypto++6-dbg - General purpose cryptographic library - debug symbols
libssl-dev - Secure Sockets Layer toolkit - development files
libssl-doc - Secure Sockets Layer toolkit - development documentation
libssl1.1 - Secure Sockets Layer toolkit - shared libraries
r-cran-openssl - GNU R toolkit for encryption, signatures and certificates based on OpenSSL

error when compiling

~/hlsdl$ sudo make && make install && make clean

cc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -g -DPREFIX='"/usr/local"' -D_GNU_SOURCE=1 -std=gnu99 -c src/hls.c -o src/hls.o
src/hls.c: In function ‘decrypt_sample_aes’:
src/hls.c:334:38: error: ‘AV_CODEC_ID_H264’ undeclared (first use in this function)
src/hls.c:334:38: note: each undeclared identifier is reported only once for each function it appears in
src/hls.c:374:18: error: variable ‘cid’ has initializer but incomplete type
src/hls.c:374:28: error: storage size of ‘cid’ isn’t known
src/hls.c:375:24: error: ‘AV_CODEC_ID_AAC’ undeclared (first use in this function)
src/hls.c:381:31: error: ‘AV_CODEC_ID_AC3’ undeclared (first use in this function)
src/hls.c:374:28: warning: unused variable ‘cid’ [-Wunused-variable]
make: *** [src/hls.o] Error 1

Why does this happen?

Error: Video or Audio missing.Segmentation fault (core dumped)

Hello,

My m3u8 file(starting) looks like this

#EXTM3U
#EXT-X-VERSION:4

Created with Unified Streaming Platform(version=1.7.25)

#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES,URI="skd://fairplay",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

i suppose this is DRM ,any possibility you can implement this decryption ? its really annoying .

thanks

Thanks for share. But i have a problem.

Downloading part 140
src/curl.c:43:get_data_from_url:malloc(1): p=0xb670400
src/curl.c:87:get_data_from_url:malloc(570): p=0xb6a9c38
src/curl.c:95:get_data_from_url:free(0xb6a99f8)
src/hls.c:575:decrypt_aes128:malloc(570): p=0xb6a98c8
src/hls.c:580:decrypt_aes128:free(0xb6a98c8)
*** Error in `./hlsdl': double free or corruption (!prev): 0x0b6a98c8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x67f4a)[0xb74b3f4a]
/lib/i386-linux-gnu/libc.so.6(+0x6eb47)[0xb74bab47]
/lib/i386-linux-gnu/libc.so.6(+0x6f486)[0xb74bb486]
./hlsdl[0x80a711b]
./hlsdl[0x80a7322]
./hlsdl[0x80a3c1e]

Segmentation fault

Hello,

Im trying to download a SAMPLE-AES encrypted video, http://tv2-stream-od.online.no/vod2/_definst_/amlst:1007470_ps60000_pd1348980_HRDNGR.smil/playlist.m3u8

Then I get "Segmentation fault" after a split second. No more information when running with --verbose.

When running a gdb-session I get the following output:
(gdb) run "http://tv2-stream-od.online.no/vod2/_definst_/amlst:1007470_ps60000_pd1348980_HRDNGR.smil/chunklist_b3253000.m3u8"
Starting program: /usr/local/bin/hlsdl "http://tv2-stream-od.online.no/vod2/_definst_/amlst:1007470_ps60000_pd1348980_HRDNGR.smil/chunklist_b3253000.m3u8"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff0406700 (LWP 20842)]
[Thread 0x7ffff0406700 (LWP 20842) exited]
[New Thread 0x7ffff0406700 (LWP 20843)]
[Thread 0x7ffff0406700 (LWP 20843) exited]

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.

Any clues?

Resuming interrupted downloads

Initially, hlsdl works great with videos that I want to download, even including those that ffmpeg and youtube-dl cannot handle. But without support of resuming download it very difficult to finish downloading some long videos, especially on slow and unstable internet connections, or with links which expire after a while. Downloading process in such conditions is eventually interrupted before it is completed.

So it would be great if hlsdl would support resuming downloads, as youtube-dl and ffmpeg does.

How does it work?

Hi!
After a lot of research I found this tool. I really need it badly to decrypt sample-aes,KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"(You know what this is!). I know a little bit programming in C(compared to you, i'm just starting out). I have found your code pretty amazing. But I am not able to use this perfect tool to my liking. Can you please teach me how this works? It would be really a huge help. I really want to understand this code. Please help and don't say NO.

i got error in the compile

:~/hlsdl# make
cc src/main.o src/aes.o src/curl.o src/hls.o src/misc.o src/msg.o -lcurl -lavformat -lavutil -lavcodec -o hlsdl
src/hls.o: In function decrypt_sample_aes': /root/hlsdl/src/hls.c:478: undefined reference to av_packet_unref'
collect2: error: ld returned 1 exit status

this is error , i need help please

Audio ignored when the TS video file doesn't start with TS_SYNC_BYTE

I noticed that the audio is completely dropped when the video file doesn't start with a TS packet immediately. After debugging a bit, it appears that the download_hls function expects to find a TS_SYNC_BYTE at the very beginning of the file which is not always the case on my streams: some of them have a FFMpeg header for instance.

Unfortunately, I can't share my m3u8 file publicly since I don't own the content of the stream and it's supposed to be behind a paywall, but here is the beginning of the video file:

0000000 7e 8d 1d 64 e0 e0 a2 37 1d 8f 17 da e6 d9 83 72
0000020 00 01 fc 80 14 48 12 01 06 46 46 6d 70 65 67 09
0000040 53 65 72 76 69 63 65 30 31 77 7c 43 ca ff ff ff
0000060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0000260 ff ff ff ff ff ff ff ff ff ff ff ff 47 40 00 16
                                            ^ First TS packet here
0000300 00 00 b0 0d 00 01 c1 00 00 00 01 f0 00 2a b1 04
0000320 b2 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0000340 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0000560 ff ff ff ff ff ff ff ff 47 50 00 16 00 02 b0 12
                                ^ the next here
0000600 00 01 c1 00 00 e1 00 f0 00 1b e1 00 f0 00 15 bd
0000620 4d 56 ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0000640 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0001060 ff ff ff ff 47 41 00 3d 07 50 00 08 b8 6c 7e 00
                    ^ and so on
0001100 00 00 01 e0 00 00 80 c0 0a 31 00 4b 06 21 11 00

A fix could be to start parsing the file as soon as a couple of TS_SYNC_BYTE are encountered. Let me know what you think.

HLS stream is DRM protected

/hlsdl# ./hlsdl https://my.mixtape.moe/fortdx.m3u8
Found 6 Qualitys

0: Bandwidth: 770726
1: Bandwidth: 707714
2: Bandwidth: 1369976
3: Bandwidth: 1224918
4: Bandwidth: 2826976
5: Bandwidth: 2563644
Which Quality should be downloaded? 0
Warning: HLS stream is DRM protected. Exiting
root@:~/hlsdl# ./hlsdl https://my.mixtape.moe/rcxrtv.m3u8
Warning: HLS stream is DRM protected. Exiting

then it can't be downloaded?
I'll leave this https://fairplaycrackle.akamaized.net/Crackle_FPS-R16463821.der

About that segfault issue from earlier...

Sorry to have to create a new issue but I wasn't sure how else to contact you. Don't need a response - close this off after you've read it by all means.
File was corrupt.
File was about 600mb so a lot of errors, I'll post the different types in what order I can get to (scrollback on bash is small) in case any of it helps.

[ffmpeg/audio] aac: Number of bands (52) exceeds limit (42).
Error decoding audio.
[ffmpeg/audio] aac: TNS filter order 16 is greater than maximum 12.
Error decoding audio.
[ffmpeg/audio] aac: TNS filter order 19 is greater than maximum 12.
Error decoding audio.
[ffmpeg/audio] aac: SSR is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[ffmpeg/audio] aac: If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. ([email protected])

[ffmpeg/audio] aac: Sample rate index in program config element does not match the sample rate index configured by the container.
[ffmpeg/audio] aac: decode_pce: Input buffer exhausted before END element found
Error decoding audio.

[ffmpeg/video] h264: error while decoding MB 12 0, bytestream 9100
[ffmpeg/video] h264: top block unavailable for requested intra mode -1

[ffmpeg/video] h264: top block unavailable for requested intra mode -1
[ffmpeg/video] h264: error while decoding MB 11 0, bytestream 7088
AV: 00:20:48 / 00:43:00 (60%) A-V: 0.000 Cache: 9s+73MB
[ffmpeg/video] h264: Reference 3 >= 3
[ffmpeg/video] h264: error while decoding MB 39 1, bytestream 5781

Cheers for your help, much appreciated.

Error: Video or Audio missing.Segmentation fault: 11

Debug: Loglevel: 2
Choosing best quality. (Bitrate: 5605000)
HLS Stream is SAMPLE-AES encrypted.
Media Playlist parsed successfully.
Downloading 411 segments.
Downloading part 0
Error: Video or Audio missing.Segmentation fault: 11

thats the output im getting. does this mean the .ts is also protected hence it cant read what the put into the single .ts

sample rate not set

When trying to convert a M3U8 file that is SAMPLE-AES encrypted I get the following error.

HLS Stream is SAMPLE-AES encrypted.
Media Playlist parsed successfully.
Downloading 325 segments.
Downloading part 0
[mpegts @ 0x7fb4ef01d000] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Ignoring attempt to set invalid timebase 1/0 for st:0
[mpegts @ 0x7fb4ef01d000] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mpegts @ 0x7fb4ef01d000] sample rate not set
Error: Writing header failed.
Segmentation fault: 11

Maximum download resolution?

1: Bandwidth: 1096, Resolution: unknown, Codecs: unknown
2: Bandwidth: 704, Resolution: unknown, Codecs: unknown
Which Quality should be downloaded? 1

START media_playlist_get_links
END media_playlist_get_links
HLS Stream is AES-128 encrypted.
Media Playlist parsed successfully.

I'm only getting highest resolution of only 720p for downloading. But, the website showing highest of 1080p. So, wondering how to achieve 1080p download resolution. Any suggestion and help is appreciated. Thank you.

m3u8 cookie

does hlsdl parse cookies in an url?
Doesnt seem like it

how do i actually install this?

hi

can someone help me install this? i downloaded the .zip file and extracted the files to a folder, but i dont really know how do i need to use the make commands with the files....

i tried 'sudo make makefile' and 'sudo make install' in that folder, but it only keeps giving errors that 'hlsdl: no such file or directory' etc...

i basically need it for the Sample-Aes decryptor...

thanks

Error: Getting key-file

Hello, I am trying to download a video but I get this error.

{"d_t":"vod"}
{"t_d":2653,"d_d":0, "d_s":0}
Downloading part 1
Error: Getting key-file [https://d14rrhzkv7td66.cloudfront.net/origin/HLS_183986_0-VO-fairplay.ism/HLS_183986_0-VO-fairplay-audio=192001-video=2331000.m3u8/../skd://fps.ezdrm.com/;20a0de82-1467-4c1f-b912-29bfa1bd9876] failed http_code[400].
{"t_d":2653,"d_d":3,"d_s":929660}

M3U8 file looks like this

#EXTM3U
#EXT-X-VERSION:1
## Created with Unified Streaming Platform (version=1.10.12-18737)
#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES,URI="skd://fps.ezdrm.com/;20a0de82-1467-4c1f-b912-29bfa1bd9876",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

# variants
#EXT-X-STREAM-INF:BANDWIDTH=368000,CODECS="mp4a.40.2,avc1.66.30",RESOLUTION=426x240
HLS_183986_0-VO-fairplay-audio=64003-video=283000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=735000,CODECS="mp4a.40.2,avc1.66.30",RESOLUTION=640x360
HLS_183986_0-VO-fairplay-audio=128001-video=565000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1429000,CODECS="mp4a.40.2,avc1.100.40",RESOLUTION=854x480
HLS_183986_0-VO-fairplay-audio=192001-video=1156000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2675000,CODECS="mp4a.40.2,avc1.100.40",RESOLUTION=1280x720
HLS_183986_0-VO-fairplay-audio=192001-video=2331000.m3u8

# variants
#EXT-X-STREAM-INF:BANDWIDTH=68000,CODECS="mp4a.40.2"
HLS_183986_0-VO-fairplay-audio=64003.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=136000,CODECS="mp4a.40.2"
HLS_183986_0-VO-fairplay-audio=128001.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=204000,CODECS="mp4a.40.2"
HLS_183986_0-VO-fairplay-audio=192001.m3u8

Do you have a solution.
Thank you.

Binary?

Do you have a pre-compiled version of this for Windows?

Stack smashing detected

I get stack smashing detected WARNING when attempting to download certain links. I can PM you the link. Other links work well.

I am using the latest version of hlsdl, ffmpeg and ubuntu.

Hello

When i am installing i am getting this error message and was hope you could help me .

root@kali:~/Desktop/hlsdl-master# make && make install && make clean
cc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -g -DPREFIX='"/usr/local"' -D_GNU_SOURCE=1 -std=gnu99 -c src/main.c -o src/main.o
src/main.c:6:23: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>

Thanks

Undefined Reference: merge_packets

In file included from src/hls.c:3:0:
| /media/budiarno/MAXXIO/Enigma2/OE-Alliance/build-enviroment/builds/openbh/release/u5/tmp/work/cortexa15hf-neon-vfpv4-oe-linux-gnueabi/hlsdl/hlsdl-1.0+gitAUTOINC+5508fd65b6-r0/recipe-sysroot/usr/include/libavformat/avformat.h:893:21: note: declared here
|      AVCodecContext *codec;
|                      ^~~~~
| /tmp/ccVoDx1M.o: In function `download_hls':
| hls.c:(.text+0x39a8): undefined reference to `merge_packets'
| collect2: error: ld returned 1 exit status

Got this error when compiling Enigma2 image.

AVCodecParameters has no member named ‘frame_size'

Tried compiling on cygwin and ubuntu, got this error on both.

src/hls.c:407:17: error: ‘AVCodecParameters {aka struct AVCodecParameters}’ has  no member named ‘frame_size’; did you mean ‘extradata_size’?
             in_c->frame_size = audio_frame_size;

Yahoo7 again: download successful but file is broken

A download appears to complete, but the file fails to play in VLC or ffplay
URL found via ~/bin/youtube-dl -j https://au.tv.yahoo.com/plus7/highway-patrol/-/watch/37394255/highway-patrol-mon-9-oct-season-9-episode-8/ | jq .

[mpegts @ 0x564212aa8800] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
Downloading part 639
[mpegts @ 0x564212c21260] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
Downloading part 640
Downloading part 641

ffmpeg says: Output #0, mpegts, to '0_hlsdl_output.ts': Output file #0 does not contain any stream

cant build this , how to build it ?

~/Downloads/hlsdl# make
cc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -g -DPREFIX='"/usr/local"' -D_GNU_SOURCE=1 -std=gnu99 -c src/hls.c -o src/hls.o
src/hls.c: In function ‘decrypt_sample_aes’:
src/hls.c:334:38: error: ‘AV_CODEC_ID_H264’ undeclared (first use in this function)
src/hls.c:334:38: note: each undeclared identifier is reported only once for each function it appears in
src/hls.c:374:18: error: variable ‘cid’ has initializer but incomplete type
src/hls.c:374:28: error: storage size of ‘cid’ isn’t known
src/hls.c:375:24: error: ‘AV_CODEC_ID_AAC’ undeclared (first use in this function)
src/hls.c:381:31: error: ‘AV_CODEC_ID_AC3’ undeclared (first use in this function)
src/hls.c:374:28: warning: unused variable ‘cid’ [-Wunused-variable]
src/hls.c:478:9: warning: implicit declaration of function ‘av_packet_unref’ [-Wimplicit-function-declaration]
make: *** [src/hls.o] Error 1

Segfault when downloading stream

[mpegts @ 0x5555557b23c0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Ignoring attempt to set invalid timebase 1/0 for st:0
[mpegts @ 0x5555557b23c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mpegts @ 0x5555557b23c0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mpegts @ 0x5555557b23c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Downloading part 1
[New Thread 0x7fffe5512700 (LWP 2598)]
[Thread 0x7fffe5512700 (LWP 2598) exited]
[mpegts @ 0x555555859d20] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Ignoring attempt to set invalid timebase 1/0 for st:0
[mpegts @ 0x555555859d20] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mpegts @ 0x555555859d20] sample rate not set
Error: Writing header failed.

Thread 1 "hlsdl" received signal SIGSEGV, Segmentation fault.
0x00007ffff7821dc0 in ?? () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
(gdb) bt
#0  0x00007ffff7821dc0 in ?? () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#1  0x00007ffff78246f2 in av_interleaved_write_frame () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#2  0x0000555555558bb5 in decrypt_sample_aes (s=0x5555557a9ce0, buf=0x7fffffffe790) at src/hls.c:474
#3  0x0000555555559019 in download_hls (me=0x7fffffffe910) at src/hls.c:553
#4  0x0000555555555de9 in main (argc=5, argv=0x7fffffffea68) at src/main.c:91

Playlist is https://yahoo7p-a.akamaihd.net/2376984108001/201706/1396/5486755041001/2376984108001_5486755041001_5486744045001.m3u8 which is restricted to Australian IPs.

Installing the -dbgsym package shows that it's failing on compute_muxer_pkt_fields (s=s@entry=0x555555859d00, st=st@entry=0x5555557bf3c0, pkt=pkt@entry=0x7fffffffe680) at src/libavformat/mux.c:659

https://anonscm.debian.org/cgit/pkg-multimedia/ffmpeg.git/tree/libavformat/mux.c?h=jessie#n659

Not working

Dear,

Thank you for such tool that I hoped it will solve my problem! Here is my command:

hlsdl "***********.ism/FOR0040971_12615_(12615_ISMUSP)-audio_eng=80001-video_eng=2404000.m3u8" -b -v --dump-dec-cmd -o /Users/d3ibis/Desktop/TestTVAE.mp4

Stars to hide url and other commands (b, v, dump..etc) for my own research...

here is the result:

Debug: Loglevel: 2 Warning: HLS stream is DRM protected. Exiting

Really ? this is a sample-aes playlist which is encrypted and DRM (thats why sample-aes is there)

here is then header of the m3u8 file:

`#EXTM3U
#EXT-X-VERSION:5

Created with Unified Streaming Platform(version=1.7.19)

#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:8
#USP-X-TIMESTAMP-MAP:MPEGTS=900000,LOCAL=1970-01-01T00:00:00Z
#EXTINF:8, no desc
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://****************",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"`

Any ideas ?

Thanks in advance...

Windows Binary

I tried compiling using "Cygwin" as suggested by SalamanderSandwich@ #31 . But, getting following error:
$ make
cc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -DPREFIX='"/usr/local"' -c src/hls.c -o src/hls.o
src/hls.c:11:10: fatal error: sys/prctl.h: No such file or directory
#include <sys/prctl.h>
^~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:47: src/hls.o] Error 1

So, any suggestion or help on this please. Thank you and regards.

downloaded files

it downloaded files....but i couldn't decrypt them.

script to run on downloaded .ts file:

hexKey=$(cat espn2.key | hexdump -e '16/1 "%02x"')
hexIV='0000000000000000000000000000CA80'

openssl aes-128-cbc -d -p -nosalt -iv ${hexIV} -K ${hexKey} -in encrypted.ts -out decrypted.ts

error

bad decrypt
9030:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad 
decrypt:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59/src/crypto/evp/evp_enc.c:330:

Abort trap: 6 on Download

Im getting this error when I trying to download on MacOS Sierra:

hlsdl url
Debug: Loglevel: 2
Found 8 Qualitys

0: Bandwidth: 300000
1: Bandwidth: 600000
2: Bandwidth: 900000
3: Bandwidth: 1200000
4: Bandwidth: 1500000
5: Bandwidth: 1800000
6: Bandwidth: 2100000
7: Bandwidth: 2524000
Which Quality should be downloaded? 1
Abort trap: 6

Looks like its an Array error.

Im getting this error when I trying to download on Ubuntu 16.04:

hlsdl url
Debug: Loglevel: 2
Found 8 Qualitys

0: Bandwidth: 300000
1: Bandwidth: 600000
2: Bandwidth: 900000
3: Bandwidth: 1200000
4: Bandwidth: 1500000
5: Bandwidth: 1800000
6: Bandwidth: 2100000
7: Bandwidth: 2524000
Which Quality should be downloaded? 1
*** stack smashing detected ***: hlsdl terminated
Aborted (core dumped)

install problems on centos 6.9

# make && make install && make clean cc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -g -DPREFIX='"/usr/local"' -D_GNU_SOURCE=1 -std=gnu99 -c src/main.c -o src/main.o src/main.c:1:34: error: libavformat/avformat.h: No such file or directory src/main.c: In function ‘main’: src/main.c:25: warning: implicit declaration of function ‘av_register_all’ make: *** [src/main.o] Error 1

how to get sample-aes working?

Im trying to get sample-aes working

HLS Stream is SAMPLE-AES encrypted.
Error: Getting key-file

The url is provided
skd://entry-.....

http error 404

Lack of dependence

我用了ubuntu 16.04,打了以下依赖才成功。。
sudo apt-get install libssl-dev
sudo apt-get install openssl
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libcurl-dev

Windows binaries

Any chance anyone could provide those?
I've tried to compile sources with cygwin, but it fails.

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.