We have to record our desktop activity for make various reason, like make a demo for an application, or making video tutorial for an application etc.
the prototype application is like
This project can be done in 3 steps
- taking screenshot of ur desktop continously
- Make an video file using the images
So first step taking screenshot of ur desktop continously
so first we have to take the screen shot of the desktop, for that we have to write the code
int ScreenWidth = Screen.PrimaryScreen.Bounds.Width;
int ScreenHeight = Screen.PrimaryScreen.Bounds.Height;
Graphics g;
Bitmap b = new Bitmap(ScreenWidth, ScreenHeight);
g = Graphics.FromImage(b);
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
Now we have to make avi file from these images, for that we aviwrapper u can download it from here.
now about making avi file from these images , the code i used is like
AviManager aviManager = new AviManager(@"..\..\Output\output.avi", false);
VideoStream aviStream = null;
aviStream = aviManager.AddVideoStream(true,4, bi);
aviStream.AddFrame(b);
the link for full source code is here
Kindly could you give us code for how we could make a video from bitmaps. Similar concept what you have done in Create a desktop video recorder in C# but not from screen instead use bitmaps
please must reply.
thanks
i use this dll , u can get it from here http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx
also u can get my source code from here http://www.multiupload.com/BR4MF5TEYM
hiiii
i want to download your code for desktop video recorder in C#
but i cant that files…
i am having error: the file not found on server!
plz help me i want this project with with source code
how do i get this project?????
Thanks for replying, I am really thrilled with so quick reply but my problem not solved from the links you suggested.
I have created a bitmap from pixels in this way.
try
{
// Retrieve the image.
//Bitmap image1 = new Bitmap(@”C:\Users\Bilal\Documents\Visual Studio 2010\Projects\WindowsFormsApplication5\bitmap\bitmap\bin\a”, true);
// Color c=Color.FromArgb(k);
int x, y;
// Loop through the images pixels to reset color.
for (x = 0; x < image1.Width; x++)
{
for (y = 0; y < image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
//Color newColor = Color.FromArgb(pixelColor.R, pixelColor.B, pixelColor.G);
}
}
for (int i = 0; i < image1.Width; i++)
{
for (int j = 0; j < image1.Height; j++)
{
Color c = new Color();
int r = 0;
r = Convert.ToInt16( c.R);
int g = 0;
g = Convert.ToInt16(c.G);
int b = 0;
b = Convert.ToInt16(c.B);
int max1 = System.Math.Max(r, g);
int final = System.Math.Max(max1, b);
r = final;
g = final;
b = final;
c = Color.FromArgb(r, g, b);
// image1.SetPixel(r, g, b);
image1.SetPixel(i, j, c);
}
}
// Set the PictureBox to display the image.
pictureBox1.Image = image1;
// Display the pixel format in Label1.
label1.Text = "Pixel format: " + image1.PixelFormat.ToString();
}
catch (ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
but now i want to convert these bitmaps to video and i have no clue how to proceed,
kindly if you could guide me.
what would be possible alternative for this method
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
to create video from bitmap made above not from CopyFromScreen methods.
thanks
try
{AviManager aviManager = new AviManager(@”..\..\Output\output.avi”, false);
VideoStream aviStream = null;
aviStream = aviManager.AddVideoStream(true,4, bi);
// Retrieve the image.
//Bitmap image1 = new Bitmap(@”C:\Users\Bilal\Documents\Visual Studio 2010\Projects\WindowsFormsApplication5\bitmap\bitmap\bin\a”, true);
// Color c=Color.FromArgb(k);
int x, y;
// Loop through the images pixels to reset color.
for (x = 0; x < image1.Width; x++)
{
for (y = 0; y < image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
//Color newColor = Color.FromArgb(pixelColor.R, pixelColor.B, pixelColor.G);
}
}
for (int i = 0; i < image1.Width; i++)
{
for (int j = 0; j < image1.Height; j++)
{
Color c = new Color();
int r = 0;
r = Convert.ToInt16( c.R);
int g = 0;
g = Convert.ToInt16(c.G);
int b = 0;
b = Convert.ToInt16(c.B);
int max1 = System.Math.Max(r, g);
int final = System.Math.Max(max1, b);
r = final;
g = final;
b = final;
c = Color.FromArgb(r, g, b);
// image1.SetPixel(r, g, b);
image1.SetPixel(i, j, c);
}
}
// Set the PictureBox to display the image.
pictureBox1.Image = image1;
aviStream.AddFrame( image1);
// Display the pixel format in Label1.
label1.Text = "Pixel format: " + image1.PixelFormat.ToString();
}
catch (ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
just add avi dll in reference and write the code use
aviStream.AddFrame( image1); //image1 as bitmap
hope it would help
Thanks alot for replying and your interest in our problem.
Yes this code helped me very much and i have created video from bitmap.
code for Making a video from bitmaps………
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Drawing.Drawing2D;
using System.Data;
using AviFile;
using System.Runtime.InteropServices;
using System.IO;
namespace bitmap
{
public partial class Form1 : Form
{
//AviManager aviManager = new AviManager(“C:\\Users\\Bilal\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication5\\bitmap\\Output\\output.avi”, false);
int m = 0;
//VideoStream aviStream = null;
Bitmap[] image1 = new Bitmap[50];
//private ArrayList streams = new ArrayList();
public Form1()
{
//image1 = new Bitmap(500, 500);
image1[0] = new Bitmap(500, 500);
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
// int k = 0;
AviManager aviManager = new AviManager(“C:\\Users\\Bilal\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication5\\bitmap\\Output\\output.avi”, false);
VideoStream aviStream = null;
aviStream = aviManager.AddVideoStream(true,2, image1[0]);
// Retrieve the image.
//Bitmap image1 = new Bitmap(@”C:\Users\Bilal\Documents\Visual Studio 2010\Projects\WindowsFormsApplication5\bitmap\bitmap\bin\a”, true);
// Color c=Color.FromArgb(k);
int x, y;
for (int count = 0; count < 10; count++)
{
image1[count] = new Bitmap(500, 500);
//aviStream = aviManager.AddVideoStream(true, 4, image1[count]);
// Loop through the images pixels to reset color.
for (x = 0; x < image1[count].Width; x++)
{
for (y = 0; y < image1[count].Height; y++)
{
m = m + 22;
Color c1 = Color.FromArgb(m);
image1[count].SetPixel(x, y, c1);
//Color newColor = Color.FromArgb(pixelColor.R, pixelColor.B, pixelColor.G);
}
}
//m = m + 40;
for (int i = 0; i < image1[count].Width; i++)
{
for (int j = 0; j < image1[count].Height; j++)
{
Color c = new Color();
c = image1[count].GetPixel(i, j);
int r = 0;
r = Convert.ToInt16(c.R);
int g = 0;
g = Convert.ToInt16(c.G);
int b = 0;
b = Convert.ToInt16(c.B);
int max1 = System.Math.Max(r, g);
int final = System.Math.Max(max1, b);
r = final;
g = final;
b = final;
c = Color.FromArgb(r, g, b);
image1[count].SetPixel(i, j, c);
// image1.SetPixel(r, g, b);
/*image1[count].SetPixel(i, j, c);
pictureBox1.Image = image1[count];
aviStream.AddFrame(image1[count]);
image1[count].Dispose();
label1.Text = "Pixel format: " + image1[count].PixelFormat.ToString();
aviManager.Close();*/
}
}
m = m + 200;
// aviStream = aviManager.AddVideoStream(true, 1, image1[count]);
aviStream.AddFrame(image1[count]);
pictureBox1.Image = image1[count];
//aviStream.AddFrame(image1[count]);
image1[count].Dispose();
label1.Text = "Pixel format: " + image1[count].PixelFormat.ToString();
// aviManager.Close();
}
// Dispose();
aviManager.Close();
//aviManager.Close();
// Set the PictureBox to display the image.
// pictureBox1.Image = image1[i];
//aviStream.AddFrame( image1);
//image1.Dispose();
//aviManager.Close();
// Display the pixel format in Label1.
//label1.Text = "Pixel format: " + image1[i].PixelFormat.ToString();
}
catch (ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}
}
}
the code works correctly but it throws an exception in program.cs file.
Application.Run(new Form1()); exception was unhandled .
can you help me out of this error.
thanks in advance
my email is is kdgupta87@gmail.com
send ur code, i will fix it and send u bk.
send the full slin. it must be referense problem, thanks.
r u installed direct x 9.0 or higher in ur pc?
Avimanager shows an error (Assemblyrefrence is missing)
do u installed direct x 9 or higher
no
Now i am downloaded Direct x from this link —– http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3&DisplayLang=en
Again it shows the same error
check ur bin folder is there any avi.dll present? if not add it from add reference
Now its working i am added avi.dll through reference
I WANT AVI.DLL
aviStream = aviManager.AddVideoStream(true, 4, bi);
from here form displays then not goes to next line
if i put false instead of true its working but video is not running
how to decrease the memory i mean for 20 sec memory 400 mb how to decrease this memory for 1 min 1mb
Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file.(some times working)
what to do
i need to change the player
Exception in VideoStreamWrite: -2147205019
why this code is not working in timer Elapsed
Thanx nice app……….
Thanks for the sample project. It is a good one to help me a lot 🙂
Hi, Your link to your source code is down, can you please re-upload it?
Please upload your code once again links are expired
Hi Kishore Iam Very New To these C#.net I have To generate screen recorder like a video i have a start ,stop ,play. buttons if i presssed statrt start recording of screen when i pres stop stop the recording when i press play it just play the video of recording screen. i hope you undersatnd my requirement .could you please send me the source code my mail id nagendra.re30@gmail.com thanq in advance iam waiting for rply
The full source code link goes to a blank page and never loads?
Where do i find this Avi.dll?
The given website only contains a download link with many .cs files.
I pasted them all into my project, but when i try to run it, and i press button1 it says in AviManager.cs:
Exception was not handled
Exception in AVIFileOpen: -2147205009
Pingback: Record video from opengl | PHP Developer Resource
This file does not exist, the access to the following file is limited or it has been removed due to infringement of copyright. -> how could i see the full source code?? please help me…
avimanager is a joke, it is a memory pig, just use ffmeg it cuts the dozens of lines of code down to a single one.
hello.. I want to record video with using webcam. i should use c# . how i am do that?