Closed ralyodio closed 8 years ago
Here's an example stream:
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/master.m3u8
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=563000,RESOLUTION=1280x720,CODECS="avc1.77.30, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_400_av-p.m3u8?sd=10&rebase=on
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=432000,RESOLUTION=428x240,CODECS="avc1.640029, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_400_av-b.m3u8?sd=10&rebase=on
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=827000,RESOLUTION=1280x720,CODECS="avc1.77.30, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_700_av-p.m3u8?sd=10&rebase=on
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=732000,RESOLUTION=428x240,CODECS="avc1.640029, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_700_av-b.m3u8?sd=10&rebase=on
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2128000,RESOLUTION=1280x720,CODECS="avc1.77.30, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_1000_av-p.m3u8?sd=10&rebase=on
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2064000,RESOLUTION=1280x720,CODECS="avc1.640029, mp4a.40.2"
http://nasatv-lh.akamaihd.net/i/NASA_101@319270/index_1000_av-b.m3u8?sd=10&rebase=on
I've noticed some streams have both bandwidth and resolution, others have one or the either, and sometimes neither.
For when its defined, I would like to be able to pass in 'best' or resolution,bandwidth similar to how livestreamer does it.
I've decided to just save the playlist locally and parse it from the file system.
If anybody needs to do this and doesn't have the option of saving the playlist locally first, I found that you can parse the remote file using the Needle HTTP client (or another client that supports piping to a stream):
const m3u8 = require('m3u8');
const needle = require('needle');
const parser = m3u8.createStream();
parser.on('item', function(item) {
// emits PlaylistItem, MediaItem, StreamItem, and IframeStreamItem
});
parser.on('m3u', function(m3u) {
// fully parsed m3u file
});
needle.get('http://url.m3u8').pipe(parser);
I'd like to parse a remote playlist for a stream that matches a specific bandwidth and/or resolution
Given http://remote-cdn/index.m3u8
I'd like to be able to search by BANDWIDTH or RESOLUTION