phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.36k stars 1.43k forks source link

Issue changing default player parameters #139

Open mwn2017 opened 7 years ago

mwn2017 commented 7 years ago

Hello, I've run the player with the following settings:

var player = new JSMpeg.Player(url, { canvas: canvas, pauseWhenHidden: true, maxAudioLag: 0.1, videoBufferSize: 64 * 1024, audioBufferSize: 13 * 1024 });

After few seconds of playback video stops (often showing artifacts). Javascript console shows the following:

Uncaught RangeError: Source is too large at Uint8Array.set (native) at BitBuffer.appendSingleBuffer (http://127.0.0.1/js/jsmpeg.min.js:1:10612) at BitBuffer.write (http://127.0.0.1/js/jsmpeg.min.js:1:10407) at MPEG1.BaseDecoder.write (http://127.0.0.1/js/jsmpeg.min.js:1:21077) at MPEG1.write (http://127.0.0.1/js/jsmpeg.min.js:1:22768) at TS.packetComplete (http://127.0.0.1/js/jsmpeg.min.js:1:20238) at TS.parsePacket (http://127.0.0.1/js/jsmpeg.min.js:1:19365) at TS.write (http://127.0.0.1/js/jsmpeg.min.js:1:17519) at WSSource.onMessage (http://127.0.0.1/js/jsmpeg.min.js:1:16820)

This message is probably repeated for every frame. Also audio stops, but after video.

With the following parameters, everything is fine:

var player = new JSMpeg.Player(url, { canvas: canvas, pauseWhenHidden: true });

Thanks

phoboslab commented 7 years ago

Well, the buffer size you specified in your first example (64*1024 = 64kb) is to small to hold a single frame. The default is 512kb.