解决方案 »
- C# socket.Client.Receive(Rece); 如何判断有无接收数据,并正常执行。
- 初学者问题之八:对TextBox值的验证
- 给指定的ELEMENT追加一个属性节点如何操作(在线等待,谢谢!)
- c#程序的打包问题
- 如何设置DataColumn的取值范围?
- vs2008 C#格式化代码的快捷键是什么?
- 高分请人帮忙优化下代码的。。。。[在线等======]
- webbrowser显示网页内容的问题?
- C#(2003) Odbc 执行事务时的一个奇怪问题.....大家来看看啊
- C# 的变量命名规范 我写了一份,请帮忙改一下.......
- 请教下json字符串转datatable出现问题
- .net mvc: Viewbag 大小影响 网页速度吗??
//自定义类实现截取视频路径和保存路径
//获取转换工具路径
public static string ffmpegtool = ConfigurationManager.AppSettings["ffmpeg"];
//获取视频的文件夹名
public static string upFile = "upfile/";
//获取图片文件的文件夹名
public static string imgFile = "imgFile/";
//获取转换后文件的文件夹名
public static string playFile = "playFile/";
//文件图片大小
public static string sizeOfImg = ConfigurationManager.AppSettings["imgSize"];
//文件大小
public static string widthOfFile = ConfigurationManager.AppSettings["widthSize"];
public static string heightOfFile = ConfigurationManager.AppSettings["heightSize"];
//截取视频图片
public static void catchImg(string fileName,string imgFile)
{
//获取截图工具路径
string ffmpeg = System.Web.HttpContext.Current.Server.MapPath("../") + ffmpegtool;
//获取截图后保存的路径
string flv_img = imgFile;
//获取截取图片的大小
string FlvImgSize = sizeOfImg;
Process pss = new Process();
//设置启动程序的路径
pss.StartInfo.FileName = ffmpeg;
pss.StartInfo.Arguments = " -i " + fileName + " -y -f image2 -ss 2 -vframes 1 -s " + FlvImgSize + " " + flv_img;
//启动进程
pss.Start();
}//codego.net/tags/11/1/
// 过滤HTML字符
// <param name="str">传入需要过滤的字符串</param>
// <returns>返回过滤后的字符串</returns>
public static string filtrateHtml(string str)
{
str = str.Trim();
str = str.Replace("'", """);
str = str.Replace("<", "<");
str = str.Replace(">", ">");
str = str.Replace(" ", " ");
str = str.Replace("\n", "<br>");
return str;
}
// 恢复HTML字符
// <param name="str">传入需要回复的字符串</param>
// <returns>返回回复后的字符串</returns>
public static string resumeHtml(string str)
{
str = str.Trim();
str = str.Replace(""", "'");
str = str.Replace("<", "<");
str = str.Replace(">", ">");
str = str.Replace(" ", " ");
str = str.Replace("<br>", "\n");
return str;
}
http://bbs.csdn.net/topics/380172482
使用了以下命令:
ffmpeg.exe -i aaa.mp4 -y -f image2 -ss 2 -vframes 1 -s 240x320 1.jpg结果得到一个一片黑的图片啊
用ffmpeg获取的是全黑图片啊
{
return null;
}
SystemApi.RECT rc = new SystemApi.RECT();
SystemApi.GetWindowRect(hwnd, out rc);
SystemApi.PointApi p = new SystemApi.PointApi();
SystemApi.ScreenToClient(hwnd, out p);
//设置客户区的坐标
SimulatorInfo.MainClientLack = new Point(Math.Abs(p.x) - rc.left, Math.Abs(p.y) - rc.top); SystemApi.RECT rcc = new SystemApi.RECT();
SystemApi.GetClientRect(hwnd, out rcc);
dc1 = SystemApi.CreateDC("DISPLAY", null,
null, (IntPtr)null);
//创建显示器的DC
Graphics g1 = Graphics.FromHdc(dc1);
//由一个指定设备的句柄创建一个新的Graphics对象
MyImage = new Bitmap(rcc.right, rcc.bottom, g1);
//根据屏幕大小创建一个与之相同大小的Bitmap对象
Graphics g2 = Graphics.FromImage(MyImage);
//获得屏幕的句柄
dc3 = g1.GetHdc();
//获得位图的句柄
dc2 = g2.GetHdc();
//把当前屏幕捕获到位图对象中
SystemApi.BitBlt(dc2, 0, 0, rcc.right,
rcc.bottom,
dc3, Math.Abs(p.x), Math.Abs(p.y), 13369376);
//把当前屏幕拷贝到位图中
g1.ReleaseHdc(dc3);
//释放屏幕句柄
g2.ReleaseHdc(dc2);
//释放位图句柄
g1.Dispose();
g2.Dispose();
return MyImage;
[DllImport("user32.dll")]
public static extern int ScreenToClient(IntPtr hWnd, out PointApi lpRect);
public struct PointApi
{
public int x;
public int y;
}
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll")]
public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("gdi32.dll")]
public static extern IntPtr CreateDC(
string lpszDriver, // driver name驱动名
string lpszDevice, // device name设备名
string lpszOutput, // not used; should be NULL
IntPtr lpInitData // optional printer data
);
[DllImport("gdi32.dll")]
public static extern bool BitBlt(
IntPtr hdcDest, // 目标 DC的句柄
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc, // 源DC的句柄
int nXSrc,
int nYSrc,
int dwRop // 光栅的处理数值
);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string className, string windowTitle);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
[DllImport("user32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); public static void Click(IntPtr mnqhwnd, Point P)
{
SendMessage(mnqhwnd, 0x201, 0, MakeLParam(P.X, P.Y));
SendMessage(mnqhwnd, 0x202, 0, MakeLParam(P.X, P.Y));
}
public static int MakeLParam(int LoWord, int HiWord)
{
return ((HiWord << 16) | (LoWord & 0xffff));
}
也不是播放视频时截图。要实现像Windows资源管理器里面显示视频文件的缩略图那样。
想知道Windows自己是怎么做到的。应该是通过Shell API吧。
查到了Windows有个API:IThumbnailCache,但实在不知道怎么用,尤其在C#下面。