当前位置: 首页 > news >正文

壹互联是网站公司吗云南昆明做网站

壹互联是网站公司吗,云南昆明做网站,泰安网站建设培训,免费手机网站商城由于工作需要#xff0c;自己封装的基于ffmpeg的视频编解码库#xff0c;显示采用了SDL库。可以播放本地文件或网络流#xff0c;支持多端口播放#xff0c;支持文字叠加#xff0c;截图、视频录制等等。 头文件代码#xff1a; #pragma once #ifdef __DLLEXPORT #defin…        由于工作需要自己封装的基于ffmpeg的视频编解码库显示采用了SDL库。可以播放本地文件或网络流支持多端口播放支持文字叠加截图、视频录制等等。 头文件代码 #pragma once #ifdef __DLLEXPORT #define __DLL_EXP _declspec(dllexport) #else #define __DLL_EXP _declspec(dllimport) #endif #include stdio.h #include stringusing namespace std; //录像状态 enum RecordStatus {Idle,Recording,Stop };//视频存储格式 enum VideoFormat {MP4,AVI, };//图片存储格式 enum PictureFormat {JPEG,PNG,BMP, };//播放器状态 enum PlayStatus {Close,Playing,Pause };//滤镜种类 enum FilterType {Time,Reticle,Text,Other };//颜色 struct RGBAColor {BYTE R;BYTE G;BYTE B;BYTE A; };//OSD字体属性结构体struct OSDParameter {char* text;int fontSize; //汉字字号int fontFamily; //0黑体1楷体2宋体 3:ArialRGBAColor fontColor; //字体颜色 rgb表示RGBAColor backColor; //字体背景色 rgb表示float x; //字体坐标 x宽度百分比0-1float y; //字体坐标 y高度百分比0-1bool visible; //是否可见 };//格式enum FrameFormat{AUDIO16,RGB32,YV12,UVVY,YUVJ420P};struct FrameInfo {int width; //画面宽单位像素。如果是音频数据则为0int height; //画面高。如果是音频数据则为0int stamp; //时标信息单位毫秒。FrameFormat format; //数据类型0AUDIO161RGB322YUV420PYV123YUVJ420P int frameRate; //实时帧率。 };/** * 功能描述打开视频 * param nPort播放通道号[0,31] * param url视频文件或视频流地址 * param data图像控件句柄后台录制时赋值NULL * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_OpenVideo(int nPort, const char* url, const void* hWnd);/** * 功能描述 开始播放 * param nPort播放通道号[0,31] * param isRealTimePlay实时播放在需要实时播放时开启如播放摄像头流。为false时将按照帧率播放。 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_StartPlay(int nPort,bool isRealTimePlay);/** * 功能描述 暂停播放 * param nPort播放通道号[0,31] */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_PausePlay(int nPort);/** * 功能描述关闭视频释放资源 * param nPort播放通道号[0,31] */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_CloseVideo(int nPort);/** * 功能描述设置文件播放指针的相对位置百分比 * param nPort播放通道号[0,31] * param pos播放时间位置 0-100 * param fReleatePos0-100 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetPlayPos(int nPort, float fReleatePos);/** * 功能描述播放速度控制 * param nPort播放通道号[0,31] * param speed速度 0正常播放 11.25倍速 21.5倍速 31.75倍速 4:2倍速 50.75倍速 60.5倍速 70.25倍速 */ extern C __declspec(dllexport) void _stdcall VideoPlayer_ChangeSpeed(int nPort, int speed);/** * 功能描述获取当前播放时间 * param nPort播放通道号[0,31] * return 播放时间 单位秒 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_GetPlayedTime(int nPort);/** * 功能描述播放窗口缩放 * param nPort播放通道号[0,31] * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_ResizeWindow(int nPort);/** * 功能描述设置录制参数 * param nPort播放通道号[0,31] * param fps视频帧率 * param quality图像质量0-10 越高质量越好占用内存越大设置为0时为自动码率 * param duration单个文件时长(min),默认60分钟 * param frameExtractionMode:抽帧模式 0不抽帧以fps进行编码11/2 帧率以fps/2进行抽帧(保证fps/2为整数否则会出现丢帧情况) * param format:存储格式,默认为mp4 * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetRecordParameter(int nPort,int fps, float quality 5, int duration 60, int frameExtractionMode 0, VideoFormat format VideoFormat::MP4);/** * 功能描述开始录制 * param nPort播放通道号[0,31] * param path录像保存路径包含文件名 * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_StartRecord(int nPort, const char* path);/** * 功能描述结束录制 * param nPort播放通道号[0,31] */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_StopRecord(int nPort);/** * 功能描述视频截图 * param nPort播放通道号[0,31] * param path 图像保存的路径不含后缀名 * param format图像格式默认为jpeg * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_ShotImage(int nPort, const char* path, PictureFormat format PictureFormat::JPEG);/** * 功能描述设置某一行的OSD叠加文本 * param nPort播放通道号[0,31] * param osdIDOSD文本序号 * param paraosd属性 * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetOSDText(int nPort, int osdID, OSDParameter osdParam);/** * 功能描述设置所有的OSD文本总共20行 * param nPort播放通道号[0,31] * param paraosd属性 * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetAllOSDTexts(int nPort, OSDParameter osdParams[]);/** * 功能描述清除所有OSD文本 * param nPort播放通道号[0,31] * * return 成功/失败 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_ClearOSDText(int nPort);/** * 功能描述设置解码缓存队列大小 * param nPort播放通道号[0,31] * param size默认为10设置过小会丢帧设置过大可能会导致画面延迟 * * return 成功/失败 */ extern C __declspec(dllexport) void _stdcall VideoPlayer_SetDecodedBufferSize(int nPort, int size);/** * 功能描述单帧往后播放 * param nPort播放通道号[0,31] */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_NextFrame(int nPort);/** * 功能描述单帧往前播放 * param nPort播放通道号[0,31] */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_PrevFrame(int nPort);/** * 功能描述跳转视频到某一时间位置 * param nPort播放通道号[0,31] * param pos视频位置百分比 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetPlayPos(int nPort,float pos);/** * 功能描述显示/隐藏当前系统时间 * param nPort播放通道号[0,31] * param visible是否显示 * param xPos坐标位置X宽度百分比 * param yPos坐标位置Y高度百分比 * param fontSize字体大小默认50 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetDateTime(int nPort,bool visible, float xPos, float yPos,int fontSize50);/** * 功能描述当前解码完成数据回调 * param nPort播放通道号[0,31] * param pBufyuv数据指针 * param nSize数据大小 * param pFrameInfo帧信息 */ typedef void(_stdcall* DecodeCallBack)(int nPort, const unsigned char* pBuf, int nSize, FrameInfo pFrameInfo);/** * 功能描述设置解码回调函数 * param nPort播放通道号[0,31] * param pDecodeProc回调函数 */ extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetDecCallBack(int nPort, DecodeCallBack pDecodeProc);/** * 功能描述在显示句柄窗口中绘制文本、图形等 * param nPort播放通道号[0,31] * param hWnd视频窗口句柄用于创建GDI * param width视频窗口宽度 * param height视频窗口高度 */ typedef void(_stdcall* DrawCallBack)(int nPort, const void* hWnd,int width,int height);extern C __declspec(dllexport) bool _stdcall VideoPlayer_SetDrawCallBack(int nPort, DrawCallBack pDrawProc); 库支持CC#调用以下是C#调用的方法 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using VideoPlayDemo.Onvif; using static VideoPlayDemo.MYVideoPlay;namespace VideoPlayDemo {public partial class Form1 : Form{const int PLAY_PORT1 0;const int PLAY_PORT2 1;public event MYVideoPlay.DecodeCallBack decodeCallBack;public event MYVideoPlay.DrawCallBack drawCallBack;bool[] isRecording new bool[2];bool[] isOpened new bool[2];MYVideoPlay.OSDParameter[] OSDParameters1 new MYVideoPlay.OSDParameter[20];MYVideoPlay.OSDParameter[] OSDParameters2 new MYVideoPlay.OSDParameter[20];public Form1(){InitializeComponent();Timer timer new Timer();timer.Interval 100;timer.Enabled true;timer.Tick Timer_Tick;decodeCallBack new MYVideoPlay.DecodeCallBack(Form1_decodeCallBack);drawCallBack new MYVideoPlay.DrawCallBack(Form1_drawCallBack);//初始化for (int i 0; i 20; i){OSDParameters1[i] new MYVideoPlay.OSDParameter();OSDParameters1[i].visible false;OSDParameters1[i].text test中文i.ToString();OSDParameters1[i].fontSize 100;OSDParameters1[i].fontFamily 0;OSDParameters1[i].fontColor new MYVideoPlay.RGBAColor(Color.White);OSDParameters1[i].backColor new MYVideoPlay.RGBAColor(Color.Transparent);OSDParameters2[i] new MYVideoPlay.OSDParameter();OSDParameters2[i].visible false;OSDParameters2[i].text test中文 i.ToString();OSDParameters2[i].fontSize 100;OSDParameters2[i].fontFamily 0;OSDParameters2[i].fontColor new MYVideoPlay.RGBAColor(Color.Yellow);OSDParameters2[i].backColor new MYVideoPlay.RGBAColor(Color.Transparent);}}#region 视频播放控制方法/// summary/// 打开视频/// /summary/// param nameport/parampublic bool OpenVideo(int port,string url,IntPtr intPtr){bool ret false;ret MYVideoPlay.VideoPlayer_SetDecCallBack(port, decodeCallBack);if (!ret){MessageBox.Show(设置解码回调函数失败);return ret;}ret MYVideoPlay.VideoPlayer_SetDrawCallBack(port, drawCallBack);if (!ret){MessageBox.Show(设置绘图回调函数失败);return ret;}ret MYVideoPlay.VideoPlayer_OpenVideo(port, url, intPtr);if (!ret){MessageBox.Show(打开视频失败);return ret;}ret MYVideoPlay.VideoPlayer_StartPlay(port,false);if (!ret){MessageBox.Show(播放失败);return ret;}//叠加时间 // ret MYVideoPlay.VideoPlayer_SetDateTime(port, true, 0.01f, 0.01f,70);return ret;}/// summary/// 关闭视频/// /summary/// param nameport/paramprivate bool CloseVideo(int port){return MYVideoPlay.VideoPlayer_CloseVideo(port);}/// summary/// 开始录制 帧率60/// /summary/// param nameport/param/// param namehalfRate/paramprivate bool StartRecord(int port,bool halfRate){bool ret false;if(halfRate)ret MYVideoPlay.VideoPlayer_SetRecordParameter(port, 60, 5, 60,1);elseret MYVideoPlay.VideoPlayer_SetRecordParameter(port, 60, 5, 60, 0);string path string.Format(d:\\video_{0}, port);ret MYVideoPlay.VideoPlayer_StartRecord(port, path);if (!ret)MessageBox.Show(开启录制失败);return ret;}/// summary/// 停止录制/// /summary/// param nameport/paramprivate bool StopRecord(int port){bool ret MYVideoPlay.VideoPlayer_StopRecord(port);return ret;}/// summary/// 截图/// /summary/// param nameport/param/// returns/returnsprivate bool ShotImage(int port){bool ret MYVideoPlay.VideoPlayer_ShotImage(port, d:\\ port.ToString(), MYVideoPlay.PictureFormat.JPEG);return ret;}int[] frameRates new int[4];private void Form1_decodeCallBack(int nPort, IntPtr pBuf, int nSize, ref MYVideoPlay.FrameInfo pFrameInfo){frameRates[nPort] pFrameInfo.frameRate;this.Invoke((Action)delegate{this.lbFPS1.Text frameRates[0].ToString()fps;this.lbFPS2.Text frameRates[1].ToString()fps;});}private void Form1_drawCallBack(int nPort, IntPtr hWnd, int width, int height){}#endregion/// summary/// 打开视频/// /summary/// param namesender/param/// param namee/paramprivate void btnOpenVideo_Click(object sender, EventArgs e){Button btn sender as Button;int n int.Parse(btn.Tag.ToString());if (isOpened[n])return;string url;IntPtr intPtr IntPtr.Zero;switch (n){case 0: url textBox1.Text;intPtr pnlVideo1.Handle; break;case 1: url textBox2.Text;intPtr pnlVideo2.Handle; break;}Task task new Task(() {//网络直播流非相机流时设置更大的buffer进行缓存否则出现马赛克MYVideoPlay.VideoPlayer_SetDecodedBufferSize(n, 250);isOpened[n] OpenVideo(n,url,intPtr);});task.Start();}/// summary/// 关闭视频/// /summary/// param namesender/param/// param namee/paramprivate void btnCloseVideo_Click(object sender, EventArgs e){Button btn sender as Button;int n int.Parse(btn.Tag.ToString());if (!isOpened[n])return;bool ret CloseVideo(n);isOpened[n] !ret;}/// summary/// 开始录制/// /summary/// param namesender/param/// param namee/paramprivate void btnStartRecord_Click(object sender, EventArgs e){Button btn sender as Button;int n int.Parse(btn.Tag.ToString());if (isRecording[n] || !isOpened[n])return;if (n 0)isRecording[n] StartRecord(n, true);elseisRecording[n] StartRecord(n, false);}/// summary/// 停止录制/// /summary/// param namesender/param/// param namee/paramprivate void btnStopRecord_Click(object sender, EventArgs e){Button btn sender as Button;int n int.Parse(btn.Tag.ToString());if (!isRecording[n] || !isOpened[n])return;bool ret StopRecord(n);isRecording[n] !ret;}/// summary/// 截图/// /summary/// param namesender/param/// param namee/paramprivate void btnShotImage_Click(object sender, EventArgs e){Button btn sender as Button;int n int.Parse(btn.Tag.ToString());ShotImage(n);}/// summary/// 叠加字符测试/// /summary/// param namesender/param/// param namee/paramprivate void Timer_Tick(object sender, EventArgs e){Random rd new Random();bool ret false;if (isOpened[PLAY_PORT1]){OSDParameters1[0].visible OSDParameters1[1].visible true;OSDParameters1[0].x (float)rd.NextDouble();OSDParameters1[0].y (float)rd.NextDouble();OSDParameters1[1].x (float)rd.NextDouble();OSDParameters1[1].y (float)rd.NextDouble();//ZYVideoPlay.VideoPlayer_SetAllOSDTexts(PLAY_PORT1, OSDParameters1);}if (isOpened[PLAY_PORT2]){OSDParameters2[0].visible OSDParameters2[1].visible true;OSDParameters2[0].x (float)rd.NextDouble();OSDParameters2[0].y (float)rd.NextDouble();OSDParameters2[1].x (float)rd.NextDouble();OSDParameters2[1].y (float)rd.NextDouble();// ret ZYVideoPlay.VideoPlayer_SetAllOSDTexts(PLAY_PORT2, OSDParameters2);}}private void timer1_Tick(object sender, EventArgs e){if (isRecording[PLAY_PORT1]){if (DateTime.Now.Millisecond 500)lbRec1.Visible true;elselbRec1.Visible false;}elselbRec1.Visible false;if (isRecording[PLAY_PORT2]){if (DateTime.Now.Millisecond 500)lbRec2.Visible true;elselbRec2.Visible false;}elselbRec2.Visible false;}private void Form1_FormClosing(object sender, FormClosingEventArgs e){for(int i0;i2;i){if (isOpened[i])CloseVideo(i);}}} }
http://www.hkea.cn/news/14400167/

相关文章:

  • 做网站毕业设计能过吗浙江高端建设网站
  • 青岛做网站哪家好夏天做哪些网站致富
  • 做网站用的软件是什么了免费电子版个人简历可编辑
  • 网站的竞品分析怎么做公司注销后网站备案
  • 百度推广账号出售搜索引擎关键词优化技巧
  • 推广seo网站的公司如何上传自己的做的网站
  • 这几年做哪个网站能致富保定网站seo
  • 在百度云上建设网站wordpress虚拟3d网站
  • 大型网站seo方案云南营销型网站建设
  • 哪些php网站网站建设中 尽情期待
  • 跆拳道东莞网站建设如何建网站不花钱
  • 夏天做那个网站能致富mysql开发网站开发
  • 想做个网站不知道做什么wordpress怎么找到作者的分类标签
  • php网站开发案例教程 dvdqq空间可以做网站吗
  • 怎样制作个人网站老网站如何做301重定向新网站
  • 专门做字体设计的网站软件下载网站排行榜前十名
  • 国和建设集团网站新手学做网站相关书籍
  • 做海报哪个网站好wordpress扫码阅读
  • html5在线制作网站模板app设计网站模板免费下载
  • 深圳公司名称核准查询百度seo软件曝光行者seo
  • 百城建设提质工程网站四川建设网有限责任公司招聘
  • 专业零基础网站建设教学服务湖南 seo
  • 福田做网站福田网站建设福田建网站500请别人做网站注意事项
  • 家用宽带怎么做网站 访问做仪表行业推广有哪些网站
  • 信宜手机网站建设公司xyz域名
  • 网络公司网站首页图片如何看网站有没有收录
  • 网站开发项目经理职责html的网站案例
  • 现在有什么网站可以做兼职的网站页面html静态化
  • 制作一个网站费用乐清网站改版公司
  • 专业的外贸网站建设陕西建新建设有限公司网站