Giter Site home page Giter Site logo

easydarwin / easyplayer.js Goto Github PK

View Code? Open in Web Editor NEW
1.6K 44.0 296.0 18.19 MB

EasyPlayer.js H5播放器,是一款免费的能够同时支持HTTP、RTMP、HTTP-FLV、HLS(m3u8)直播与点播等多种协议,支持H.264、H.265、AAC等多种音视频编码格式,支持mse、asm、wasm等多种解码方式,支持Windows、Linux、Android、iOS全平台终端的H5播放器。EasyPlayer.js H5 Player support HTTP/RTMP/HTTP-FLV/HLS(m3u8) live streaming & vod streaming,support H.264/H.265/AAC video & audio codec,support mse/asm/wasm decode mode,support Windows/Linux/Android/iOS platform,EasyPlayer.js uses leading-edge technology.

Home Page: http://www.tsingsee.com/

HTML 85.62% JavaScript 14.38%

easyplayer.js's Introduction

文档

简介

EasyPlayer.js H5播放器,是一款能够同时支持HTTP、HTTP-FLV、HLS(m3u8)、WS、WEBRTC、FMP4视频直播与视频点播等多种协议,支持H.264、H.265、AAC等多种音视频编码格式,支持MSE、WASM、WebCodec等多种解码方式,支持Windows、Linux、Android、iOS全平台终端的H5播放器,使用简单, 功能强大。

功能说明

  • 支持 MSE H264和H265硬解码;
  • 支持 WebCodec H264和H265硬解码;
  • 支持 WASM H264和H265硬解码/软解码;
  • 支持 m3u8/HLS (H265/H265)播放;
  • 支持 Mpeg4格式(H264)播放;
  • 支持 HTTP-FLV/WS-FLV (H265/H265)播放;
  • 支持 HTTP-FMP4/WS-FMP4 (H265/H265)播放;
  • <支持 WEBRTC(easy支持H264/H265、其他流媒体支持H264)播放;
  • 支持 裸流(H264/H265) 播放;
  • 支持 直播和点播播放;
  • 支持 点播多清晰度播放;
  • 支持 全屏或比例显示;
  • 支持 电子放大;
  • 支持 水印(动态水印、幽灵水印);
  • 支持 显示上一个视频最后一帧;
  • 支持 播放器快照截图;
  • 支持 视频录制(WebM格式(音频+视频)、Mp4格式(视频),Flv格式(音频+视频));
  • 支持 超时、断网重连、异常暂停播放等;

案例演示

演示地址: https://www.easydarwin.org/easyplayer.js/index.html

配置属性

参数 说明 类型 默认值
container 播放器容器 - -
decoder wasm解码地址 String -
isResize 是否拉伸 Boolean true
loadingText 加载显示的文字 String 加载中
videoBuffer 加载显设置最小缓冲时长,单位秒,播放器会自动消除延迟。示的文字 Number 1
hasAudio 是否解析音频 Boolean true
useMSE MSE模式 Boolean fasle
useWCS WCS模式 Boolean fasle
useSIMD 强制使用wasm模式 Boolean false
background 视频封面图片 String -
qualityConfig 配置清晰 Array ['普清', '高清', '超清', '4K', '8K']
defaultStreamQuality 默认显示的清晰度,如果不设置,会显示第一个清晰度 String -
isNotMute 是否渲染音频 Boolean false
recordType 视频录制默认mp4格式 String mp4,flv
playbackForwardMaxRateDecodeIFrame 录像倍数 Number -
debug 控制台日志打印 Boolean false
debugLevel 打印日志级别默认warn String debug,warn

事件回调

事件名 说明
play 播放事件
pause 暂时事件
videoInfo 视频信息
audioInfo 音频信息
mute 音频
error 播放异常
kBps 当前网速, 单位KB 每秒1次,
recordEnd 录制结束的事件
recordStart 录制开始的事件
fullscreen 当前是否全屏
streamQualityChange 清晰度回调
playbackSeek 录像时间轴跳转回调
playbackPreRateChange 录像倍数的回调
currentPts 监听当前渲染帧的时间戳(流里面的)

案例

EasyPlayrPro.on('play', function () {
    console.log('play');
})

错误 Type 类型说明

playError = 'playError'/** 播放错误,url 为空的时候,调用 play 方法 */
fetchError = 'fetchError'/** http 请求失败 */
websocketError = 'websocketError'/** websocket 请求失败 */
wasmDecodeError = 'wasmDecodeError'/** wasm 解码失败 */
hlsError = 'hlsError'/** hls 解码失败 */
webrtcError = 'webrtcError'/** webrtc 解码失败 */
webrtcClosed = 'webrtcClosed',/** webrtc 关闭 */
flvDemuxBufferSizeTooLarge = 'flvDemuxBufferSizeTooLarge'/** 缓冲区过大*/
audioChannelError = 'audioChannelError'/** 音频错误*/

EasyPlayrPro.on('error', function (type, msg) {
    console.log('error:', type, msg);
})
// 说明: type为错误类型,msg为错误详情。

方法

方法名 说明 参数
play 播放 'url'
playback 播放录像
pause 暂停播放
isPause 返回是否暂停中状态
setBufferTime 设置最大缓冲时长 1
setVolume 设置音量
getVolume 获取音量
exitFullscreen 退出全屏
mute 静音
cancelMute 取消静音
isMute 返回是否静音
screenshot 获取快照
setFullscreen 全屏(取消全屏)播放视频
setStreamQuality 设置分辨率必须是qualityConfig里面的数据
forward 设置录像倍数
setPlaybackStartTime 设置录像跳转时间/s
getVideoInfo 获取视频信息
getAudioInfo 获取音频信息
destroy 关闭视频,释放底层资源

screenshot 截图,调用后弹出下载框保存截图

filename: 可选参数, 保存的文件名, 默认 时间戳
format : 可选参数, 截图的格式,可选png或jpeg或者webp ,默认 png
quality: 可选参数, 当格式是jpeg或者webp时,压缩质量,取值0 ~ 1 ,默认 0.92
type: 可选参数, 可选download或者base64或者blob,默认download

案例:

const base64 = EasyPlayerPro.screenshot("test", "png", 0.5, 'base64')

更多流媒体音视频资源

EasyDarwin开源流媒体服务器:www.EasyDarwin.org

easyplayer.js's People

Contributors

babosa avatar cuixu1987 avatar itsujingli avatar likeadust avatar taoist-yang avatar xiaolebailetu 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  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

easyplayer.js's Issues

报错

视频流服务关闭报这个错误。能不弹出alart框。影响用户体验。

1603177650408
Console 信息
UnityLoader.js:3 Invoking error handler due to
Uncaught TypeError: Cannot read property 'currentSpeed' of null

在某些云平台的视频,流地址和拉取的ts分片地址不一致,downloadWorker在拼接uri和baseurl时就无法得到ts分片的真实地址

web如何播放海康的h265摄像头

测试环境是海康的h265摄像头,推流到nginx转flv,然后浏览器上没有图像,但是好像有数据接收到,看到一些信息如下:
[MSEController] MediaSource onSourceOpen
[FLVDemuxer] Parsed OnMetaData
[FLVDemuxer] Parsed AVCDecoderConfigurationRecord
[FLVDemuxer] Video resolution:1280*720
[MSEController] Received Initialization Segment,mimeType: video/mp4;codecs=avc1.4d001f
然后一直就是
InitialMetadataDiapatehed fail
InitialMetadataDiapatehed fail

不支持rtmp格式

这个略坑,明明不支持rtmp格式,开篇介绍却说支持。实际测试并不支持、、、蛋蛋的忧伤啊

VM242:40534 Uncaught TypeError: c.vjs_snap is not a function

将easyplayer 放于 dialog中,dialog 关闭后报 “VIDEOJS: ERROR: TypeError: this.el_.vjs_getProperty is not a function ”;

再次打开dialog 点击截图时 报错:“VM242:40534 Uncaught TypeError: c.vjs_snap is not a function”

H265音视频不同步

我试了去推本地的H265 aac的mp4,然后用这个去拉播放没有问题。但是转推rtsp alaw的实时流为rtmp aac,然后去拉就出现音视频不同步的问题,直接去推本地h265 aac的flv再拉也是音视频不同步,是声音不对。

265-Hls 会出现播放非常卡顿的现象

我们用海康的摄像头进行推流,测试发现FLV播放正常,但是HLS播放非常卡顿,看控制台现象似乎一直收不到流;
转换测试工具,使用ffplay进行验证,发现播放正常;
这个问题会是什么情况导致的?

videojs流畅播放,easy卡的一比

rtmp
videojs流畅播放,easy卡的一比

videojs卡在第一帧的,easy能播,还是卡的一比

rtmp://140.206.75.44:1935/live/pag/10.33.71.10/7302/881b18264d2b4770a55ca3bb932cc8d6/0/SUB/TCP

不能播放rtmp,

rtmp://58.200.131.2:1935/livetv/hunantv 这个rtmp地址,播放不了,但是vlc可以播放

Legacy分支无法播放H265, EasyPlayer-RTMP客户端可以播放

你好,
我用ffmpeg进行RTSP拉流,然后推到nginx-rtmp上, EasyPlayer-RTMP客户端是可以播放的, 但是网页版EasyPlayer.js不能播放, rtmp,flv,m3u8都不能播放, 请帮忙分析下原因,谢谢。 ffmpeg命令如下:
./ffmpeg -i rtsp://admin:[email protected]:554/Streaming/Channels/101 -c:v copy -c:a copy -f flv rtmp://192.168.33.243:51935/live/h265

网页端现象是: 播放rtmp没反应, 播放flv一直pending, 播放m3u8一直显示加载中。。

文件没音频不能播放

flv文件,只有视频没有音频。播放提示失败。
音频不识别,播放也失败。
音频aac 视频h264 播放成功,但是卡顿严重。
怎么改善?

現在最新版無法撥放

幾個月前使用EasyPlayer-element.min.js正常
現在抓最新的版本使用同樣的代碼沒有畫面 但是flv有在傳輸
稍微試了試 好像抱怨無法識別video/x-flv的樣子 對前端不是很了解 僅供參考
EasyPlayer-element.min.js跟vue cli3建構的EasyPlayer-lib.min.js都相同的問題

<!DOCTYPE html>
<html>
<head>
  <title>player</title>
  <meta charset="utf-8" />
  <script src="js/vue.min.js"></script>
  <script src="./EasyPlayer-element.min.js"></script>
</head>

<body>
  <div id="app" style="width: 100%; height: 100%">
    <easy-player
      :video-url="url"
      :video-title="title"
      live="true"
      stretch="true"
      show-custom-button="false"
      hasvideo="true"
      hasaudio="false"
    ></easy-player>
  </div>
</body>

<script>
new Vue({
  el: '#app',
  data: {
    url: '',
    title: '',
  },

  created() {
    let urlParams = new URLSearchParams(window.location.search)
    this.title = urlParams.get('title')
    this.url = urlParams.get('url')
  }
})
</script>
</html>

H.265 播放报错,Hls 和 http-flv 两种方式都出错

使用Hls方式拉流 报
Uncaught TypeError: Cannot read property 'segments' of undefined

使用Flv 的方式报
EasyPlayer-lib.min.js:1 Uncaught Error: Uncaught, unspecified "error" event. (MediaError)
at n.emit (EasyPlayer-lib.min.js:1)
at n. (EasyPlayer-lib.min.js:1)
at n.emit (EasyPlayer-lib.min.js:1)

播放H264的视频流正常

No sound on iOS with FLV input.

Hi,

we are having an issue where an FLV stream has no sound on iOS - I guess this is due to the fallback of software decoders since Safari on iOS does not support mse. Since this is as far as I understand an open project, is there a chance to get sources of the player and of libDecode, to understand what is going on? Or is that part proprietary and you do not plan to publish that so that others can debug and investigate?

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.