Skip to content

Commit

Permalink
别翻啦~我真的没有请假睡一整天~
Browse files Browse the repository at this point in the history
  • Loading branch information
numberwolf committed Jul 4, 2021
1 parent 87dbf34 commit 2799033
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 51 deletions.
16 changes: 14 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@

<img src="./resource/[email protected]" width="300px" />

一个可支持HEVC/H.265编码播放720P、1080P的播放器
`~^_^~` 作者用爱发电 如果 <a href="https://github.com/numberwolf/h265web.js">h265web.js</a> 帮助到了你,请点击右上角的star!
一个可支持HEVC/H.265编码播放360P、480P、540P、720P、1080P的播放器 <a href="https://github.com/numberwolf/h265web.js">h265web.js</a>

| h265web.js | mpeg.js `(解析ts)` | h265web.js 底层265解码器SDK |
| ---- | ---- | ---- |
| [h265web.js](https://github.com/numberwolf/h265web.js) | [MPEG-Demuxer.js](https://github.com/numberwolf/MPEG-Demuxer.js) | [h265web.js-wasm-decoder](https://github.com/numberwolf/h265web.js-wasm-decoder) |

<a href="https://www.gnu.org/licenses/gpl-3.0.md">License GPL-3.0 https://www.gnu.org/licenses/gpl-3.0.md</a>

# Remind!

因为使用软解码能力(浏览器上无法做硬解码加速 与 汇编优化),故设备电脑配置性能 会 影响播放器性能!

请注意:

* 视频帧率最好 <= 30fps
* 建议:24fps

* 视频码率最好 <= 1.5Mb
* 建议:300~600kbps (HEVC/H.265可提供较高的压缩率)

## 目录

Expand Down Expand Up @@ -58,6 +68,8 @@

| 更新日志 | 内容 |
| ---- | ---- |
| 时间 | 2021/07/04 |
| - | 0.修复 <a href="https://github.com/numberwolf/h265web.js/issues/58">`ISSUE#58`</a> (默认内核缓存状态下的暂停问题) |
| 时间 | 2021/07/01 |
| - | 0.增加示例 与 编译所需 |
| 时间 | 2021/06/27 |
Expand Down
18 changes: 17 additions & 1 deletion README_EN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ __`~^_^~ For love` if <a href="https://github.com/numberwolf/h265web.js">h265web
<a href="https://www.gnu.org/licenses/gpl-3.0.md">License GPL-3.0 https://www.gnu.org/licenses/gpl-3.0.md</a>


# Remind!

H265web.js use the soft-decode mode(Can not use hard-decode and assembly-optimization on browers), so your device performance has a large impact on player.

Notice:

* Recommended FPS <= 30fps
* Better: 24fps

* Recommended Bitrate <= 1500kbps
* Better: 300~600kbps



## Index

- [0、README](#0readme)
Expand Down Expand Up @@ -59,7 +73,9 @@ __`~^_^~ For love` if <a href="https://github.com/numberwolf/h265web.js">h265web

| Update | Content |
| ---- | ---- |
| 时间 | 2021/07/01 |
| Time | 2021/07/04 |
| - | 0.Fixed: <a href="https://github.com/numberwolf/h265web.js/issues/58">`ISSUE#58`</a> (When default player-core's status is caching-frames, can not pause video) |
| Time | 2021/07/01 |
| - | 0.Add example and package.json file |
| Time | 2021/06/27 |
| - | 0.Open Source! |
Expand Down
15 changes: 0 additions & 15 deletions dist/h265webjs-v20210627.js

This file was deleted.

17 changes: 17 additions & 0 deletions dist/h265webjs-v20210704.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Github: https://github.com/numberwolf/h265web.js
*
**********************************************************/
require('./h265webjs-v20210627');
require('./h265webjs-v20210704');
export default class h265webjs {
static createPlayer(videoURL, config) {
return window.new265webjs(videoURL, config);
Expand Down
10 changes: 5 additions & 5 deletions example/dist/dist-play.js

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions example/dist/h265webjs-v20210627.js

This file was deleted.

17 changes: 17 additions & 0 deletions example/dist/h265webjs-v20210704.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Github: https://github.com/numberwolf/h265web.js
*
**********************************************************/
require('./h265webjs-v20210627');
require('./h265webjs-v20210704');
export default class h265webjs {
static createPlayer(videoURL, config) {
return window.new265webjs(videoURL, config);
Expand Down
6 changes: 3 additions & 3 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ <h1> h265web.js demo </h1>
var token = "base64:QXV0aG9yOmNoYW5neWFubG9uZ3xudW1iZXJ3b2xmLEdpdGh1YjpodHRwczovL2dpdGh1Yi5jb20vbnVtYmVyd29sZixFbWFpbDpwb3JzY2hlZ3QyM0Bmb3htYWlsLmNvbSxRUTo1MzEzNjU4NzIsSG9tZVBhZ2U6aHR0cDovL3h2aWRlby52aWRlbyxEaXNjb3JkOm51bWJlcndvbGYjODY5NCx3ZWNoYXI6bnVtYmVyd29sZjExLEJlaWppbmcsV29ya0luOkJhaWR1";
var type = "mp4";
var url = "res/video40_265_moov.mp4";
// var url = "res/bd265_540p_20210513165027_.mp4";
// var url = "res/hevc_issue_58.mp4";
// var url = "res/speed_moov.mp4";
// var url = "res/no_formattag_265.mp4";
// var url = "res/06hY38_64_yuvj420p.mp4";
Expand All @@ -210,8 +210,8 @@ <h1> h265web.js demo </h1>
// var type = "ts";
// var url = "res/hls/v-000.ts"

var type = "flv";
var url = "res/video40_265_moov.flv";
// var type = "flv";
// var url = "res/video40_265_moov.flv";

// var type = "hls";
//var url = "res/m3u82/cg720phevc.m3u8";
Expand Down
3 changes: 3 additions & 0 deletions src/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ global.makeH265webjs = (videoURL, config) => {
showLabel.textContent = SHOW_LOADING;

playBar.onclick = () => {
console.log("is playing:", h265webjs.isPlaying());
if (h265webjs.isPlaying()) {
console.log("bar pause============>");
playBar.textContent = '>';
Expand Down Expand Up @@ -256,6 +257,7 @@ global.makeH265webjs2 = (videoURL, config) => {
showLabel.textContent = SHOW_LOADING;

playBar.onclick = () => {
console.log("is playing:", h265webjs.isPlaying());
if (h265webjs.isPlaying()) {
console.log("bar pause============>");
playBar.textContent = '>';
Expand Down Expand Up @@ -395,6 +397,7 @@ global.makeH265webjsRaw = (url265, config) => {
playBar.textContent = '>';

playBar.onclick = () => {
console.log("is playing:", h265webjs.isPlaying());
if (h265webjs.isPlaying()) {
console.log("bar pause============>");
playBar.textContent = '>';
Expand Down
6 changes: 5 additions & 1 deletion src/src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ module.exports = {

A_CODEC_NAME_AAC : 112,
A_CODEC_NAME_MP3 : 113,
A_CODEC_NAME_UNKN : 500
A_CODEC_NAME_UNKN : 500,

CACHE_NO_LOADCACHE : 0xC0,
CACHE_WITH_PLAY_SIGN : 0xC1,
CACHE_WITH_NOPLAY_SIGN : 0xC2,
}
20 changes: 16 additions & 4 deletions src/src/decoder/player-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module.exports = config => {
preCostTime: 0, // Play Use MS
realVolume: 1, // Play Use 0~1
isPlaying: false,
isCaching: def.CACHE_NO_LOADCACHE,
isNewSeek: false,
isCheckDisplay: false,
isPlayLoadingFinish: 0, // 0:undo, 1 loading 2 loading finish
Expand Down Expand Up @@ -147,7 +148,7 @@ module.exports = config => {
player.config.audioNone == false && player.audio.setVoice(player.realVolume);
};
player.isPlayingState = () => {
return player.isPlaying;
return player.isPlaying || player.isCaching === def.CACHE_WITH_PLAY_SIGN;
};
// {pts: 3.04, isKey: false, data: Uint8Array(682), video: true}
player.appendAACFrame = streamBytes => {
Expand Down Expand Up @@ -188,6 +189,10 @@ module.exports = config => {
player.loop = null;
player.config.audioNone == false && player.audio.pause();
player.isPlaying = false;

if (player.isCaching === def.CACHE_WITH_PLAY_SIGN) {
player.isCaching = def.CACHE_WITH_NOPLAY_SIGN
}
};
player.checkFinished = (mode = def.PLAYER_MODE_VOD) => {
// //console.log((mode == def.PLAYER_MODE_VOD)
Expand Down Expand Up @@ -369,13 +374,18 @@ module.exports = config => {
// 就剩下最后3帧就别管了
if (player.frameList.length <= 3) {
return;
}
}

let isPlay = player.isPlaying;

if (player.cacheYuvBuf.yuvCache.length <= 3) {
player.pause();
player.onLoadCache != null && player.onLoadCache();

if (isPlay) {
player.isCaching = def.CACHE_WITH_PLAY_SIGN;
} else {
player.isCaching = def.CACHE_WITH_NOPLAY_SIGN;
}
} else {
return;
}
Expand All @@ -391,9 +401,11 @@ module.exports = config => {
window.clearInterval(cacheInterval);
cacheInterval = null;

if (isPlay) {
if (player.isCaching === def.CACHE_WITH_PLAY_SIGN) {
player.play(player.playParams);
}

player.isCaching = def.CACHE_NO_LOADCACHE;
}
}, 40);
};
Expand Down
2 changes: 1 addition & 1 deletion src/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Github: https://github.com/numberwolf/h265web.js
*
**********************************************************/
require('./h265webjs-v20210627');
require('./h265webjs-v20210704');
export default class h265webjs {
static createPlayer(videoURL, config) {
return window.new265webjs(videoURL, config);
Expand Down
2 changes: 1 addition & 1 deletion src/src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
*
**********************************************************/
module.exports = {
PLAYER_VERSION : "3.0.0",
PLAYER_VERSION : "3.1.0",
};
2 changes: 1 addition & 1 deletion src/version.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION='v20210627' # output version + index.js
VERSION='v20210704' # output version + index.js

0 comments on commit 2799033

Please sign in to comment.