Hey guys,
Until recently, I've been using streamlink (invoked daily as a batch file at the same time each day by task scheduler) to download and save a HLS stream for a duration of ~2:30 hours. Was using this command:
streamlink --http-no-ssl-verify --stream-segment-threads 2 --stream-timeout 300 --hls-playlist-reload-attempts 10 --hls-duration 02:30:00 --http-header "User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 AOL/9.8 AOLBuild/4346.2019.US Safari/537.36" --http-header "Referer=https://telefullenvivo.com/ver-canal-26-en-vivo-online/" "hlsvariant://edge2-ccast-sl.cvattv.com.ar/live/c6eds/26_TV_HD/SA_SAGEMCOM/26_TV_HD-avc1_3000000=10004.m3u8" best -o E:\sl\canal26-{time:%%Y_%%m_%%d__%%H-%%M}.ts
Unfortunately, the stream is no longer available as HLS, only as Widevine DRM protected DASH.
I have this link to the MPD file:
https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd
I also have the key and it works. Using yt-dlp, this is what I got:
yt-dlp --allow-u --external-downloader aria2c -f bv,ba "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd" -o test.mp4
WARNING: You have asked for UNPLAYABLE formats to be listed/downloaded. This is a developer option intended for debugging.
If you experience any issues while using this option, DO NOT open a bug report
[generic] 26_TV_HD: Downloading webpage
[redirect] Following redirect to https://edge-live17-hr.cvattv.com.ar:443/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd
[generic] 26_TV_HD: Downloading webpage
WARNING: [generic] Falling back on generic information extractor.
[generic] 26_TV_HD: Extracting information
[info] 26_TV_HD: Downloading 2 format(s): avc1_3000000=10004, mp4a_144800_spa=20000
[dashsegments] Total fragments: 3597
[dashsegments] Fragment downloads will be delegated to aria2c
[download] Destination: test.mp4
[aria2c] Downloaded 2690955902 bytes )][#08b09c 704KiB/738KiB(95%)]
[download] 100% of 2.51GiB in 13:28
[download] test.mp4 has already been downloaded
[download] 100% of 2.51GiB
I then used mp4decrypt --key kid:key test.mp4 decr.mp4, which was successful
However, decr.mp4 has no audio (video plays fine), despite yt-dlp saying "Downloading 2 format(s): avc1_3000000=10004, mp4a_144800_spa=20000". Seeking is broken - MediaInfo lists it as 1 h 59 min, but the video shows as 6667 hours long in VLC and 109 hours in MPC-HC. Avidemux can't open the file. Don't know why the file is broken like that, but it's not what I need anyway...
...so back to the original question. If I try to use streamlink with the new .mpd URL's, I always get this error - 26_TV_HD.mpd is protected by DRM - and can't proceed to download the stream. Can anyone point me in the right direction as to how to download this stream (video+audio) in real time (not like yt-dlp) for a duration of my choosing (2:30 hours), so in essence I get similar result like with the old HLS command pasted above (minus the extra decryption step which is now needed). Thank you!
Support our site by donate $5 directly to us Thanks!!!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
+ Reply to Thread
Results 1 to 17 of 17
-
Last edited by aquadark; 9th Aug 2022 at 17:44.
-
@aquadark
You must be congratulated for an extreme well composed posting.
I have one question
you have yt-dlp ...................... -o test.mp4
then you used mp4decrypt --key kid:key test.mp4 decr.mp4
yt-dlp should have downloaded two files .... one video and one audio. If yt-dlp did not d/l two files, then I suggest that you retry without the -o option.
You need to mp4decrypt both the audio and the video. After decryption, the two decrypted files should the be merged.
Also, no need for -f bv,ba as yt-dlp will download the best audio and video by default
The reason you have no audio is because you did not merge the audio with the video. yt-dlp usually produces one mp4 and one m4a file.
Hope this helps and thanks for your great post.Last edited by jack_666; 9th Aug 2022 at 20:45.
-
First download this version of ffmpeg https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-2022-08-08-git-56973eb687-essentials_build.7z
Install it (you can find on youtube how to do it) and then use this command:
Code:ffmpeg -cenc_decryption_key "ad60c5e1d378a97271bf8688f094d092" -i "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc/26_TV_HD.mpd" -map 0:4 -map 0:5 -t 02:30:00.00 -c copy c26.mp4
.
Last edited by lfer94; 9th Aug 2022 at 22:57.
-
Thank you, @lfer94, for the detailed explanation. Your code works great, I get a decrypted, playable file with audio and with the highest quality, unfortunately, as you said, it's slow... 0.116x slow, according to ffmpeg's output... meaning my 10 minute test download took just under 90 minutes to download (file created 9:30, completed 10:55). So, if I want to record 2:30 hours, it would take ffmpeg over 22 hours. Yes, it's doable, if the stream expires after 24 hours as you said, but unfortunately I only have one PC (notebook), which I also use for work and take it with me every morning, meaning I temporarily loose the internet connection...
Just out of curiosity, why is the speed so slow? Does it have to do anything with the decryption? Do you think I can download an encrypted file with higher speed (actually, live speed 1.0x, like streamlink) and decrypt later using mp4decrypt?
Thank you, @jack_666, too! I first tried, as you mentioned, the simplest command (without -f and -o) and here is what I got:
yt-dlp --allow-u --external-downloader aria2c "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd"
WARNING: You have asked for UNPLAYABLE formats to be listed/downloaded. This is a developer option intended for debugging.
If you experience any issues while using this option, DO NOT open a bug report
[generic] 26_TV_HD: Downloading webpage
[redirect] Following redirect to https://edge-live17-hr.cvattv.com.ar:443/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd
[generic] 26_TV_HD: Downloading webpage
WARNING: [generic] Falling back on generic information extractor.
[generic] 26_TV_HD: Extracting information
[info] 26_TV_HD: Downloading 1 format(s): avc1_3000000=10004+mp4a_144800_spa=20000
WARNING: You have requested merging of multiple formats while also allowing unplayable formats to be downloaded. The formats won't be merged to prevent data corruption.
[dashsegments] Total fragments: 3597
[dashsegments] Fragment downloads will be delegated to aria2c
[download] Destination: 26_TV_HD [26_TV_HD].favc1_3000000=10004.mp4
[DL:2.8MiB][#7c26eb 656KiB/717KiB(91%)][#d0988b 560KiB/700KiB(79%)][#b00038 496KiB/725KiB(68%)][#b56983 480KiB/743KiB(64%)][#278fbc 624KiB/724KiB(86%)](+11)
Unfortunately, there were many errors during the download, don't know why... (also see screenshot, the code below is just a snippet)
[DL:0B][#e404ac 0B/0B][#c79051 0B/0B][#657cb6 0B/0B][#74ef66 0B/0B][#5daf6a 0B/0B](+11)
08/10 12:10:41 [ERROR] CUID#54 - Download aborted. URI=https://edge-live17-hr.cvattv.com.ar:443/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD-avc1_3000000=10004-2400418395114445.mp4
Exception: [AbstractCommand.cc:403] errorCode=1 URI=https://edge-live17-hr.cvattv.com.ar:443/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD-avc1_3000000=10004-2400418395114445.mp4
-> [RequestGroup.cc:761] errorCode=1 Download aborted.
-> [DefaultBtProgressInfoFile.cc:298] errorCode=1 total length mismatch. expected: 749927, actual: 749446
[DL:0B][#efe45d 0B/0B][#143f05 0B/0B][#831412 0B/0B][#b700a5 0B/0B][#611d79 0B/0B]
aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.
[Attachment 66254 - Click to enlarge]
[aria2c] Downloaded 2699021154 bytes
[download] 100% of 2.51GiB in 59:32
[dashsegments] Total fragments: 3598
[dashsegments] Fragment downloads will be delegated to aria2c
[download] Destination: 26_TV_HD [26_TV_HD].fmp4a_144800_spa=20000.m4a
[aria2c] Downloaded 119354898 bytes 844d9 0B/0B][#2ec7c2 0B/32KiB(0%)][#272122 0B/0B][#76374a 0B/32KiB(0%)](+11)
[download] 100% of 113.83MiB in 02:03
I decrypted both files using mp4decrypt and the interesting thing is that the mp4 video file ALSO has audio, even before merging!
So I renamed the files to something easier and tried to merge them anyway using:
ffmpeg -i video_d.mp4 -i video_d.m4a decry.mp4
I got a file that was only 112mb. It is playable in the first 8 seconds (both video + audio), but then it stops... so, essentially, the 2.51GiB mp4 file, after decryption, does the same... probably the video file was corrupted because of the too many errors (there were none yesterday...)
Here is the ffmpeg output:
ffmpeg -i video_d.mp4 -i video_d.m4a decry.mp4
ffmpeg version 2022-08-08-git-56973eb687-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 32.101 / 57. 32.101
libavcodec 59. 42.100 / 59. 42.100
libavformat 59. 30.100 / 59. 30.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 46.101 / 8. 46.101
libswscale 6. 8.102 / 6. 8.102
libswresample 4. 8.100 / 4. 8.100
libpostproc 56. 7.100 / 56. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_d.mp4':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
Duration: 66678:15:55.43, start: 240041747.452811, bitrate: 0 kb/s
Stream #0:0[0x2714](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 10000k tbn (default)
Metadata:
handler_name : -> vide
vendor_id : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video_d.m4a':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
Duration: 66680:15:48.63, start: 240041747.440045, bitrate: 0 kb/s
Stream #1:0[0x4e20](spa): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 0 kb/s (default)
Metadata:
handler_name : -> soun
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 000002157f0d7040] using SAR=1/1
[libx264 @ 000002157f0d7040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000002157f0d7040] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 000002157f0d7040] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'decry.mp4':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
encoder : Lavf59.30.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 30k tbn (default)
Metadata:
handler_name : -> vide
vendor_id : [0][0][0][0]
encoder : Lavc59.42.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(spa): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : -> soun
vendor_id : [0][0][0][0]
encoder : Lavc59.42.100 aac
[NULL @ 000002157ee404c0] Invalid NAL unit size (-2024543073 > 3578).346.7kbits/s speed= 3.9x
[NULL @ 000002157ee404c0] missing picture in access unit with size 3582
[h264 @ 000002157f0db940] Invalid NAL unit size (-2024543073 > 3578).
[h264 @ 000002157f0db940] Error splitting the input into NAL units.
[h264 @ 000002157f5e6cc0] Reference 6 >= 2
[h264 @ 000002157f5e6cc0] error while decoding MB 52 31, bytestream 5926
[h264 @ 000002157f5e6cc0] concealing 1117 DC, 1117 AC, 1117 MV errors in P frame
Error while decoding stream #0:0: Invalid data found when processing input
frame= 240 fps=1.0 q=-1.0 Lsize= 115124kB time=02:00:01.17 bitrate= 131.0kbits/s speed=29.9x
video:1586kB audio:112210kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.166641%
[libx264 @ 000002157f0d7040] frame I:1 Avg QP:24.29 size: 47057
[libx264 @ 000002157f0d7040] frame P:66 Avg QP:23.15 size: 14751
[libx264 @ 000002157f0d7040] frame B:173 Avg QP:26.85 size: 3487
[libx264 @ 000002157f0d7040] consecutive B-frames: 2.9% 0.8% 6.2% 90.0%
[libx264 @ 000002157f0d7040] mb I I16..4: 27.7% 42.5% 29.8%
[libx264 @ 000002157f0d7040] mb P I16..4: 10.3% 12.6% 2.4% P16..4: 35.1% 7.9% 3.5% 0.0% 0.0% skip:28.2%
[libx264 @ 000002157f0d7040] mb B I16..4: 0.7% 0.7% 0.2% B16..8: 31.7% 2.8% 0.3% direct: 1.8% skip:61.9% L0:46.9% L1:48.8% BI: 4.3%
[libx264 @ 000002157f0d7040] 8x8 transform intra:48.7% inter:74.4%
[libx264 @ 000002157f0d7040] coded y,uvDC,uvAC intra: 33.4% 54.1% 10.4% inter: 7.3% 11.7% 0.6%
[libx264 @ 000002157f0d7040] i16 v,h,dc,p: 25% 36% 8% 31%
[libx264 @ 000002157f0d7040] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 26% 25% 3% 5% 4% 5% 4% 4%
[libx264 @ 000002157f0d7040] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 34% 12% 3% 6% 5% 6% 4% 3%
[libx264 @ 000002157f0d7040] i8c dc,h,v,p: 46% 29% 18% 7%
[libx264 @ 000002157f0d7040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002157f0d7040] ref P L0: 67.9% 7.5% 19.3% 5.3%
[libx264 @ 000002157f0d7040] ref B L0: 88.9% 8.7% 2.4%
[libx264 @ 000002157f0d7040] ref B L1: 96.4% 3.6%
[libx264 @ 000002157f0d7040] kb/s:1622.19
[aac @ 000002157f0db400] Qavg: 1492.746
-
I'm not sure. FFmpeg sometimes download files very slowly, regardless of our connection speed, but in your case it's too slow. Are you sure you copied the command exactly as I wrote it?
Anyway, what you could try is to download the audio and video separately. If there's an improvement in download speed, then the problem is the decryption and/or multiplexing process. But then you'll have another problem, because you'll have to mux both files and synchronize them if there's a delay in one of them.
Another thing you could try is to use this command two hours after the TV show you want to record has started.
Code:yt-dlp --allow-un --write-info-json --skip-download "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd" -o c26-1.%(ext)s
Code:yt-dlp --allow-un --write-info-json --skip-download "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd" -o c26-2.%(ext)s
Last edited by lfer94; 10th Aug 2022 at 08:22.
-
Downloaded here without a hitch.
Code:yt-dlp --allow-u --external-downloader aria2c "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd" WARNING: You have asked for UNPLAYABLE formats to be listed/downloaded. This is a developer option intended for debugging. If you experience any issues while using this option, DO NOT open a bug report [generic] 26_TV_HD: Requesting header [redirect] Following redirect to https://edge-live17-hr.cvattv.com.ar:443/live/c6eds/26_TV_HD/SA_Live_dash_enc_2A/26_TV_HD.mpd [generic] 26_TV_HD: Requesting header WARNING: [generic] Falling back on generic information extractor. [generic] 26_TV_HD: Downloading webpage [generic] 26_TV_HD: Extracting information [info] 26_TV_HD: Downloading 1 format(s): avc1_3000000=10004+mp4a_144800_spa=20000 WARNING: You have requested merging of multiple formats while also allowing unplayable formats to be downloaded. The formats won't be merged to prevent data corruption. [dashsegments] Total fragments: 3597 [dashsegments] Fragment downloads will be delegated to aria2c [download] Destination: 26_TV_HD [26_TV_HD].favc1_3000000=10004.mp4 [aria2c] Downloaded 2684515341 bytes )][#b11715 576KiB/733KiB(78%)] [download] 100% of 2.50GiB in 13:30 [dashsegments] Total fragments: 3597 [dashsegments] Fragment downloads will be delegated to aria2c [download] Destination: 26_TV_HD [26_TV_HD].fmp4a_144800_spa=20000.m4a [aria2c] Downloaded 119321602 bytes 0d16f 0B/32KiB(0%)][#41a3f0 0B/32KiB(0%)][#ba7a8c 0B/32KiB(0%)][#946a13 0B/0B](+2) [download] 100% of 113.79MiB in 01:53
-
-
Enjoy
Code:https://mega.nz/file/Y9NglKbI#tp51nRgkDsNKKJcxNfTIyGprW9cmz1FcTZCHhW_nBmY
-
-
Alternatively, try this version of Streamlink, I have more success with it than yt-dlp for live streams.
https://github.com/sunghome/streamlink_optionalkey
You can specify the key with --ffmpeg-dkey -
Yet another solution:
N_m3u8DL-RE: https://github.com/nilaoda/N_m3u8DL-RE/releases/
Need shaka-packager, ffmpeg
Sample to record 3 minutes, and mux to mp4.
Code:N_m3u8DL-RE "https://cdn.cvattv.com.ar/live/c6eds/26_TV_HD/SA_Live_dash_enc/26_TV_HD.mpd" --auto-select --save-name c26 --mux-after-done mp4 --use-shaka-packager --key e32aaa4b67430b3b51be1efce5a74ac5:ad60c5e1d378a97271bf8688f094d092 --live-keep-segments false --live-real-time-merge --live-record-limit 00:03:00
[Attachment 67543 - Click to enlarge]
[Attachment 67544 - Click to enlarge] -
Similar Threads
-
restreaming to non-drm m3u8 from drm mpd
By grabyea in forum Video Streaming DownloadingReplies: 1Last Post: 8th Aug 2022, 00:35 -
What is the so-called 'working CDM' in the context of widevine DRM?
By adidaz in forum Video Streaming DownloadingReplies: 14Last Post: 15th Mar 2022, 04:05 -
DRM Live NO, DRM VoD YES.
By d0b in forum Video Streaming DownloadingReplies: 49Last Post: 7th Oct 2021, 15:41 -
Download DRM protected video and decrypt it with a drm licence url
By vikral in forum Video Streaming DownloadingReplies: 9Last Post: 9th Feb 2021, 02:14 -
Download from Daily Motion
By sven32 in forum Video Streaming DownloadingReplies: 2Last Post: 24th Nov 2020, 11:48