Joey Morani Joey Morani - 7 months ago 45
C# Question

Possible to stream images (video) from C# using JavaScript?

I've created a C# program which captures the screen as a Jpeg image and saves it to a file. Then using HTML5's Canvas, I'm using this code to pull in the image and display it, updating every 8 milliseconds so it looks like a video.

<script type="application/javascript">
function draw() {
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var img=new Image();
img.src="C://wamp/www/test.jpg?" + new Date().getTime();

img.onload = function() {
cxt.drawImage(img, 0, 0);

function start() {

<body onLoad="start()">
<canvas id="myCanvas" width="1024" height="720"></canvas>

Doing this locally gives a good picture (a bit choppy, but still good) but doing it over the internet is useless. Is there a way to stream the image straight from the C# program instead of using a file? Would that update it quick enough for a good picture? Or shall I compress the image in the C# program? Just looking for any pointers of how to make this work. Thanks for the help! :)


If you can manage to code the delivery-method, it shouldn't be any worse than attaching a html5-video element to a endpoint in your app :)

But it might involve transcoding jpeg-images to h264 on the fly ;)