求助 用c# 实现屏幕录像功能?

liyachi 2009-05-24 08:07:19
如何 用c#实现屏幕录像功能 ?
...全文
2364 35 打赏 收藏 转发到动态 举报
写回复
用AI写文章
35 条回复
切换为时间正序
请发表友善的回复…
发表回复
銩铥熊 2011-05-04
  • 打赏
  • 举报
回复
还在观望中吗?有好的没有啊
art9527 2011-04-12
  • 打赏
  • 举报
回复
[Quote=引用 31 楼 xue12300 的回复:]

怎么输出AVI文件啊?
[/Quote]

用windows操作系统自带的 AVIFil32.dll 类库 会有你要的东西
参考msdn
http://msdn.microsoft.com/en-us/library/dd756808(v=VS.85).aspx
new2007 2010-11-29
  • 打赏
  • 举报
回复
怎么输出AVI文件啊?
xue12300 2009-12-23
  • 打赏
  • 举报
回复
怎么输出AVI文件啊?
liyachi 2009-06-03
  • 打赏
  • 举报
回复
如果检测到屏幕有变化在截图,是否可行?

该怎么检测到屏幕有变化?
walkghost 2009-05-27
  • 打赏
  • 举报
回复
楼上那位抓图的肯定行不通,太占用资源了。
十八道胡同 2009-05-27
  • 打赏
  • 举报
回复
[Quote=引用 27 楼 zzxap 的回复:]

C#三层结构屏幕录象和源码2
http://download.csdn.net/source/789809
[/Quote]

这个没注释的。。汗。。
zzxap 2009-05-27
  • 打赏
  • 举报
回复

C#三层结构屏幕录象和源码2
http://download.csdn.net/source/789809
muyebo 2009-05-27
  • 打赏
  • 举报
回复
ding
wxm3630478 2009-05-27
  • 打赏
  • 举报
回复
放进我的网摘 以后看.......如果那天心血来潮 想写这么东西 可以参考参考
chenshujun1127 2009-05-27
  • 打赏
  • 举报
回复
DirectShow
PENYY 2009-05-26
  • 打赏
  • 举报
回复
飘过!关注ING
lovebenben 2009-05-26
  • 打赏
  • 举报
回复
路过学习一下
newdigitime 2009-05-26
  • 打赏
  • 举报
回复
当然是从directX 入手啦
jiemengw 2009-05-26
  • 打赏
  • 举报
回复
学习
liyachi 2009-05-25
  • 打赏
  • 举报
回复
源代码如下:
Imports WMEncoderLib
Imports WMPREVIEWLib

Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(48, 80)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(216, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Write To file and Close application"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region
Dim Encoder As WMEncoder
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create a WMEncoder object.

Encoder = New WMEncoder
' Retrieve the source group collection and add a source group.

Dim SrcGrp As IWMEncSourceGroup2
Dim SrcGrpColl As IWMEncSourceGroupCollection
SrcGrpColl = Encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Dim SrcVid As IWMEncVideoSource2
Dim SrcAud As IWMEncAudioSource
SrcVid = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO)
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO)

' Identify the source files to encode.
SrcVid.SetInput("ScreenCap://ScreenCapture1")
SrcAud.SetInput("Device://Default_Audio_Device")

' Choose a profile from the collection.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim lLength As Long

ProColl = Encoder.ProfileCollection
lLength = ProColl.Count
'For i = 0 To lLength - 1
' Console.WriteLine(ProColl.Item(i).Name)
'Next
For i = 0 To lLength - 1
Pro = ProColl.Item(i)
If Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)" Then
SrcGrp.Profile = Pro
Exit For
End If
Next

' Fill in the description object members.
Dim Descr As IWMEncDisplayInfo
Descr = Encoder.DisplayInfo
Descr.Author = "Armoghan Asif"
Descr.Copyright = "Copyright information"
Descr.Description = "Text description of encoded content"
Descr.Rating = "Rating information"
Descr.Title = "Title of encoded content"

' Add an attribute to the collection.
Dim Attr As IWMEncAttributes
Attr = Encoder.Attributes
Attr.Add("URL", "www.adnare.com")

' Specify a file object in which to save encoded content.
Dim File As IWMEncFile
File = Encoder.File
File.LocalFileName = "C:\OutputFile.avi"

' Crop 2 pixels from each edge of the video image.
SrcVid.CroppingBottomMargin = 2
SrcVid.CroppingTopMargin = 2
SrcVid.CroppingLeftMargin = 2
SrcVid.CroppingRightMargin = 2

' Start the encoding process.
Encoder.Start()

End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Encoder.RunState Then
Encoder.Stop()
Application.Exit()
End If
End Sub
End Class

liyachi 2009-05-25
  • 打赏
  • 举报
回复
...
using WMEncoderLib;
using WMPREVIEWLib;
using System.IO;

WMEncoder Encoder;
private void Form1_Load(object sender, System.EventArgs e)
{
Encoder = new WMEncoder();
IWMEncSourceGroup SrcGrp;
IWMEncSourceGroupCollection SrcGrpColl;
SrcGrpColl = Encoder.SourceGroupCollection;
SrcGrp = SrcGrpColl.Add("SG_1");

IWMEncSource SrcVid;
IWMEncSource SrcAud;
SrcVid = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);


SrcAud.SetInput("Default_Audio_Device", "Device", "");
SrcVid.SetInput("ScreenCapture1", "ScreenCap", "");


IWMEncProfileCollection ProColl;
IWMEncProfile Pro;
int i;
long lLength;

ProColl = Encoder.ProfileCollection;
lLength = ProColl.Count;

for( i=0 ; i<lLength-1 ; i++ )
{
Pro = ProColl.Item(i);
if( Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)" )
{
SrcGrp.set_Profile(Pro);
break;
}
}

IWMEncDisplayInfo Descr;
Descr = Encoder.DisplayInfo;
Descr.Author = "Armoghan Asif";
Descr.Copyright = "Copyright information";
Descr.Description = "Text description of encoded content";
Descr.Rating = "Rating information";
Descr.Title = "Title of encoded content";

IWMEncAttributes Attr;
Attr = Encoder.Attributes;
Attr.Add("URL", "www.adnare.com");

IWMEncFile File;
File = Encoder.File;
File.LocalFileName = @"C:\OutputFile.avi";
// SrcVid.CroppingBottomMargin = 2;
// SrcVid.CroppingTopMargin = 2;
// SrcVid.CroppingLeftMargin = 2;
// SrcVid.CroppingRightMargin = 2;


Encoder.Start();
}

private void button1_Click(object sender, System.EventArgs e)
{
this.Encoder.Stop();

// if( Encoder.RunState )
// {
// Encoder.Stop();
// Application.Exit();
// }
}

以上的代码是我翻译网上vb的写的屏幕录像代码,但录像的效果很差,cup占100%,屏幕像素也很小,
希望各位帮忙看看。
crazyboy52055 2009-05-24
  • 打赏
  • 举报
回复
大姐 是 DrictX 吧??
APP开发王 2009-05-24
  • 打赏
  • 举报
回复
建议用 DericorX
crazyboy52055 2009-05-24
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;//

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Bitmap bmp;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(GetImg));
thread.IsBackground = true;
thread.Start();
}
/// <summary>
/// 循环读取桌面图像
/// </summary>
public void GetImg()
{
while (true)
{
Thread.Sleep(100);
//获取全屏图像
this.bmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
Graphics g = Graphics.FromImage(this.bmp);
//
g.CopyFromScreen(0, 0, 0, 0, new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));
this.pictureBox1.Image = this.bmp;
}
}
}
}
加载更多回复(14)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧