Cannot download m3u8 from reddit
Closed this issue · 1 comments
remorses commented
I tried to download a video from reddit (https://v.redd.it/uag4uw003od51/HLSPlaylist.m3u8
) but the download stops at about 400 bytes
const fs = require('fs')
const m3u8stream = require('m3u8stream')
const res = m3u8stream('https://v.redd.it/uag4uw003od51/HLSPlaylist.m3u8').pipe(
fs.createWriteStream('videofile.mp4'),
)
res.on('progress', console.log)
res.on('end', () => console.log('end'))
This is what gets downloaded:
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:197024@0
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:206612@197024
HLS_224.ts
#EXTINF:5,
#EXT-X-BYTERANGE:184240@403636
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:208492@587876
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:219960@796368
HLS_224.ts
#EXTINF:5,
#EXT-X-BYTERANGE:173524@1016328
HLS_224.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:344040@0
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:354568@344040
HLS_270.ts
#EXTINF:5,
#EXT-X-BYTERANGE:314712@698608
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:363404@1013320
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:379196@1376724
HLS_270.ts
#EXTINF:5,
#EXT-X-BYTERANGE:296476@1755920
HLS_270.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:639200@0
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:641268@639200
HLS_360.ts
#EXTINF:5,
#EXT-X-BYTERANGE:578664@1280468
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:668340@1859132
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:702744@2527472
HLS_360.ts
#EXTINF:5,
#EXT-X-BYTERANGE:547644@3230216
HLS_360.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:976660@0
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1008056@976660
HLS_540.ts
#EXTINF:5,
#EXT-X-BYTERANGE:891496@1984716
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1045468@2876212
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1080248@3921680
HLS_540.ts
#EXTINF:5,
#EXT-X-BYTERANGE:855588@5001928
HLS_540.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:1315812@0
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1235724@1315812
HLS_576.ts
#EXTINF:5,
#EXT-X-BYTERANGE:1203388@2551536
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1506632@3754924
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1222188@5261556
HLS_576.ts
#EXTINF:5,
#EXT-X-BYTERANGE:1365820@6483744
HLS_576.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:197024@0
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:206612@197024
HLS_224.ts
#EXTINF:5,
#EXT-X-BYTERANGE:184240@403636
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:208492@587876
HLS_224.ts
#EXTINF:6,
#EXT-X-BYTERANGE:219960@796368
HLS_224.ts
#EXTINF:5,
#EXT-X-BYTERANGE:173524@1016328
HLS_224.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:344040@0
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:354568@344040
HLS_270.ts
#EXTINF:5,
#EXT-X-BYTERANGE:314712@698608
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:363404@1013320
HLS_270.ts
#EXTINF:6,
#EXT-X-BYTERANGE:379196@1376724
HLS_270.ts
#EXTINF:5,
#EXT-X-BYTERANGE:296476@1755920
HLS_270.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:639200@0
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:641268@639200
HLS_360.ts
#EXTINF:5,
#EXT-X-BYTERANGE:578664@1280468
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:668340@1859132
HLS_360.ts
#EXTINF:6,
#EXT-X-BYTERANGE:702744@2527472
HLS_360.ts
#EXTINF:5,
#EXT-X-BYTERANGE:547644@3230216
HLS_360.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:976660@0
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1008056@976660
HLS_540.ts
#EXTINF:5,
#EXT-X-BYTERANGE:891496@1984716
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1045468@2876212
HLS_540.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1080248@3921680
HLS_540.ts
#EXTINF:5,
#EXT-X-BYTERANGE:855588@5001928
HLS_540.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
#EXT-X-BYTERANGE:1315812@0
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1235724@1315812
HLS_576.ts
#EXTINF:5,
#EXT-X-BYTERANGE:1203388@2551536
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1506632@3754924
HLS_576.ts
#EXTINF:6,
#EXT-X-BYTERANGE:1222188@5261556
HLS_576.ts
#EXTINF:5,
#EXT-X-BYTERANGE:1365820@6483744
HLS_576.ts
#EXT-X-ENDLIST
fent commented
dupe of #28
the url given is a master m3u8 playlist. to download the videos listed in that playlist, you'll have to pick one and give it to m3u8stream directly.
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="0",NAME="audio 0",AUTOSELECT=YES,DEFAULT=YES,URI="HLS_AUDIO_64_K.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="1",NAME="audio 1",AUTOSELECT=YES,DEFAULT=YES,URI="HLS_AUDIO_160_K.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=365000,AVERAGE-BANDWIDTH=347000,RESOLUTION=400x226,CLOSED-CAPTIONS=NONE,CODECS="avc1.42001e,mp4a.40.2",AUDIO="0"
HLS_224.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=578000,AVERAGE-BANDWIDTH=548000,RESOLUTION=480x270,CLOSED-CAPTIONS=NONE,CODECS="avc1.42001e,mp4a.40.2",AUDIO="0"
HLS_270.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1009000,AVERAGE-BANDWIDTH=950000,RESOLUTION=640x360,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001e,mp4a.40.2",AUDIO="0"
HLS_360.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1512000,AVERAGE-BANDWIDTH=1435000,RESOLUTION=960x540,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="0"
HLS_540.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2134000,AVERAGE-BANDWIDTH=1900000,RESOLUTION=1024x576,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="0"
HLS_576.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=460000,AVERAGE-BANDWIDTH=444000,RESOLUTION=400x226,CLOSED-CAPTIONS=NONE,CODECS="avc1.42001e,mp4a.40.2",AUDIO="1"
HLS_224.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=673000,AVERAGE-BANDWIDTH=645000,RESOLUTION=480x270,CLOSED-CAPTIONS=NONE,CODECS="avc1.42001e,mp4a.40.2",AUDIO="1"
HLS_270.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1104000,AVERAGE-BANDWIDTH=1047000,RESOLUTION=640x360,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001e,mp4a.40.2",AUDIO="1"
HLS_360.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1607000,AVERAGE-BANDWIDTH=1532000,RESOLUTION=960x540,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="1"
HLS_540.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2229000,AVERAGE-BANDWIDTH=1997000,RESOLUTION=1024x576,CLOSED-CAPTIONS=NONE,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="1"
HLS_576.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=36740,AVERAGE-BANDWIDTH=24117,RESOLUTION=400x226,CODECS="avc1.42001e",URI="HLS_224-iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=54143,AVERAGE-BANDWIDTH=37578,RESOLUTION=480x270,CODECS="avc1.42001e",URI="HLS_270-iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=103776,AVERAGE-BANDWIDTH=70727,RESOLUTION=640x360,CODECS="avc1.4d001e",URI="HLS_360-iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=146962,AVERAGE-BANDWIDTH=109840,RESOLUTION=960x540,CODECS="avc1.4d001f",URI="HLS_540-iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=204042,AVERAGE-BANDWIDTH=135711,RESOLUTION=1024x576,CODECS="avc1.4d001f",URI="HLS_576-iframe.m3u8"
changing the url to the following will download the first listed stream
const fs = require('fs')
const m3u8stream = require('m3u8stream')
const res = m3u8stream('https://v.redd.it/uag4uw003od51/HLS_224.m3u8').pipe(
fs.createWriteStream('videofile.mp4'),
)
I agree that this is unintuitive. there are plans to have m3u8stream pick the first option for you from master playlists if none is given.