Membuat Server Video Streming Sederhana Visual C# 2012

Berdasarkan post sebelumnya https://wangready.wordpress.com/2011/10/09/akuisisi-gambar-dari-webcam-menggunakan-aforge-net-library-berbasis-bahasa-c/

saya edit dan tambahkan timer untuk menyimpan file gambar pada server xampp. Jadi instal dulu xampp.

private void timer1_Tick(object sender, EventArgs e)
        {
            Bitmap im1 = videoSourcePlayer.GetCurrentVideoFrame();
            pictureBox1.Image = im1;
            im1.Save(@"C:\xampp\htdocs\my_page\tes_buff.jpg");
            try
            {
                System.IO.FileInfo f = new System.IO.FileInfo(@"C:\xampp\htdocs\my_page\tes_buff.jpg");
                long s1 = f.Length;
                label4.Text = s1.ToString();
                if(s1>100000)
                    System.IO.File.Copy(@"C:\xampp\htdocs\my_page\tes_buff.jpg", @"C:\xampp\htdocs\my_page\tes.jpg", true);
            }
            catch (Exception a)
            {
            }
        }

file gambar saya simpan di C:\xampp\htdocs\my_page\tes.jpg . File bisa di browse lewat page html sederhana sbb.

<html>
<head>
<title>HTML in 10 Simple Steps or Less</title>
<meta http-equiv="refresh" content="0.5" >
</head>
<body>
<img src="http://10.7.21.8/my_page/tes.jpg"/>
</body>

Untuk mengganti folder file browsing saya mengedit file dari index.php di folder htdocs menjadi /my_page/

<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/my_page/');
	exit;
?>

gambar bisa distreaming juga lewat aplikasi yang contohnya ada di example library aforge.net langsung mengakses file .jpg nya dengan alamat URL server. file project aplikasinya ada di directory \AForge.NET\Framework\Samples\Vision\MotionDetector

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s