-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem switching videos #424
Comments
|
Works for me™ Tested with html: <canvas id="video-canvas"></canvas>
<script type="text/javascript" src="jsmpeg.min.js"></script>
<script type="text/javascript">
let player = null;
let port = '8082';
let canvas = document.getElementById('video-canvas');
let toggleStreams = function() {
port = port === '8082' ? '8084' : '8082';
if (player) {
player.destroy();
}
let url = 'ws://'+document.location.hostname+':'+port;
player = new JSMpeg.Player(url, {canvas: canvas});
}
toggleStreams();
</script>
<button onclick="toggleStreams()">switch</button> Terminal 1: node websocket-relay.js zomg 8081 8082 Terminal 2: ffmpeg -stream_loop -1 -re -i video.mp4 -f mpegts -codec:v mpeg1video -codec:a mp2 -b 0 http://127.0.0.1:8081/zomg Terminal 3: node websocket-relay.js zomg 8083 8084 Terminal 4: # same input video but different size (`-s wxh`)
ffmpeg -stream_loop -1 -re -i video.mp4 -f mpegts -codec:v mpeg1video -codec:a mp2 -s 320x180 -b 0 http://127.0.0.1:8083/zomg Video_2024-02-24_21-57-03.mp4It's curious that you were able to do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const canvas = document.getElementById('videoCanvas');
The text was updated successfully, but these errors were encountered: