Compare commits
No commits in common. "5b204904a7c504dd4ba33fff58ef77601b5ccdce" and "c5e84f805ae8f0cf9b9fdc784626b88921ae1ef1" have entirely different histories.
5b204904a7
...
c5e84f805a
@ -29,12 +29,9 @@ evanEnv.enableAutoDownload = true
|
|||||||
|
|
||||||
## FFmpeg合并示例
|
## FFmpeg合并示例
|
||||||
```shell
|
```shell
|
||||||
ffmpeg -i mediasource_0_0_0.mp4 -i mediasource_0_1_0.mp4 -c copy -bsf:a aac_adtstoasc out.mp4
|
ffmpeg -i mediasource_0_0.mp4 -i mediasource_0_1.mp4 -c copy -bsf:a aac_adtstoasc out.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
## 大文件分段需要先文件合并
|
|
||||||
copy /b mediasource_0_0_*.mp4 out.mp4
|
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
- 合并后声音播放不正常:由于部分网站使用了HE-AAC v2(AAC+SBR+PS)作为音频编码,大部分播放器还不支持此音频流格式,故声音不正常,使用Windows自带的视频播放器播放正常
|
- 合并后声音播放不正常:由于部分网站使用了HE-AAC v2(AAC+SBR+PS)作为音频编码,大部分播放器还不支持此音频流格式,故声音不正常,使用Windows自带的视频播放器播放正常
|
||||||
|
|
||||||
|
@ -19,44 +19,29 @@ evanEnv.enableAutoDownload = true;
|
|||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
evanEnv.videos = document.getElementsByTagName('video');
|
evanEnv.videos = document.getElementsByTagName('video');
|
||||||
evanEnv.downloadRawData = function (bufferList, fileName = 'out', ext = '.mp4') {
|
evanEnv.buildArrayBuffer = function (bufferList) {
|
||||||
var buffList = new Array();
|
|
||||||
var totalLength = 0;
|
var totalLength = 0;
|
||||||
|
|
||||||
for (var i = 0; i < bufferList.length; i++) {
|
for (var i = 0; i < bufferList.length; i++) {
|
||||||
totalLength += bufferList[i].byteLength;
|
totalLength += bufferList[i].byteLength;
|
||||||
if (totalLength > 1073741824 || i == bufferList.length - 1) {
|
|
||||||
buffList.push(new Uint8Array(totalLength));
|
|
||||||
totalLength = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var tmp = new Uint8Array(totalLength);
|
||||||
var lastLength = 0;
|
var lastLength = 0;
|
||||||
var part = 0;
|
|
||||||
for (var ix = 0; ix < bufferList.length; ix++) {
|
for (var ix = 0; ix < bufferList.length; ix++) {
|
||||||
//10485760
|
tmp.set(new Uint8Array(bufferList[ix]), lastLength);
|
||||||
//1073741824
|
|
||||||
|
|
||||||
buffList[part].set(new Uint8Array(bufferList[ix]), lastLength);
|
|
||||||
lastLength += bufferList[ix].byteLength;
|
lastLength += bufferList[ix].byteLength;
|
||||||
if (lastLength > 1073741824) {
|
|
||||||
part++;
|
|
||||||
lastLength = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return tmp.buffer;
|
||||||
for (var iz = 0; iz < buffList.length; iz++) {
|
};
|
||||||
var buff = buffList[iz];
|
evanEnv.downloadRawData = function (bufferList, fileName = 'out.mp4') {
|
||||||
let url = window.URL.createObjectURL(new Blob([buff], { type: "arraybuffer" }))
|
var buff = evanEnv.buildArrayBuffer(bufferList);
|
||||||
const link = document.createElement('a');
|
let url = window.URL.createObjectURL(new Blob([buff], {type: "arraybuffer"}))
|
||||||
link.style.display = 'none';
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.style.display = 'none';
|
||||||
link.setAttribute('download', fileName + "_" + iz + ext);
|
link.href = url;
|
||||||
document.body.appendChild(link);
|
link.setAttribute('download', fileName);
|
||||||
link.click();
|
document.body.appendChild(link);
|
||||||
document.body.removeChild(link);
|
link.click();
|
||||||
}
|
document.body.removeChild(link);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
evanEnv.download = function () {
|
evanEnv.download = function () {
|
||||||
@ -64,7 +49,7 @@ evanEnv.enableAutoDownload = true;
|
|||||||
var currentItem = evanEnv.mediaSources[i];
|
var currentItem = evanEnv.mediaSources[i];
|
||||||
if (currentItem.downloaded == undefined || currentItem.downloaded == false) {
|
if (currentItem.downloaded == undefined || currentItem.downloaded == false) {
|
||||||
for (var x = 0; x < currentItem.rawSources.length; x++) {
|
for (var x = 0; x < currentItem.rawSources.length; x++) {
|
||||||
evanEnv.downloadRawData(currentItem.rawSources[x], 'mediasource_' + i + '_' + x);
|
evanEnv.downloadRawData(currentItem.rawSources[x], 'mediasource_' + i + '_' + x + '.mp4');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentItem.downloaded = true;
|
currentItem.downloaded = true;
|
||||||
@ -72,7 +57,7 @@ evanEnv.enableAutoDownload = true;
|
|||||||
};
|
};
|
||||||
evanEnv.downloadMediaSource = function (mediaSource) {
|
evanEnv.downloadMediaSource = function (mediaSource) {
|
||||||
for (var x = 0; x < mediaSource.rawSources.length; x++) {
|
for (var x = 0; x < mediaSource.rawSources.length; x++) {
|
||||||
evanEnv.downloadRawData(mediaSource.rawSources[x], 'mediasource_' + x);
|
evanEnv.downloadRawData(mediaSource.rawSources[x], 'mediasource_' + x + '.mp4');
|
||||||
mediaSource.downloaded = true;
|
mediaSource.downloaded = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user