Skip to content

Commit

Permalink
成功人士总是不约而同的配合时代的需求
Browse files Browse the repository at this point in the history
  • Loading branch information
numberwolf committed Oct 8, 2021
1 parent b8dbb85 commit 48f3a07
Show file tree
Hide file tree
Showing 29 changed files with 1,286 additions and 124 deletions.
20 changes: 16 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# h265web.js - 即将支持HDR10!
# h265web.js - 已支持HTTP-FLV 即将支持HDR10!

<a href="README.MD">中文</a> | <a href="README_EN.MD">English</a>

Expand All @@ -20,8 +20,8 @@
| ---- | ---- | ---- | ---- |
| HLS(LIVE) | MP4(VOD) | FLV(VOD) | MPEG2 TS(VOD) |
| <img src="resource/icon-hls.png" height="100"> | <img src="resource/icon-mp4.png" height="100"> | <img src="resource/icon-flv.png" height="100"> | <img src="resource/icon-ts.png" height="100"> |
| M3u8(VOD) | HDR10(BT2020) | HTTP FLV(LIVE) | G711A |
| <img src="resource/icon-m3u8.png" height="100"> | @TODO Support - <br>Before 2021/10/31 | @TODO Support - <br>Before 2021/10/31 | @TODO |
| M3u8(VOD) | HTTP FLV(LIVE) | G711A | HDR10(BT2020) |
| <img src="resource/icon-m3u8.png" height="100"> | <img src="resource/icon-httpflv.png" height="100"> | @TODO | @TODO Support - <br>Before 2021/10/31 |

<br>

Expand Down Expand Up @@ -118,6 +118,8 @@
- [3-其它](#3-其它)

- [捐赠](#捐赠)

- [FFmpeg支持265的HTTPFLV直播](#ffmpeg支持265的httpflv直播)

- [FFmpeg转码265编码的视频](#ffmpeg转码265编码的视频)

Expand All @@ -131,6 +133,9 @@

| 更新日志 | 内容 |
| ---- | ---- |
| 时间 | 2021/10/09 - 凌晨 |
| - | 0.支持HTTP-FLV(HEVC) 直播播放 CodecID=12 |
| - | 0.MP4/FLV(VOD) 优化缓存区域外Seek速度性能 |
| 时间 | 2021/09/27 - 晚 |
| - | 0.M3u8/MpegTS 优化缓存区域外Seek速度性能 |
| 时间 | 2021/09/25 - 凌晨 |
Expand Down Expand Up @@ -236,7 +241,7 @@
| hls | 直播 || ---- |
| H.265 | 点播 || ---- |
| H.265 | 直播 || ---- |
| http-flv | 直播 | | 待支持 |
| http-flv | 直播 | | CodecID=12 |
| flv | 点播 || 备用播放内核模式,不需要填写 |

* 能力
Expand Down Expand Up @@ -395,6 +400,7 @@ var config = {
| \+ core | Int | - | 否:默认0 | 0:默认播放内核 <br>1:备用播放内核 |
| \+ coreProbePart | Float32 | - | 否:默认1.0 | 探测Mp4媒体的属性,百分比 `0.0~1.0`,正常moov前置的文件都用0.1(10%)可以(只适用于备用播放内核) |
| \+ ignoreAudio | Int | - | 否:默认0 | 0:带音频播放 <br>1:忽略音频播放 |
| \+ probeSize | Int | - | 否:4096 | HTTP-FLV直播模式下的探测长度 |



Expand Down Expand Up @@ -919,6 +925,12 @@ player.release();

<br>

### FFmpeg支持265的HTTPFLV直播 ###

* Github地址: https://github.com/numberwolf/FFmpeg-QuQi-H265-FLV-RTMP

<br>

### FFmpeg转码265编码的视频 ###

* mp4
Expand Down
20 changes: 16 additions & 4 deletions README_EN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ A hevc/h.265 web player, easy to play 1080P. `~^_^~ For love` if <a href="https:
| ---- | ---- | ---- | ---- |
| HLS(LIVE) | MP4(VOD) | FLV(VOD) | MPEG2 TS(VOD) |
| <img src="resource/icon-hls.png" height="100"> | <img src="resource/icon-mp4.png" height="100"> | <img src="resource/icon-flv.png" height="100"> | <img src="resource/icon-ts.png" height="100"> |
| M3u8(VOD) | HDR10(BT2020) | HTTP FLV(LIVE) | G711A |
| <img src="resource/icon-m3u8.png" height="100"> | @TODO Support - <br>Before 2021/10/31 | @TODO Support - <br>Before 2021/10/31 | @TODO |
| M3u8(VOD) | HTTP FLV(LIVE) | G711A | HDR10(BT2020) |
| <img src="resource/icon-m3u8.png" height="100"> | <img src="resource/icon-httpflv.png" height="100"> | @TODO | @TODO Support - <br>Before 2021/10/31 |

| h265web.js | mpeg.js `(ts demuxer)` | h265web.js's H.265 decoder | LICENSE |
| ---- | ---- | ---- | ---- |
Expand Down Expand Up @@ -118,8 +118,10 @@ Notice:
- [3、Others](#3others)

- [Donate](#donate)

- [FFmpeg Support H265 Live Encode](#ffmpegsupporth265liveencode)

- [Transcode and get hevc media file by ffmpeg](#transcodeandget265codecfilebyffmpeg)
- [Transcode and get HEVC/H.265 media file by ffmpeg](#transcodeandget265codecfilebyffmpeg)

- [Update Log](upldatelog)

Expand All @@ -131,6 +133,9 @@ Notice:

| Update | Content |
| ---- | ---- |
| 时间 | 2021/10/09 - In the small hours |
| - | 0.Support HTTP-FLV(HEVC) LIVE, CodecID=12 |
| - | 0.MP4/FLV(VOD) performance optimizing of Seek operation(out of cache area) |
| Time | 2021/09/27 - Evening |
| - | 0.M3u8/MpegTS performance optimizing of Seek operation(out of cache area) |
| Time | 2021/09/25 - In the small hours |
Expand Down Expand Up @@ -234,7 +239,7 @@ Notice:
| hls | Live | Y | ---- |
| H.265 | Video on demand | Y | ---- |
| H.265 | Live | Y | ---- |
| http-flv | Live | N | TODO |
| http-flv | Live | Y | CodecID=12 |
| flv | Video on demand | Y | Bak player core mode |

* Features
Expand Down Expand Up @@ -390,6 +395,7 @@ let config = {
| \+ coreProbePart | Float32 | - | N:Default is 1.0 | Probe Mp4 media info,interval: `0.0~1.0`, traditional mp4 file which moov box front of mdat box, use 0.1(10%) (only with Bak player core mode(beta)) |
| \+ core | Int | - | N:Default 0 | 0:Default Core <br>1:Bak Core |
| \+ ignoreAudio | Int | - | N:Default is 0 | 0:Play with audio <br>1:Without audio |
| \+ probeSize | Int | - | N:4096 | HTTP-FLV(LIVE) Mode's probe size, default is 4096 |


<br>
Expand Down Expand Up @@ -910,6 +916,12 @@ player.release();

<br>

### FFmpegSupportH265LiveEncode ###

* Github: https://github.com/numberwolf/FFmpeg-QuQi-H265-FLV-RTMP

<br>

### TranscodeAndGet265CodecFileByFFmpeg ###

* mp4
Expand Down
17 changes: 0 additions & 17 deletions dist/h265webjs-v20210927.js

This file was deleted.

17 changes: 17 additions & 0 deletions dist/h265webjs-v20211009.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-v20210927');
require('./h265webjs-v20211009');
export default class h265webjs {
static createPlayer(videoURL, config) {
return window.new265webjs(videoURL, config);
Expand Down
Binary file not shown.
10 changes: 5 additions & 5 deletions example/dist/dist-play.js

Large diffs are not rendered by default.

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

This file was deleted.

17 changes: 17 additions & 0 deletions example/dist/h265webjs-v20211009.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-v20210927');
require('./h265webjs-v20211009');
export default class h265webjs {
static createPlayer(videoURL, config) {
return window.new265webjs(videoURL, config);
Expand Down
Binary file not shown.
14 changes: 6 additions & 8 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ <h1> h265web.js 播放器 Demo </h1>
<script>
//var token = "============>>>>>>>>>>>>>>Author:changyanlong|numberwolf,Github:https://github.com/numberwolf,Email:[email protected],QQ:531365872,HomePage:http://xvideo.video,Discord:numberwolf#8694,Beijing,WorkIn:Baidu<<<<<<<<<<<<===========";
var token = "base64:QXV0aG9yOmNoYW5neWFubG9uZ3xudW1iZXJ3b2xmLEdpdGh1YjpodHRwczovL2dpdGh1Yi5jb20vbnVtYmVyd29sZixFbWFpbDpwb3JzY2hlZ3QyM0Bmb3htYWlsLmNvbSxRUTo1MzEzNjU4NzIsSG9tZVBhZ2U6aHR0cDovL3h2aWRlby52aWRlbyxEaXNjb3JkOm51bWJlcndvbGYjODY5NCx3ZWNoYXI6bnVtYmVyd29sZjExLEJlaWppbmcsV29ya0luOkJhaWR1";
var type = "mp4";
var url = "hevc_test_moov_set_head_16s.mp4";
// var url = "res/video40_265_moov.mp4";
// var url = "res/hevc_issue_58.mp4";
Expand All @@ -115,27 +114,26 @@ <h1> h265web.js 播放器 Demo </h1>
// var url = "res/06hY38_64_yuvj420p.mp4";
// var url = "res/video40_265_moov.flv";

// var type = "ts";
// var url = "res/hls/v-000.ts"

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

// var type = "hls";
//var url = "res/m3u82/cg720phevc.m3u8";
// var url = "res/m3u8/cg.m3u8";
// var url = "res/hls/veilside.m3u8";
//var url = "res/m3u8/cg.m3u8";
//var url = "res/hls/veilside.m3u8";
//var url = "res/hls/veilside_live.m3u8";
//var url = "res/hls-an/veilside_live.m3u8";
// var url = "res/hls1/test.m3u8";
//var url = "res/hls1/test.m3u8";
//var url = "http://182.61.31.911:8080/live/livestream.flv";

var config = {
player: "glplayer",
width: 960,
height: 540,
token : token,
extInfo : {
coreProbePart : 0.4
coreProbePart : 0.4,
probeSize : 8192
}
};
makeH265webjs(url, config);
Expand Down
Binary file modified resource/icon-flv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/icon-httpflv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions src/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ global.makeH265webjs = (videoURL, config) => {
showLabel.textContent = SHOW_DONE;
};

playerObj.onNetworkError = (error) => {
alert("player - onNetworkError" + error.toString());
}; // onNetworkError

playerObj.onLoadCache = () => {
showLabel.textContent = "Caching...";
};
Expand Down Expand Up @@ -259,7 +263,8 @@ global.makeH265webjs = (videoURL, config) => {
coverToast.removeAttribute('hidden');
coverBtn.onclick = () => {
// playBar.textContent = '||';
playerObj.play();
// playerObj.play();
playAction();
coverToast.setAttribute('hidden', 'hidden');
};
}
Expand Down Expand Up @@ -313,8 +318,8 @@ global.makeH265webjs = (videoURL, config) => {
***************************************************/
var workerFetch = new Worker('./dist/worker-fetch-dist.js');
var workerParse = new Worker('./dist/worker-parse-dist.js');
console.log("workerFetch:", workerFetch);
console.log("workerParse:", workerParse);
// console.log("workerFetch:", workerFetch);
// console.log("workerParse:", workerParse);
/*
* 创建265流播放器
*/
Expand Down
47 changes: 29 additions & 18 deletions src/src/decoder/audio-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
const AudioContext = window.AudioContext || window.webkitAudioContext;
const AUDIO_WAIT = 0.04; // 40ms ~ 2frame, 44100 -> 20ms 22050 40ms
const def = require('../consts');
const AVCommon = require('./av-common');

const getMsTime = () => {
return new Date().getTime();
};
// const AVCommon.GetMsTime = () => {
// return new Date().getTime();
// };

module.exports = options => {
let audioModule = {
Expand Down Expand Up @@ -57,6 +58,7 @@ module.exports = options => {
playTimestamp: 0.0,
playStartTime: 0,
durationMs: -1,
isLIVE: false,
// voice 0.0 ~ 1.0
voice: 1.0,
onLoadCache: null
Expand All @@ -83,12 +85,13 @@ module.exports = options => {
// + audioModule.seekPos;
// console.log("audio pts:" + audioModule.audioCtx.currentTime);
// return pts;
return audioModule.playTimestamp + (getMsTime() - audioModule.playStartTime) / 1000;
return audioModule.playTimestamp + (AVCommon.GetMsTime() - audioModule.playStartTime) / 1000;
};
/**
* @brief Swap SourceNode To Play When before node play end
*/
audioModule.swapSource = (sourceIndex = -1, dstIndex = -1) => {
console.log("audioModule.swapSource", sourceIndex, dstIndex);
if (audioModule.startStatus == false) {
return null;
}
Expand All @@ -107,15 +110,15 @@ module.exports = options => {
audioModule.sourceList[sourceIndex] = null;
}
} catch (e) {
console.log("[DEFINE ERROR]disconnect source Index:" + sourceIndex + " error happened!", e);
console.error("[DEFINE ERROR] audioModule disconnect source Index:" + sourceIndex + " error happened!", e);
// return null;
}

audioModule.sourceChannel = dstIndex;

let ret = audioModule.decodeSample(dstIndex, sourceIndex);
// console.log("in swapSource -> decodeSample ret", ret);
if (ret == -2) {
if (ret == -2 && audioModule.isLIVE) {
if (audioModule.getAlignVPTS() >= (audioModule.durationMs / 1000.0 - AUDIO_WAIT)) {
audioModule.pause();
} else {
Expand Down Expand Up @@ -227,11 +230,19 @@ module.exports = options => {
}

if (audioModule.sampleQueue.length == 0) {
console.log("audioModule.sampleQueue.length is 0, return -2");
// @todo
// audioModule.sourceList[sourceIndex].connect(audioModule.gainNode);
// audioModule.sourceList[sourceIndex].start();
// audioModule.sourceList[sourceIndex].stop();
if (audioModule.isLIVE) {
audioModule.sourceList[sourceIndex].connect(audioModule.gainNode);
audioModule.sourceList[sourceIndex].start();
audioModule.sourceList[sourceIndex].onended = function() {
audioModule.swapSource(sourceIndex, dstIndex);
};
audioModule.sourceList[sourceIndex].stop();
// audioModule.decodeSample(sourceIndex, dstIndex);
console.log("audioModule.sampleQueue.length is 0, return 0");
return 0;
}
console.log("audioModule.sampleQueue.length is 0, return -2");
return -2;
}

Expand Down Expand Up @@ -269,25 +280,25 @@ module.exports = options => {

if (audioModule.nextBuffer == null || audioModule.nextBuffer.data.length < 1)
{
console.warn(
"2 audioModule.sourceList ctx state before",
audioModule.sourceList[sourceIndex].context.state);
// console.warn(
// "2 audioModule.sourceList ctx state before",
// audioModule.sourceList[sourceIndex].context.state);

audioModule.sourceList[sourceIndex].connect(audioModule.gainNode);
audioModule.sourceList[sourceIndex].start();
audioModule.sourceList[sourceIndex].startState = true;
audioModule.sourceList[sourceIndex].stop();
// console.log("audioModule.nextBuffer is null, return 1");

console.warn(
"2 audioModule.sourceList ctx state after",
audioModule.sourceList[sourceIndex].context.state);
// console.warn(
// "2 audioModule.sourceList ctx state after",
// audioModule.sourceList[sourceIndex].context.state);
return 1;
}

let inputArrayBuffer = audioModule.nextBuffer.data.buffer;
audioModule.playTimestamp = audioModule.nextBuffer.pts;
audioModule.playStartTime = getMsTime();
audioModule.playStartTime = AVCommon.GetMsTime();

// console.log("audioModule inputArrayBuffer.pts ", audioModule.playTimestamp);
try {
Expand Down Expand Up @@ -453,7 +464,7 @@ module.exports = options => {
}
};
audioModule.pause = () => {
console.log("=========> audio pause!");
console.log("____________________________________audioModule.pause");
audioModule.startStatus = false;
for (let i = 0; i < audioModule.sourceList.length; i++) {
if (audioModule.sourceList[i] !== undefined
Expand Down
7 changes: 6 additions & 1 deletion src/src/decoder/av-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ function GetFormatPlayCore(inputFormat) {
return Formats[0].core;
} // GetFormatPlayCore

function GetMsTime() {
return new Date().getTime();
};

module.exports = {
frameDataAlignCrop : frameDataAlignCrop,
GetUriFormat : GetUriFormat,
GetFormatPlayCore : GetFormatPlayCore
GetFormatPlayCore : GetFormatPlayCore,
GetMsTime : GetMsTime,
}; // module exports
Loading

0 comments on commit 48f3a07

Please sign in to comment.