Coder Social home page Coder Social logo

php-m3u8's People

Contributors

chrisyue avatar junglegenius avatar m1ch3lp3r3z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-m3u8's Issues

希望可以支援双语(多语)结构的 M3U8 格式

您好,最近有个 HLS 反代的需求需要用到您的库,使用中发现索引中的多条(音、字幕)轨只能被识别到最后一条。

image
(原始 M3U8 索引文件)

image
(Parse 后的数组,只匹配了最后一个 EXT-X-MEDIA 数据)

兼容解析 media playlist 标签写在 media segment 标签之后的非标准 M3u8 内容

大大您好,我又来提 BUG 了…

这次发现的问题是 DumperFacade 组件在利用 dump() 方法生成播放列表的时候,会把原列表上的 EXT-X-MEDIA-SEQUENCE 字段无视掉,这个参数对于直播来说非常重要。如果该字段丢失,会令播放器出现断流的问题。

image
(原始播放列表)

image
(经过 Parse 后再重新生成的播放列表,可以看到 EXT-X-MEDIA-SEQUENCE 字段被舍弃了)

现在的设计,解析之后没有办法对元素标签进行属性修改,只能dump的时候做各种拼装

解析以后,所有的mediaSegments内的元素属性都是只读的,比如Inf标签,我想遍历这些元素,找出Inf标签的CCTV-1的TITLE,然后把uri进行修改和替换,貌似做不到。为什么这么设计呢?
如果parse后只能用自定义 dump函数的方法控制输出,我直接按行文本查找都比较快。
我现在自定义了我的Inf标签类,把这些属性都改成可读写了,毕竟我读取列表不是为了只是解析一下然后就dump成文本的。

PHP 8.1 error

During inheritance of Iterator: Return type of Chrisyue\PhpM3u8\Line\Lines::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Could not install using Composer.

I am getting the following error:

composer require 'chrisyue/php-m3u8'

[InvalidArgumentException]
Could not find package 'chrisyue/php-m3u8' at any version for your minimum-
stability (stable). Check the package spelling or your minimum-stability
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest]
[--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--
ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|
--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<
packages>]...

Resolution is blank

Resolution is blank, please fix it.

`#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=370227,RESOLUTION=640x360,FRAME-RATE=30.000,CODECS="avc1.64081e,mp4a.40.2"
http://localhost/test/hls/tysxew4gws66j6cdabtr7scwfkcyox6jz46ae5kir2gbfkrlh5wt233mbmda/index-v1-a1.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1399956,RESOLUTION=1920x1080,FRAME-RATE=23.974,CODECS="avc1.640032,mp4a.40.2"
http://localhost/test/hls/tysxew4gws66j6cdabtr7scwfkcyox6jz46ae5kiranbhkrlh5w3igq4x4ca/index-v1-a1.m3u8

#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=45881,RESOLUTION=640x360,CODECS="avc1.64081e",URI="http://localhost/test/hls/tysxew4gws66j6cdabtr7scwfkcyox6jz46ae5kir2gbfkrlh5wt233mbmda/iframes-v1-a1.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=166687,RESOLUTION=1920x1080,CODECS="avc1.640032",URI="http://localhost/test/hls/tysxew4gws66j6cdabtr7scwfkcyox6jz46ae5kiranbhkrlh5w3igq4x4ca/iframes-v1-a1.m3u8"
`

Byterange class on resources files

Some resources files trying use Byterange from Tag:

use Chrisyue\PhpM3u8\Data\Value\Tag\Byterange;

files:
resources/tagValueParsers.php
resources/attributeValueParsers.php

The namespace for Byterange is Value.

Duration in #EXTINF should allow to equal 0 Described in RFC 8216

https://tools.ietf.org/html/rfc8216#section-4.3.2.1

...
duration is a decimal-floating-point or decimal-integer number
(as described in Section 4.2) that specifies the duration of the
Media Segment in seconds.
...

https://tools.ietf.org/html/rfc8216#section-4.2

decimal-integer: an unquoted string of characters from the set
[0..9] expressing an integer in base-10 arithmetic in the range
from 0 to 2^64-1 (18446744073709551615). A decimal-integer may be
from 1 to 20 characters long.

[version 2.3.1] EXT-X-MEDIA parser support.

I know that tag EXT-X-MEDIA is not ready in version 2.3.1, but i want to get it done by myself.
But where is the best place shoud I put my code in the php-m3u8 library?

  • Place in M3u8::__construct() and where?
  • Place in Segment::__construct() and where?

我想了半天 他确实没有这个

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:1614843567
#EXT-X-TARGETDURATION:4
#EXTINF:3.008,
emhFT1paQjRkU291XzE=_orig-1614843567.ts
#EXTINF:3.008,
emhFT1paQjRkU291XzE=_orig-1614843568.ts
#EXTINF:3.008,
emhFT1paQjRkU291XzE=_orig-1614843569.ts

就是 获取 hls 时候 取一个绝对路径

Dumping

Hi, what does dumping do and do you have any method that would add / append new data?

duration should be greater than 0

A lot of m3u/m3u8 lists have a duration of -1. Your script checks if duration is <= 0 and throws an error.

InvalidArgumentException
$duration should be greater than 0

incorrect comment recognize against RFC 8216

https://tools.ietf.org/html/rfc8216#section-4.1

Lines that start with the character '#' are either comments or tags.
Tags begin with #EXT. They are case sensitive. All other lines that
begin with '#' are comments and SHOULD be ignored.

This test case will fail

<?php

use Chrisyue\PhpM3u8\Facade\DumperFacade;
use Chrisyue\PhpM3u8\Facade\ParserFacade;
use Chrisyue\PhpM3u8\Stream\TextStream;

require 'vendor/autoload.php';

$parser = new ParserFacade();
$dumper = new DumperFacade();

echo '*** Parsing media playlist... ***', PHP_EOL;

$m3u8Content = <<<'M3U8'
#EXTM3U 

#EXTINF:2,CCTV-1(高清)
rtp://239.45.3.145:5140

###EXTINF:2,这是应该被当做一行注释忽略 this line should be ignored as a comment as RFC 8216

#
#The Above line should also be a valid comment
M3U8;

$mediaPlaylist = $parser->parse(new TextStream($m3u8Content));

var_export($mediaPlaylist);
echo PHP_EOL;

echo '*** Dumping media playlist... ***', PHP_EOL;
$text = new TextStream();
$dumper->dump($mediaPlaylist, $text);

echo $text, PHP_EOL;
** Dumping media playlist... ***
*** Parsing media playlist... ***
PHP Fatal error:  Uncaught Error: Call to a member function isType() on null in /home/ihipop/Desktop/udpxy-src/test/vendor/chrisyue/php-m3u8/src/Parser/Parser.php:38
Stack trace:
#0 /home/ihipop/Desktop/udpxy-src/test/vendor/chrisyue/php-m3u8/src/Facade/ParserFacade.php(38): Chrisyue\PhpM3u8\Parser\Parser->parse(Object(Chrisyue\PhpM3u8\Line\Lines))
#1 /home/ihipop/Desktop/udpxy-src/test/dump2.php(26): Chrisyue\PhpM3u8\Facade\ParserFacade->parse(Object(Chrisyue\PhpM3u8\Stream\TextStream))
#2 {main}
  thrown in /home/ihipop/Desktop/udpxy-src/test/vendor/chrisyue/php-m3u8/src/Parser/Parser.php on line 38

Nothing work

programmer have always hard time to explain and create a simple demo php file

When parsing the manifest file, I get the Exception "$ offset should be an integer greater than 0".

When I wrote the code according to the implementation example of READEME, the following Exception occurred.

[App\Exceptions\Handler] InvalidArgumentException: $offset should be an integer greater than 0 in /var/www/mgsplayer_api/vendor/chrisyue/php-m3u8/src/Data/Value/Tag/Byterange.php:33

The master manifest can be parsed without any problems, but only the media manifest has an Exception.
Do you know what caused it?

The following is a partial excerpt of the contents of the manifest file that is about to be parsed.

#EXTM3U
#EXT-X-VERSION:5
#EXT-X-TARGETDURATION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="***"
#EXTINF:6.006,
#EXT-X-BYTERANGE:300800@0
***_6000.ts
#EXTINF:6.006,
#EXT-X-BYTERANGE:335204@300800
***_6000.ts
  • version : "chrisyue/php-m3u8": "^3"

When parsing master.m3u8, provide full path to stream playlists

When parsing a master.m3u8 in some sub directory, this library returns the URIs of sub-streams as-is. Which means they can be relative to the directory where the master.m3u8 is located. It would be great if there was a property that gives the full path to the sub-stream. E.g.:

$master = $parser->parse(new FileStream('../download/master.m3u8'));
print_r($master['EXT-X-STREAM-INF'][0]);

This currently just returns:

[uri] => playlist-1280.m3u8

So I have to figure out myself that this is relative to ../download/.

I'd like to have it also spit out e.g.:

[uri] => playlist-1280.m3u8
[filepath] => ../download/playlist-1280.m3u8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.