All Projects → carlanton → m3u8-parser

carlanton / m3u8-parser

Licence: MIT License
A simple HLS playlist parser for Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to m3u8-parser

aws-clustered-video-streams
A clustered video stream is an AWS architecture that increases the quality and reliability of live events by providing seamless regional failover capabilities for live video steams. Operators can monitor the status of the clustered stream from a single pane of glass and dynamically control from which region the stream consumed by a player origin…
Stars: ✭ 35 (-65%)
Mutual labels:  hls, hls-live-streaming
cassandra-nginx-cdn
Some config files and POC code to use Apache Cassandra as distributed storage for HLS chunks accross multiple datacenters and scripts for converting/transcoding UDP MPEG-TS to HLS and vice versa. The idea is take from Globo.com’s Live Video Platform for FIFA World Cup ’14.
Stars: ✭ 24 (-76%)
Mutual labels:  hls, hls-live-streaming
hls-live-thumbnails
A service which will generate thumbnails from a live HLS stream.
Stars: ✭ 49 (-51%)
Mutual labels:  hls, hls-live-streaming
lhls-simple-live-platform
Very simple low latency live platform prototype
Stars: ✭ 57 (-43%)
Mutual labels:  hls, hls-live-streaming
srt2hls
Simple audio HLS streaming server based on Liquidsoap
Stars: ✭ 66 (-34%)
Mutual labels:  hls, hls-live-streaming
orcanode
Software for live-streaming and recording lossy or lossless compressed audio (HLS, DASH, FLAC) via AWS S3 buckets. ⭐
Stars: ✭ 23 (-77%)
Mutual labels:  hls, hls-live-streaming
tms
tms(toy media server) is a toy media server for myself learning media develop. Just for fun.
Stars: ✭ 29 (-71%)
Mutual labels:  hls, hls-live-streaming
nott
The New OTT Platform - an excuse to discuss and design a simple edge computing platform
Stars: ✭ 46 (-54%)
Mutual labels:  hls
vidi
<video> playback simplified
Stars: ✭ 31 (-69%)
Mutual labels:  hls
YoutubeSpotifyDL
Youtube and Spotify music downloader with metadata.
Stars: ✭ 66 (-34%)
Mutual labels:  playlists
hls m3u8
HLS(RFC8216) m3u8 parser/generator
Stars: ✭ 40 (-60%)
Mutual labels:  hls
m3u8
Parse and generate m3u8 playlists for Apple HTTP Live Streaming (HLS) in Ruby.
Stars: ✭ 96 (-4%)
Mutual labels:  hls
wsa
WSA(Websocket Streaming Agent) is a stream server target for mp4/h264 streaming over websocket
Stars: ✭ 35 (-65%)
Mutual labels:  hls
browserLiveStream
Use webcam, browser and Node to stream live video. From api.video (https://api.video)
Stars: ✭ 141 (+41%)
Mutual labels:  hls
scalehls
A scalable High-Level Synthesis framework on MLIR
Stars: ✭ 62 (-38%)
Mutual labels:  hls
cordova-plugin-tencent-liteav
A cordova plugin for video playing with Tencent's LiteAV SDK. Support RTMP/HLS/FLV/MP4.
Stars: ✭ 24 (-76%)
Mutual labels:  hls
hwt
VHDL/Verilog/SystemC code generator, simulator API written in python/c++
Stars: ✭ 145 (+45%)
Mutual labels:  hls
leftry
Leftry - A left-recursion enabled recursive-descent parser combinator library for Lua.
Stars: ✭ 32 (-68%)
Mutual labels:  parsers
kaltura-player-js
Kaltura Player JS Platform - Cloud TV and OVP Media Players
Stars: ✭ 83 (-17%)
Mutual labels:  hls
sms
rtmp server and super media server whith golang.
Stars: ✭ 65 (-35%)
Mutual labels:  hls

m3u8-parser

Build Status Maven Central Javadocs

A simple HLS playlist parser for Java.

The goal of this project was to implement parsers and a consistent Java object model according to RFC 8216 HTTP Live Streaming.

This parser is very similar to iHeartRadio's open-m3u8. The main differences are:

  • m3u8-parser does not try to validate playlists. You are responsible for creating valid playlists.
  • m3u8-parser uses java.util.Optional instead of null.
  • m3u8-parser uses Immutables to generate all builders.
  • The parser objects are thread safe & reusable and could be used as a singleton (like Jackson's ObjectMapper).
  • m3u8-parser requires Java 8 or later.

Artifacts

Maven:

<dependency>
    <groupId>io.lindstrom</groupId>
    <artifactId>m3u8-parser</artifactId>
    <version>0.22</version>
</dependency>

Gradle:

implementation 'io.lindstrom:m3u8-parser:0.22'

Usage

Create master playlist

MasterPlaylist playlist = MasterPlaylist.builder()
    .version(4)
    .independentSegments(true)
    .addAlternativeRenditions(AlternativeRendition.builder()
        .type(MediaType.AUDIO)
        .name("Default audio")
        .groupId("AUDIO")
        .build())
    .addVariants(
        Variant.builder()
            .addCodecs("avc1.4d401f", "mp4a.40.2")
            .bandwidth(900000)
            .uri("v0.m3u8")
            .build(),
        Variant.builder()
            .addCodecs("avc1.4d401f", "mp4a.40.2")
            .bandwidth(900000)
            .uri("v1.m3u8")
            .resolution(1280, 720)
            .build())
    .build();

MasterPlaylistParser parser = new MasterPlaylistParser();
System.out.println(parser.writePlaylistAsString(playlist));

This code should produce the following master playlist:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="AUDIO",NAME="Default audio"
#EXT-X-STREAM-INF:BANDWIDTH=900000,CODECS="avc1.4d401f,mp4a.40.2"
v0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=900000,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=1280x720
v1.m3u8

Create media playlist

MediaPlaylist mediaPlaylist = MediaPlaylist.builder()
    .version(3)
    .targetDuration(10)
    .mediaSequence(1)
    .ongoing(false)
    .addMediaSegments(
        MediaSegment.builder()
            .duration(9.009)
            .uri("http://media.example.com/first.ts")
            .build(),
        MediaSegment.builder()
            .duration(9.009)
            .uri("http://media.example.com/second.ts")
            .build(),
        MediaSegment.builder()
            .duration(3.003)
            .uri("http://media.example.com/third.ts")
            .build())
    .build();

MediaPlaylistParser parser = new MediaPlaylistParser();
System.out.println(parser.writePlaylistAsString(mediaPlaylist));

This code should produce the following media playlist:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:9.009,
http://media.example.com/first.ts
#EXTINF:9.009,
http://media.example.com/second.ts
#EXTINF:3.003,
http://media.example.com/third.ts
#EXT-X-ENDLIST

Parse master playlist

MasterPlaylistParser parser = new MasterPlaylistParser();

// Parse playlist
MasterPlaylist playlist = parser.readPlaylist(Paths.get("path/to/master.m3u8"));

// Update playlist version
MasterPlaylist updated = MasterPlaylist.builder()
                                        .from(playlist)
                                        .version(2)
                                        .build();

// Write playlist to standard out
System.out.println(parser.writePlaylistAsString(updated));

Parse media playlist

MediaPlaylistParser parser = new MediaPlaylistParser();

// Parse playlist
MediaPlaylist playlist = parser.readPlaylist(Paths.get("path/to/media-playlist.m3u8"));

// Update playlist version
MediaPlaylist updated = MediaPlaylist.builder()
                                     .from(playlist)
                                     .version(2)
                                     .build();

// Write playlist to standard out
System.out.println(parser.writePlaylistAsString(updated));

Parsing mode

By default, the parser will throw an exception on unsupported tags and attributes. This can be configured by passing a ParsingMode to the parser. Example:

MasterPlaylistParser lenientParser = new MasterPlaylistParser(ParsingMode.LENIENT);

Currently two modes are available:

ParsingMode.STRICT   // fail on unsupported things (this is default)
ParsingMode.LENIENT  // ignore unsupported things

Supported tags

The following tags should be fully supported:

EXTM3U
EXT-X-VERSION
EXTINF
EXT-X-BYTERANGE
EXT-X-DISCONTINUITY
EXT-X-KEY
EXT-X-MAP
EXT-X-PROGRAM-DATE-TIME
EXT-X-TARGETDURATION
EXT-X-MEDIA-SEQUENCE
EXT-X-ENDLIST
EXT-X-PLAYLIST-TYPE
EXT-X-I-FRAMES-ONLY
EXT-X-MEDIA
EXT-X-STREAM-INF
EXT-X-I-FRAME-STREAM-INF
EXT-X-INDEPENDENT-SEGMENTS
EXT-X-START
EXT-X-ALLOW-CACHE
EXT-X-SESSION-DATA
EXT-X-SESSION-KEY
EXT-X-DISCONTINUITY-SEQUENCE
EXT-X-DATERANGE

EXT-X-DEFINE
EXT-X-GAP
EXT-X-BITRATE
EXT-X-SERVER-CONTROL

EXT-X-PART
EXT-X-PRELOAD-HINT
EXT-X-RENDITION-REPORT
EXT-X-SKIP
EXT-X-PART-INF

EXT-X-CUE-OUT:<duration>
EXT-X-CUE-IN

The following tags are currently not implemented:

Android

This library uses java.time.* which requires core library desugaring when running on Android API level < 26.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].