iheartradio / open-m3u8 Goto Github PK
View Code? Open in Web Editor NEWOpen Source m3u8 Parser
License: Other
Open Source m3u8 Parser
License: Other
To allow simplify life for callers of the library, hashCode()
and equals()
should be implemented.
When writing a playlist, EXT-X-ENDLIST tag is always appended at the end. In progress playlists can have files appended as they become available.
Hi,
I'm very interested in your library, and was wondering if there are plans for supporting custom EXT-X tags. I'm specifically interested in the EXT-X-CUE tags for scte-35 markers, which are not in the pantos spec, but which the industry widely supports. Alternatively, Pantos just introduced the EXT-X-DATERANGE tag with their newest version: https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.2.7.1
which essentially adds this functionality. If this is on your roadmap, I'd love to know!
I've observed spaces in generated m3u8 from CDNs for these tags. Note the space after colon. Do we need to handle this as part of library? Spec doesn't say whether space is allowed.
should be #EXT-X-TARGETDURATION:<s> but seen as #EXT-X-TARGETDURATION: <s>
should be #EXT-X-MEDIA-SEQUENCE:<number> but seen as #EXT-X-MEDIA-SEQUENCE: <number>
For now I've handled with below change in Constants.java.
public static final Pattern EXT_X_TARGETDURATION_PATTERN = Pattern.compile("^#" + EXT_X_TARGETDURATION_TAG + EXT_TAG_END + OPTIONAL_WHITESPACE_REGEX +"(" + INTEGER_REGEX + ")"+OPTIONAL_WHITESPACE_REGEX+"$");
public static final Pattern EXT_X_MEDIA_SEQUENCE_PATTERN = Pattern.compile("^#" + EXT_X_MEDIA_SEQUENCE_TAG + EXT_TAG_END + OPTIONAL_WHITESPACE_REGEX +"(" + INTEGER_REGEX + ")"+OPTIONAL_WHITESPACE_REGEX+"$");
Where regex for optional white space is as below
private static final String OPTIONAL_WHITESPACE_REGEX = "\\s*?";
Let me know if this makes sense. There is no harm if no spaces exist. regex takes care of that case too.
I came across situation where one of the m3u8 had tag EXT-X-PROGRAM-DATE-TIME which is part of spec [https://tools.ietf.org/html/draft-pantos-http-live-streaming-16#section-4.3.2.6]
Since library is not complete it ends up throwing exception. Adding parsing for all such tags is going to take a while. Till then is there better alternative than throwing exception?
Can one bypass that [through config maybe]? Can you help with example of LENIENT mode.
Here us sample m3u8 which fails to parse
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:11
#EXT-X-PROGRAM-DATE-TIME:1970-01-01T00:00:00Z
#EXTINF:10.010010,no-desc
Fragments(video=0,format=m3u8-aapl-v3,audiotrack=aac_UND_2_127)
#EXTINF:10.010010,no-desc
Fragments(video=100100100,format=m3u8-aapl-v3,audiotrack=aac_UND_2_127)
#EXTINF:10.010010,no-desc
Fragments(video=200200200,format=m3u8-aapl-v3,audiotrack=aac_UND_2_127)
#EXTINF:10.010010,no-desc
Fragments(video=300300300,format=m3u8-aapl-v3,audiotrack=aac_UND_2_127)
The specification has an EXT-X-ENDLIST tag which delimits the end of a playlist. The parser should stop reading from the InputStream when this tag is detected and return the parsed playlist.
In both cases of EXT-X-ENDLIST or reaching the end of the InputStream, the parser should not close the InputStream. This is to support reading multiple playlists from a single stream and to not violate the principle of least astonishment.
Parsing the file with:
PlaylistParser parser = new PlaylistParser();
Playlist playlist = parser.parse(inputStream, Format.EXT_M3U, Extension.M3U8);
causes ParseException
with message: "invalid attribute name: EXT-X-STREAM-INF - #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=101485, RESOLUTION=140x80"
m3u8 file content is:
50k.mp4/chunk.m3u8
100k.mp4/chunk.m3u8
200k.mp4/chunk.m3u8
400k.mp4/chunk.m3u8
900k.mp4/chunk.m3u8
What should I do then?
It should be possible to specify encryption data for each track data in a playlist and not just for the entire playlist
Create a way to specify lenient mode which ignores unsupported tags rather than throwing an exception.
Please checkout below 2 lines from the constructor of com.iheartradio.m3u8.data.MasterPlaylist.
mPlaylists = playlists == null ? Collections.emptyList() : Collections.unmodifiableList(playlists);
mIFramePlaylists = playlists == null ? Collections.emptyList() : Collections.unmodifiableList(iFramePlaylists);
If one forgets to add IFrameStreamInfo list while creating MasterPlaylist. It throws runtime NPE
Trying to parse a m3u8 playlist using library, but exception thrown
com.iheartradio.m3u8.ParseException: bad format found for an EXT tag: EXTINF - #EXTINF:-1 tvg-logo="http://some_url.com/logo.png" group-title="INFO",* test IPTV
#EXTINF:-1 tvg-logo="http://some_url.com/logo.png" group-title="INFO",* test IPTV
I am using Linent mode
I'm having trouble getting encryption part to work.
#EXT-X-KEY:METHOD=AES-128,URI="https://domain/plist/Cn4/3/d628933e949ed2285c1a8abb1573c66/47406/index.key"
But when I tried generating same playlist with open-m3u8 I could not get it to play.
I've used #EXT-X-KEY:KEYFORMATVERSIONS="1" and KEYFORMAT="identity".
Thanks.
An application I made that uses open-m3u8 has a section where it reads a playlist then creates a new one based on edited values in the original list. I noticed the original playlist didn't have the attributes KEYFORMATVERSIONS and KEYFORMAT. But the new one has the attributes with their default values.
I read the specification "HTTP Live Streaming draft-pantos-http-live-streaming-16". It states in there that these two attributes are optional and their omission means the default values will be assumed. So newly created playlists don't need to include these unless their values are non-default.
So I was wondering if this behavior would be desired (new playlists won't include these attributes unless they were specified before or their values are non-default). If so I'll try to work on it in a new fork.
This isn't an important issue nonetheless. The rewritten playlist with these two attributes included worked fine.
I faced the case when a duration in EXTINF tag was given as negative integer (-1), because it was a list of infinite audio streams.
(Here the link to the M3U list of the internet radio: http://promodj.com/radio/channels-hq.m3u)
#EXTM3U
#EXTINF:-1,TOP 100
http://radio.promodj.com:8000/top100-192
#EXTINF:-1,Channel 5
http://radio.promodj.com:8000/channel5-192
#EXTINF:-1,Klubb
http://radio.promodj.com:8000/klubb-192
So I've got "com.iheartradio.m3u8.ParseException: bad format found for an EXT tag".
Specification talks about positive integers and floating points only, but real life dictates own rules. Maybe it's better just to ignore wrong duration?
Version 0.1.2
H
All EXT-X-MEDIA attributes except CHANNELS seems to be supported.
The specification describes the CHANNELS attribute as following:
CHANNELS
The value is a quoted-string that specifies an ordered,
"/"-separated list of parameters. If the TYPE attribute is AUDIO
then the first parameter is a count of audio channels expressed as
a decimal-integer, indicating the maximum number of independent,
simultaneous audio channels present in any Media Segment in the
Rendition. For example, an AC-3 5.1 rendition would have a
CHANNELS="6" attribute. No other CHANNELS parameters are
currently defined.
All audio EXT-X-MEDIA tags SHOULD have a CHANNELS attribute. If a
Master Playlist contains two renditions encoded with the same
codec but a different number of channels, then the CHANNELS
attribute is REQUIRED; otherwise it is OPTIONAL.
Currently some of the builders perform validation to ensure the data is representative of the specification. The responsibility for validation should be its own component. The builders should only be concerned with building the type.
Because Integer.toHexString
is used negative bytes will be prefixed with ffffff
and bytes between 0 and 15 will only be written as one digit, this causes the IV in the playlist to be corrupt.
final PlaylistParser parser = new PlaylistParser(new FileInputStream(new File(hlsFileAbsolutePath)),Format.EXT_M3U, Encoding.UTF_8);
Playlist playlist = parser.parse();
when parse,throw exception,
unsupported ext tag detected: EXT-QQHLS-PIC-WIDTH - #EXT-QQHLS-PIC-WIDTH:0 i do not know how to solve it
As title, How to create live style playlist? ( without end tag #EXT-X-ENDLIST)
This library is unable to parse m3u file given in link.
Hi,
I created an playlist with this library and enabled the Encoding.UTF8
flag. This playlist works fine in Winamp, but Foobar isn't able to play the UTF8 paths.
After searching on the internet I found a topic talking about the BOM tag (first three bytes of the file: EF BB BF), I tested this with Foobar and it actually works!
Anyway, Am i missing some configuration option or is this missing from the library?
For reference: http://www.hydrogenaud.io/forums/index.php?showtopic=93905
Edit: I temporarily solved it using:
OutputStream outputStream = new FileOutputStream(fullPlayListPath);
PlaylistWriter writer = new PlaylistWriter();
outputStream.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
writer.write(outputStream, playlist, Format.EXT_M3U, Encoding.UTF_8);
Would ofcourse be nicer if the library would take care of this.
When writing a playlist with encryption an exception is thrown if key format or key format versions are unset. These are optional according to the spec and should be left out if not specified.
Currently only 16-octet and 32-octet initialization vectors are allowed. User code should be able to use arbitrarily strong encryption. To that end, initialization vectors should be of variable size.
PlaylistParser parser = new PlaylistParser(inputStream , Format.EXT_M3U, Encoding.UTF_8);
Playlist playlist = parser.parse();
parse() method throw EOFExcention,how can i fix it?
Hi, I just wanted to say thank you for making this library available. It's always nice to see people (especially companies) giving back to the open source community.
I also wanted to let you know that I've forked this project and translated it into C#, targeting .NET Standard 2.0. I've tried to provide attribution and references back to this repository. Feel free to take a look and let me know if you'd like to see any more/different attribution.
https://github.com/bzier/open-m3u8
Thanks again,
-Brian
Please let me know how can i support to version 6?
Hi.
I used this library for a small application I made. The m3u8 files I was downloading had the "ext-x-program-date-time" tag. I added some code so that open-m3u8 supports the tag in strict parsing mode.
I'm not sure how to commit it though. I've never used github. I couldn't find any option to make a new branch or anything. So would anyone help guiding on what I should do next?
Do we have iOS version for the same?
The EXT-X-START is allowed in both master and media playlists:
http://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-4.3.5.2
Currently, the parser will only handle this tag for media playlists. It will actually prevent master playlists from being parsed if it appears in a master playlist.
How can you define a live playlist ? (no #EXT-X-ENDLIST at the end)
Hi.
I've run across a new issue. Maybe just evolution of m3u8 playlists, but a new tag that's not supported.
com.iheartradio.m3u8.ParseException: unsupported ext tag detected: EXT-X-INDEPENDENT-SEGMENTS - #EXT-X-INDEPENDENT-SEGMENTS
at com.iheartradio.m3u8.ParseException.create(ParseException.java:35)
at com.iheartradio.m3u8.ExtendedM3uParser.parse(ExtendedM3uParser.java:66)
at com.iheartradio.m3u8.PlaylistParser.parse(PlaylistParser.java:115)
You can get the playlist that has these tags here.
https://ngcstatpack-a.akamaihd.net/Nat_Geo_Channels/896/599/1509829223445/Long_Road_101_HD_Clean_AUTH_movie.m3u8
I will probably work on integrating this is my clone so if you don't have anything by the time I do I'll post my edits for you.
According to the HLS specification, also linked in the documentation, the FORCED attribute should only be present with subtitles: "The FORCED attribute MUST NOT be present unless the TYPE is SUBTITLES."
https://tools.ietf.org/html/draft-pantos-http-live-streaming-16
However, when writing an m3u8 file, it is present with audio as well:
#EXT-X-MEDIA:LANGUAGE="eng",AUTOSELECT=YES,FORCED=NO,TYPE=AUDIO,URI="...",GROUP-ID="audio_aac",DEFAULT=YES,NAME="eng"
Version: 0.2.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.