| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4265 人关注过本帖
标题:那位朋友能分享一下视频捕捉、压缩、传输代码,即视频会议用的代码,只提供 ...
只看楼主 加入收藏
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:10 
那位朋友能分享一下视频捕捉、压缩、传输代码,即视频会议用的代码,只提供一部分功能即可,谢谢了
那位朋友能分享一下视频捕捉、压缩、传输代码,即视频会议用的代码,只提供一部分功能即可,谢谢了

谢谢大家啦!
搜索更多相关主题的帖子: 压缩 传输 代码 视频会议 
2009-10-08 09:23
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
2009-10-08 10:44
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
但是没有视频压缩的部分
2009-10-08 10:45
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
求个C#调用摄像头的程序:https://bbs.bccn.net/thread-287603-1-1.html
这个程序也不错,也是没有压缩的部分,也没有UDP传输部分。

如果都有了就可以做视频会议了。
2009-10-08 10:47
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
2009-10-08 10:51
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
c# 压缩 和 传输
http://topic.
2009-10-08 11:01
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
程序代码:
using System;  
using System.Runtime.InteropServices;  
 
namespace VideoPreview.Utilities  
{  
    public class CCodec  
    {  
        private int hic;  
        //private IntPtr hic;  
        private COMPVARS cp;  
        private BITMAPINFO cbiIn;  
        private BITMAPINFO cbiOut;  
 
        private int dehic;  
        //private IntPtr dehic;  
        private COMPVARS decp;  
        private BITMAPINFO decbiIn;  
        private BITMAPINFO decbiOut;  
 
        public bool InitCompress(BITMAPINFOHEADER bi)  
        {  
            this.cp = new COMPVARS();  
            cp.cbSize = Marshal.SizeOf(this.cp);  
            cp.dwFlags = 1; // ICMF_COMPVAES_VALID  
            cp.fccHandler = 2021026148;  
            cp.fccType = FOURCC.ICTYPE_VIDEO;  
 
            cp.lKey = 15;  
            cp.lQ = 10000;  
 
            this.hic = ICOpen(cp.fccType, cp.fccHandler, ICMODE.ICMODE_COMPRESS | ICMODE.ICMODE_DECOMPRESS);  
            if (this.hic != 0)  
            {  
                cp.hic = this.hic;  
                cbiIn = new BITMAPINFO();  
                cbiIn.bmiHeader = bi;  
                if (ICSendMessage(this.hic, ICM_COMPRESS_GET_FORMAT, ref this.cbiIn, ref this.cbiOut) == ICERR_OK)  
                {  
                    return ICSeqCompressFrameStart(ref this.cp, ref this.cbiIn);  
                }  
                else  
                {  
                    return false;  
                }  
            }  
            else  
            {  
                return false;  
            }  
        }  
 
        public byte[] CPProcess(byte[] data)  
        {  
            if (this.hic == 0)  
            {  
                return null;  
            }  
            bool key = false;  
            int size = 0;  
            try  
            {  
                lock (data)  
                {  
                    IntPtr source = ICSeqCompressFrame(  
                        ref this.cp,  
                        0,  
                        data,  
                        ref key,  
                        ref size);  
                    if (size > 0)  
                    {  
                        byte[] cpdata = new byte[size];  
                        try  
                        {  
                            Marshal.Copy(source, cpdata, 0, size);  
                        }  
                        catch  
                        {  
                            //System.Windows.Forms.MessageBox.Show("Data array over flow!", "CompressframeError", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);  
                        }  
                        return cpdata;  
                    }  
                    else  
                    {  
                        return null;  
                    }  
                }  
            }  
            catch (System.Exception ex)  
            {  
                //System.Windows.Forms.MessageBox.Show("Compress Exception : " + ex.Message);  
            }  
            return null;  
        }  
 
        public bool InitDecompress()  
        {  
            if (this.cp.hic != 0)  
            {  
                this.decp = this.cp;  
                this.dehic = this.hic; // this.cp.hic;  
            }  
            else  
            {  
                return false;  
            }  
 
            //this.dehic = ICOpen(cp.fccType, cp.fccHandler, ICMODE.ICMODE_DECOMPRESS);  
 
            this.decbiIn = this.cbiOut;  
            this.decbiOut = this.cbiIn;  
 
            if (this.dehic != 0)  
            {  
                if (ICSendMessage(this.dehic, ICM_DECOMPRESS_BEGIN, ref this.decbiIn, ref this.decbiOut) == ICERR_OK)  
                {  
                    return true;  
                }  
                else  
                {  
                    return false;  
                }  
            }  
            else  
            {  
                return false;  
            }  
        }  
 
        public byte[] DECCPProcess(byte[] data)  
        {  
            if (this.dehic == 0)  
            {  
                return null;  
            }  
            byte[] deccpdata = new byte[this.decbiOut.bmiHeader.biSizeImage];  
            try  
            {  
                if (ICDecompress(this.dehic, 0, ref this.decbiIn.bmiHeader, data, ref this.decbiOut.bmiHeader, deccpdata) != ICERR_OK)  
                {  
                    return null;  
                }  
            }  
            catch (Exception ex)  
            {  
                //System.Windows.Forms.MessageBox.Show("Decompress Exception : " + ex.Message);  
            }  
            return deccpdata;  
        }  
 
        public void CCodecClose()  
        {  
            try  
            {  
                if (this.hic != 0)  
                {  
                    try  
                    {  
                        ICSeqCompressFrameEnd(ref this.cp);  
                    }  
                    catch { }  
                    ICClose(this.hic);  
                }  
                if (this.dehic != 0)  
                {  
                    try  
                    {  
                        ICSendMessage(hic, ICM_USER + 14, 0, 0);  
                    }  
                    catch { }  
                    ICClose(this.dehic);  
                }  
            }  
            catch { }  
        }  
2009-10-08 11:04
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
程序代码:
       #region  
        [DllImport("MSVFW32.dll")]  
        public static extern int ICCompressGetFormat(  
            //int hic,  
            IntPtr hic,  
            ref BITMAPINFO lpbiInput,  
            ref BITMAPINFO lpbiOutput  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICDecompressBegin(  
            //int hic,  
            IntPtr hic,  
            ref BITMAPINFO lpbiInput,  
            ref BITMAPINFO lpbiOutput  
            );  
 
        [DllImport("VFW32.dll")]  
        public static extern int ICDecompressGetFormat(  
            //int hic,  
            IntPtr hic,  
            ref BITMAPINFO lpbiInput,  
            ref BITMAPINFO lpbiOutput  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern void ICSeqCompressFrameEnd(ref COMPVARS pc);  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICCompressGetFormatSize(  
            int hic,  
            ref BITMAPINFO lpbiInput  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern bool ICSeqCompressFrameStart(  
            ref COMPVARS pc,  
            //ref BITMAPINFO lpbiIn  
            ref BITMAPINFO lpbiIn  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern IntPtr ICSeqCompressFrame(  
            ref COMPVARS pc,  
            uint uiFlags,  
            byte[] lpBits,  
            ref bool pfKey,  
            //ref ushort pfKey,  
            //ref long plSize  
            ref int plSize  
            );  
 
        [DllImport("MSVFW32.dll", CharSet = CharSet.Ansi)]  
        public static extern int ICGetInfo(  
            int hic,  
            ICINFO lpicinfo,  
            int cb  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern bool ICCompressorChoose(  
            IntPtr hwnd,  
            int uiFlags,  
            //int pvIn,  
            //int lpData,  
            IntPtr pvIn,  
            IntPtr lpData,  
            ref COMPVARS pc,  
            string lpszTitle  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICLocate(  
            int fccType,  
            int fccHandler,  
            ref BITMAPINFOHEADER lpbiIn,  
            ref BITMAPINFOHEADER lpbiOut,  
            short wFlags  
            );  
 
        [DllImport("MSVFW32.dll"), PreserveSig]  
        public static extern int ICOpen(uint fccType, uint fccHandler, ICMODE wMode);  
        //public static extern IntPtr ICOpen(uint fccType, uint fccHandler, uint wmode); // ICMODE wMode);  
 
        [DllImport("MSVFW32.dll"), PreserveSig]  
        public static extern int ICDecompressOpen(  
            int fccType,  
            int fccHandler,  
            ref BITMAPINFOHEADER lpbiIn,  
            ref BITMAPINFOHEADER lpbiOut  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICClose(int hic);  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICCompress(  
            int hic,  
            int dwFlags,        // flags  
            ref BITMAPINFOHEADER lpbiOutput,    // output format  
            IntPtr lpData,        // output data  
            ref BITMAPINFOHEADER lpbiInput,      // format of frame to compress  
            IntPtr lpBits,        // frame data to compress  
            int lpckid,        // ckid for data in AVI file  
            int lpdwFlags,      // flags in the AVI index.  
            int lFrameNum,      // frame number of seq.  
            int dwFrameSize,    // reqested size in bytes. (if non zero)  
            int dwQuality,      // quality within one frame  
            int lpbiPrev,      // format of previous frame  
            int lpPrev          // previous frame  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICDecompress(  
            int hic,  
            //IntPtr hic,  
            //int dwFlags,  
            uint dwFlags,  
            ref BITMAPINFOHEADER lpbiFormat,  
            byte[] lpData,  
            ref BITMAPINFOHEADER lpbi,  
            byte[] lpBits  
            );  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICSendMessage(int hic, int msg, ref BITMAPINFO dw1, ref BITMAPINFO dw2);  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICSendMessage(int hic, int msg, int dw1, int dw2);  
 
        [DllImport("MSVFW32.dll")]  
        public static extern int ICSendMessage(int hic, int msg, ICINFO dw1, int dw2);  
        public static readonly int DRV_USER = 0x4000;  
        public static readonly int ICM_USER = (DRV_USER + 0x0000);  
        public static readonly int ICM_COMPRESS_BEGIN = (ICM_USER + 7);    // begin a series of compress calls.  
        public static readonly int ICM_COMPRESS = (ICM_USER + 8);  // compress a frame  
        public static readonly int ICM_COMPRESS_END = (ICM_USER + 9);  // end of a series of compress calls.  
        public static readonly int ICM_COMPRESS_GET_FORMAT = (ICM_USER + 4);  
        public static readonly int ICM_DECOMPRESS_BEGIN = (ICM_USER + 12);  // start a series of decompress calls  
        public static readonly int ICM_DECOMPRESS = (ICM_USER + 13);  // decompress a frame  
        public static readonly int ICM_DECOMPRESS_END = (ICM_USER + 14);  
 
        public static readonly int ICERR_OK = 0x0;  
        #endregion  
    }  
}  

 
用的是Divx编码器。
2009-10-08 11:05
srxljl
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-5-10
收藏
得分:0 
听别人说要用 VoIP基本概念:H.323协议
简介:http://www.

1、“视频流采集->MPEG4,H.263,H.264压缩算法压缩视频->传输->接收解码   
  H.323协议”

2、“h323+mpeg4+扩展=DivX。   
  不只你的视频会议系统的设计带宽是多少,带宽太低就要增加采样的次数来降低传输的量并增加画面质量,可惜这样又要特殊的硬件支持,增加了成本。”

3、“建议使用sip协议,h323本来就不是为internet应用的,对Qos支持也不好,而且323协议又相当复杂,sip就简单的多了,国外有些公司的系统就是支持sip的,”

[ 本帖最后由 srxljl 于 2009-10-8 13:56 编辑 ]
2009-10-08 13:41
swc
Rank: 3Rank: 3
等 级:论坛游民
威 望:6
帖 子:394
专家分:83
注 册:2006-4-7
收藏
得分:0 
要把采集到的图像用H.264来压缩是很大的工程,一方面建议在CSDN下载里头寻找相关代码(不一定有);一方面采用包含压缩编码的视频采集卡(可以更换采集卡的前提下)。

实践、学习、再实践、再学习......
2009-10-09 09:11
快速回复:那位朋友能分享一下视频捕捉、压缩、传输代码,即视频会议用的代码,只 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049218 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved