chrisyue / php-m3u8 Goto Github PK
View Code? Open in Web Editor NEWAn M3U8 parser / dumper in PHP.
License: MIT License
An M3U8 parser / dumper in PHP.
License: MIT License
I have a shared server
How can i download and use it without composer?
解析以后,所有的mediaSegments内的元素属性都是只读的,比如Inf标签,我想遍历这些元素,找出Inf标签的CCTV-1的TITLE,然后把uri进行修改和替换,貌似做不到。为什么这么设计呢?
如果parse后只能用自定义 dump函数的方法控制输出,我直接按行文本查找都比较快。
我现在自定义了我的Inf标签类,把这些属性都改成可读写了,毕竟我读取列表不是为了只是解析一下然后就dump成文本的。
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
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, 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"
`
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.
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.
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?
M3u8::__construct()
and where?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
时候 取一个绝对路径
Hi, what does dumping do and do you have any method that would add / append new data?
百度了一圈m3u8,没想明白
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
I think Segment is missing setUri function?
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
programmer have always hard time to explain and create a simple demo php file
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
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
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.