Skip to content

Commit c46873e

Browse files
committed
Fix video rendering issue.
1 parent 5302f47 commit c46873e

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

src/graphics/Composer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ShaderPass from 'graphics/ShaderPass';
33
import BlendShader from 'shaders/BlendShader';
44
import CopyShader from 'shaders/CopyShader';
55
import blendModes from 'graphics/blendModes';
6+
import { base64ToBytes } from 'utils/data';
67
import { createRenderTarget } from './common';
78

89
export default class Composer {
@@ -30,7 +31,7 @@ export default class Composer {
3031
getImage(format = 'image/png') {
3132
const img = this.renderer.domElement.toDataURL(format);
3233
const data = img.replace(/^data:image\/\w+;base64,/, '');
33-
return Buffer.from(data, 'base64');
34+
return base64ToBytes(data);
3435
}
3536

3637
setSize(width, height) {

src/main/api/plugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from 'fs';
22
import path from 'path';
33
import yauzl from 'yauzl';
4-
import { streamToBuffer } from 'utils/data';
54

65
const plugins = {};
76

@@ -15,6 +14,16 @@ function getPluginId(file) {
1514
return path.parse(file).base;
1615
}
1716

17+
function streamToBuffer(stream) {
18+
const chunks = [];
19+
20+
return new Promise((resolve, reject) => {
21+
stream.on('data', chunk => chunks.push(chunk));
22+
stream.on('error', reject);
23+
stream.on('end', () => resolve(Buffer.concat(chunks)));
24+
});
25+
}
26+
1827
function loadModule(id, data) {
1928
initPlugin(id);
2029

src/utils/data.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export async function dataToBlob(data, ext) {
3636
return new Blob([new Uint8Array(data).buffer], { type: mime.getType(ext) });
3737
}
3838

39-
export function streamToBuffer(stream) {
40-
const chunks = [];
41-
42-
return new Promise((resolve, reject) => {
43-
stream.on('data', chunk => chunks.push(chunk));
44-
stream.on('error', reject);
45-
stream.on('end', () => resolve(Buffer.concat(chunks)));
46-
});
39+
export function base64ToBytes(base64) {
40+
const str = atob(base64);
41+
const len = str.length;
42+
const bytes = new Uint8Array(len);
43+
for (let i = 0; i < len; i++) {
44+
bytes[i] = str.charCodeAt(i);
45+
}
46+
return bytes;
4747
}

src/video/RenderProcess.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export default class RenderProcess extends Process {
5656
'yuv420p',
5757
'-f',
5858
format,
59+
'-analyzeduration',
60+
2147483647,
61+
'-probesize',
62+
2147483647,
5963
];
6064

6165
// Encoding options

src/view/components/controls/Setting.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ export default function Setting({
2323
<div className={styles.label} style={{ width: labelWidth }}>
2424
{label}
2525
</div>
26-
{InputCompnent && (
27-
<div style={{ width: inputWidth }}>
26+
<div style={{ width: inputWidth }}>
27+
{InputCompnent && (
2828
<InputCompnent
2929
{...inputProps}
3030
{...otherProps}
3131
name={name}
3232
value={value}
3333
onChange={onChange}
3434
/>
35-
{children}
36-
</div>
37-
)}
35+
)}
36+
{children}
37+
</div>
3838
</div>
3939
);
4040
}

0 commit comments

Comments
 (0)