全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:8157
推到 Plurk!
推到 Facebook!
[<<] [1] [2] [>>]

影像壓縮!!

 
RickyT
一般會員


發表:15
回覆:25
積分:13
註冊:2002-06-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-06-22 21:11:32 IP:210.58.xxx.xxx 未訂閱
請為各位前輩..我已經寫了一個程式可以把CCD的影像錄成AVI的格式,但是檔案量非常的大,請問該如何錄成其他壓縮的格式如MPEG,ASF,RM...的格式呢??請各位大大指導一下囉.. ^^
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-06-24 10:39:38 IP:61.218.xxx.xxx 未訂閱
試試這個說明文件 ftp://ftp.microsoft.com/developr/drg/multimedia/avi-mpeg/avimpg.zip 或者到ftp://ftp.microsoft.com/developr/drg/multimedia/ 下找一找 關於RM格式,請到http://www.real.com/ 找一找 或者到ISO http://www.iso.ch的網站去找一找!不過文件是要錢的! 發表人 - axsoft 於 2002/07/11 14:10:44
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-06-24 10:50:31 IP:61.218.xxx.xxx 未訂閱
ASF 格式 資料來源:Microsoft http://www.microsoft.com/windows/windowsmedia/WM7/format/asfspec11300e.asp The Advanced Systems Format (ASF) is the file format used by Windows Media Technologies. Audio and/or Video content compressed with a wide variety of codecs can be stored in an ASF file and played back with the Windows Media Player (provided the appropriate codecs are installed), streamed with Windows Media Services or optionally packaged with Windows Media Rights Manager. The Advanced Systems Format (ASF) is an extensible file format designed to store synchronized multimedia data. It supports data delivery over a wide variety of networks and protocols while still proving suitable for local playback. ASF supports advanced multimedia capabilities including extensible media types, component download, scaleable media types, author-specified stream prioritization, multiple language support, and extensive bibliographic capabilities, including document and content management. Hardware or software developers that wish to create or read ASF structured files, may download the ASF Specification from this web site. Windows software developers are encouraged to use the available Windows Media SDKs, which include support for creating and reading Windows Media content including ASF files. Hardware manufacturers may also wish to license the Windows Media Embedded PAK which includes Windows Media and ASF support optimized for various embedded processors. Windows Media SDKs: http://www.microsoft.com/windows/windowsmedia/create/develop.asp Download the Specification Now! http://download.microsoft.com/download/winmediatech40/Doc/1.0/WIN98MeXP/EN-US/ASF_Specification_v.1.0.exe
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-06-24 11:01:35 IP:61.218.xxx.xxx 未訂閱
QuickTime檔案格式: formats: .PKG .M2S .MPEG .MPG .MPGX .MPM .MOV .QT .QTIF .QTI [Shane Weber] http://www.wotsit.org/download.asp?f=quicktime MPEG-4 Audio Reference Software (C code) [Various Authors] http://www.wotsit.org/download.asp?f=mpeg4 ISO/IEC 13818-3 MPEG-2 Audio (MS Word) [ISO/IEC] http://www.wotsit.org/download.asp?f=mpeg2-3
RickyT
一般會員


發表:15
回覆:25
積分:13
註冊:2002-06-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-07-22 23:27:37 IP:210.58.xxx.xxx 未訂閱
感謝各位大大...我在BCB的SDK中已經找到一個壓縮工具,只是壓起來還是AVI的格式就是了..但是各位大大提供的資料我還是會努力去研究研究的..感激不盡囉!! ^^
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-07-23 08:42:57 IP:61.218.xxx.xxx 未訂閱
引言: 感謝各位大大...我在BCB的SDK中已經找到一個壓縮工具,只是壓起來還是AVI的格式就是了..但是各位大大提供的資料我還是會努力去研究研究的..感激不盡囉!! ^^
不知您在BCB的SDK中找到一個壓縮工具是一個怎麼樣的東西? 如果您研究出來的抓影像及壓縮方法結果可否公開給大夥參考! 時間就是金錢---[ 發問前請先找找舊文章] 發表人 - axsoft 於 2002/07/23 08:45:43
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-07-23 08:54:40 IP:61.218.xxx.xxx 未訂閱
這裡有一個很完整的影像檔案解壓/壓縮格式說明!    有C的Source Code可以參考喔!     http://www.webartz.com/fourcc/indexcod.htm 時間就是金錢---[ 發問前請先找找舊文章] 發表人 - axsoft 於 2002/07/23 08:56:16
天外來客
初階會員


發表:22
回覆:199
積分:44
註冊:2001-11-27

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-07-23 10:28:59 IP:163.28.xxx.xxx 未訂閱
我是用capDlgVideoCompression函式來處理壓縮的,安裝BCB5.x企業版選擇完全安裝就會有了,原本一分鐘的AVI影像要90幾M的空間,壓縮後只剩300多K而已喔~~ 另外可以用capDlgVideoFormat來設定影像格式,詳細的說明再help裡的windows SDK有說明..可以參考看看.. ^^
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#9 引用回覆 回覆 發表時間:2002-07-23 17:13:29 IP:61.218.xxx.xxx 未訂閱
To 天外來客:
引言: 我是用capDlgVideoCompression函式來處理壓縮的,安裝BCB5.x企業版選擇完全安裝就會有了,原本一分鐘的AVI影像要90幾M的空間,壓縮後只剩300多K而已喔~~ 另外可以用capDlgVideoFormat來設定影像格式,詳細的說明再help裡的windows SDK有說明..可以參考看看.. ^^
那可否將您的源碼Post上來給大家參考一下!我找了一下BCB5企業版裡好像沒您說的函式耶? 時間就是金錢---[ 發問前請先找找舊文章]
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#10 引用回覆 回覆 發表時間:2002-07-24 22:13:45 IP:61.70.xxx.xxx 未訂閱
引言: To 天外來客:
引言: 我是用capDlgVideoCompression函式來處理壓縮的,安裝BCB5.x企業版選擇完全安裝就會有了,原本一分鐘的AVI影像要90幾M的空間,壓縮後只剩300多K而已喔~~ 另外可以用capDlgVideoFormat來設定影像格式,詳細的說明再help裡的windows SDK有說明..可以參考看看.. ^^
那可否將您的源碼Post上來給大家參考一下!我找了一下BCB5企業版裡好像沒您說的函式耶? 時間就是金錢---[ 發問前請先找找舊文章]
上述cap開頭的函式都是window SDK, 不是BCB的函式, 只是BCB引用它吧... 底下是我寫的程式, 不過是delphi code, 差不多啦.. capCaptureGetSetup(hVideoWnd, @CapParam, sizeof(CapParam)); CapParam.fAbortLeftMouse := False; CapParam.fAbortRightMouse := False; CapParam.fYield := True; CapParam.dwRequestMicroSecPerFrame := 1000000 div 20; //20 FPS capCaptureSetSetup(hVideoWnd, @CapParam, sizeof(CapParam)); capPreviewRate(hVideoWnd,100); capOverlay(hVideoWnd, True); // capPreview(hVideoWnd,true); // capDlgVideoSource(hVideoWnd); // capDlgVideoFormat(hVideoWnd); // capDlgVideoDisplay(hVideoWnd); // capDlgVideoCompression(hVideownd); StartBtn.Enabled := False; StopBtn.Enabled := True; if (ICCompressBegin(hIC, @EncBiIn, @EncBiOut)<>ICERR_OK) then begin MessageBox(Handle, 'Error Initializing compressor', 'error', MB_OK or MB_ICONSTOP); exit; end; 要停止時使用下列函式 capCaptureSequenceNoFile(hVideoWnd); gogowin
------
gogowin
RickyT
一般會員


發表:15
回覆:25
積分:13
註冊:2002-06-15

發送簡訊給我
#11 引用回覆 回覆 發表時間:2002-07-24 22:32:12 IP:210.58.xxx.xxx 未訂閱
抱歉抱歉...那個確實是Windows SDK的東東啦..是我沒講清楚..感謝Help的指教喔.. ^^ 另外axsoft大大我提供程式碼當然是沒問題囉..但是因為已經累積了一些東西了,不知道您是要哪一段??或者是有需要的話我可以把source code mail給你也可以啊.. ^^ 另外那些cap開頭的函式是在vfw.h裡的,必須要在安裝BCB時選擇完全安裝才會有喔... ^^ 另外另外請教各位大大一個問題,就是現在我面臨要把CCD影像由server端透過TCP/IP傳送到client端,請問一下該怎麼做會比較好比較有效率呢??找了很多資料但是還是理不出頭緒ㄋㄟ...麻煩各位救救命囉.. ^^~
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#12 引用回覆 回覆 發表時間:2002-07-25 08:53:41 IP:61.218.xxx.xxx 未訂閱
引言: 抱歉抱歉...那個確實是Windows SDK的東東啦..是我沒講清楚..感謝Help的指教喔.. ^^ 另外axsoft大大我提供程式碼當然是沒問題囉..但是因為已經累積了一些東西了,不知道您是要哪一段??或者是有需要的話我可以把source code mail給你也可以啊.. ^^ 另外那些cap開頭的函式是在vfw.h裡的,必須要在安裝BCB時選擇完全安裝才會有喔... ^^ 另外另外請教各位大大一個問題,就是現在我面臨要把CCD影像由server端透過TCP/IP傳送到client端,請問一下該怎麼做會比較好比較有效率呢??找了很多資料但是還是理不出頭緒ㄋㄟ...麻煩各位救救命囉.. ^^~
有關資料傳送您可以參考這一篇 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=19377 裡頭的SDK有談到影像傳送的架構!如果在區域網路裡建議用UDP如果是Internet上可使用RTP/RTCP協定,但RTP/RTCP以及UDP都有防火牆的問題! 我想瞭解您Capture及影像壓縮部分的程式碼!參考一下您的構思!不知有沒有人有用DirectShow來處理這一部份的東西,聽說效能比VFW好一些! 時間就是金錢---[ 發問前請先找找舊文章] 發表人 - axsoft 於 2002/07/25 08:57:29
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#13 引用回覆 回覆 發表時間:2002-07-27 13:26:17 IP:61.70.xxx.xxx 未訂閱
要傳送影像可用UDP. overhead最低. 我是用delphi的UDP元件做的. 不過firewall當然是會有問題. 因為需要一個固定IP. 不過可以指定PORT, 或許就可以通過防火牆.... gogowin
------
gogowin
changyu
一般會員


發表:9
回覆:18
積分:5
註冊:2002-04-23

發送簡訊給我
#14 引用回覆 回覆 發表時間:2002-07-28 01:50:35 IP:61.224.xxx.xxx 未訂閱
對不起,對於壓縮方面小弟也是遇到瓶頸 help大大,因小弟看不大懂,可否請您多講一點 讓小弟能有所了解,謝謝,麻煩您了
RickyT
一般會員


發表:15
回覆:25
積分:13
註冊:2002-06-15

發送簡訊給我
#15 引用回覆 回覆 發表時間:2002-07-30 01:09:23 IP:210.58.xxx.xxx 未訂閱
axsoft大大~~ 以下是我的部分程式碼,大家可以參考看看給點意見喔~~ ^^ capture的部分,以下可產生預視~~ hCapWnd = capCreateCaptureWindow("My Capture Window", WS_CHILD |WS_VISIBLE,0, 0, 400, 300,Form1->Handle, 0);//產生預視視窗 capDriverConnect (hCapWnd, 0);//連接CCD裝置 capPreview(hCapWnd,true);//啟動預視 capPreviewRate(hCapWnd,2);//設定畫面更新率 capOverlay(hCapWnd,true); BITMAPINFO bmi; capGetVideoFormat(hCapWnd, &bmi, sizeof(BITMAPINFO)); SetWindowPos(hCapWnd, 0, 25, 25, bmi.bmiHeader.biWidth,bmi.bmiHeader.biHeight,0); 以下可存檔成AVI格式~~ char save_path[50] ; strcpy(save_path,Form1->Edit1->Text.c_str()); capFileSetCaptureFile(hCapWnd,save_path);//設定存檔路徑檔名 capCaptureSequence(hCapWnd);//存取畫面視訊流 capCaptureStop(hCapWnd);//停止錄影 壓縮部分~~ 在開始錄影前呼叫capDlgVideoCompression()函數設定壓縮格式即可壓縮.. 至於DirectShow的方式我不知道耶...哪裡有相關的資料可參考嗎?? ^^
changyu
一般會員


發表:9
回覆:18
積分:5
註冊:2002-04-23

發送簡訊給我
#16 引用回覆 回覆 發表時間:2002-07-31 02:34:48 IP:61.216.xxx.xxx 未訂閱
RickyT 大大 我試了一下您的程式,可以正確的看到影像也可存下avi檔 不過檔案還是無法壓縮,請問是哪裡的問題呢,謝謝。 capDlgVideoCompression(),我是放在capDriverConnect (hCapWnd, 0); 後面。
RickyT
一般會員


發表:15
回覆:25
積分:13
註冊:2002-06-15

發送簡訊給我
#17 引用回覆 回覆 發表時間:2002-08-01 00:48:42 IP:210.58.xxx.xxx 未訂閱
應該是要在開始preview後&存檔前,去呼叫capDlgVideoCompression()函數才行喔..你可以試試先讓程式開始preview後,使用獨立的一個button去呼叫壓縮的函式,會跳出一個form,有一些選項可以設定..設定玩後再存檔.. ^^
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#18 引用回覆 回覆 發表時間:2002-08-01 13:52:11 IP:61.70.xxx.xxx 未訂閱
用DlgCompression()或許可以, 不過我是用 ICOpen來將壓縮格式設定為MPEG4, 當然, 你的電腦必須先將有這個driver. 可安裝免費的Widows media SDK 8.0就可以有了. 使用時,code如下: hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); 還要有一個VFW 模組. 粉麻煩的啦.... 你可參考windows SDK關於ICOPEN的部份... gogowin
------
gogowin
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#19 引用回覆 回覆 發表時間:2002-08-01 18:59:09 IP:61.218.xxx.xxx 未訂閱
引言: 用DlgCompression()或許可以, 不過我是用 ICOpen來將壓縮格式設定為MPEG4, 當然, 你的電腦必須先將有這個driver. 可安裝免費的Widows media SDK 8.0就可以有了. 使用時,code如下: hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); 還要有一個VFW 模組. 粉麻煩的啦.... 你可參考windows SDK關於ICOPEN的部份... gogowin
可否請您Help(Pai Roger)先生花些時間講解一下! 解壓還原如何實做?可否說說您的寫法? 時間就是金錢---[ 發問前請先找找舊文章] 發表人 - axsoft 於 2002/08/01 19:02:38
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#20 引用回覆 回覆 發表時間:2002-08-02 11:29:12 IP:61.218.xxx.xxx 未訂閱
引言: 用DlgCompression()或許可以, 不過我是用 ICOpen來將壓縮格式設定為MPEG4, 當然, 你的電腦必須先將有這個driver. 可安裝免費的Widows media SDK 8.0就可以有了. 使用時,code如下: hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); 還要有一個VFW 模組. 粉麻煩的啦.... 你可參考windows SDK關於ICOPEN的部份... gogowin
我找了一些相關資訊 資料來源:http://www.leadtools.com/video-codec_API.htm How Can a Developer Integrate LEAD's Video Codecs Into an Application? A video codec can be used to compress or decompress a series of images automatically (using DirectShow or with Video for Windows capture) or programmatically (where the user opens the codec and asks it to compress one frame at a time). This is useful for developers that want to quickly compress to memory a large number of DIBs and wants to insert the result into a database or a file format not supported by DirectShow. The following information describes how to use the codec from within an application that is being developed. Additionally, information is included concerning how to programmatically override the compression settings that are set in the compression dialog. This information applies to the LEAD Video Codec and to most Video for Windows codecs. All Video for Windows codecs should implement these messages that are called using DriverProc. The constants and structures below are defined in the Video for Windows SDK. Background Information on Video for Windows Codecs * Video for Windows communicates with installed codecs via the DriverProc function that every codec exports. The function prototype and explanation on the parameters can be found in MSDN help (search for DriverProc). The DriverProc function is used in all drivers, not only VFW drivers (for example, in CD_ROM drivers). The DriverProc function is obtained like this: hInst = LoadLibrary("CODEC.DLL"); pfnDriverProc = GetProcAddress(hInst, "DriverProc"); * For VFW codecs, the messages below are important: DRV_LOAD DRV_FREE DRV_OPEN /* lParam2 is a pointer to an ICOPEN structure */ DRV_QUERYCONFIGURE DRV_CONFIGURE DRV_DISABLE DRV_ENABLE DRV_INSTALL DRV_REMOVE /** configuration/miscellaneous messages */ ICM_CONFIGURE ICM_ABOUT ICM_GETSTATE ICM_SETSTATE /* especially useful for overriding the compression settings */ ICM_GETINFO ICM_SET_STATUS_PROC ICM_GETQUALITY ICM_GETDEFAULTQUALITY ICM_SETQUALITY /** compress messages **/ ICM_COMPRESS_QUERY ICM_COMPRESS_BEGIN ICM_COMPRESS_GET_FORMAT ICM_COMPRESS_GET_SIZE ICM_COMPRESS ICM_COMPRESS_END /** decompress format query messages **/ ICM_DECOMPRESS_GET_FORMAT ICM_DECOMPRESS_GET_PALETTE /** decompress messages **/ ICM_DECOMPRESS_QUERY ICM_DECOMPRESS_BEGIN ICM_DECOMPRESS ICM_DECOMPRESS_END ICM_DECOMPRESSEX_QUERY ICM_DECOMPRESSEX_BEGIN ICM_DECOMPRESSEX ICM_DECOMPRESSEX_END Information on each message can be found in MSDN. Below is additional information on some of the messages: First example In the information below, the mentioning of a message means that the DriverProc is called with that message. For example, DRV_LOAD /* -> would be implemented as -> */ DriverProc(0, 0, DRV_LOAD, 0, 0); /* The documentation says that most parameters are ignored, so just pass 0).*/ Second example: DRV_OPEN /* (the codec will allocate a INSTINFO pointer. Use it in all the communication with the codec).*/ /* -> would be implemented as -> */ void *pInst; ICOPEN icOpen; // initialize the ICOPEN structure icOpen.dwSize = sizeof(ICOPEN); icOpen.fccType = ICTYPE_VIDEO; icOpen.fccHandler = mmioFOURCC('L','E','A','D'); /*for our codec*/ icOpen.dwVersion = 0; /* our codec ignores this */ icOpen.dwFlags = ICMODE_QUERY; /* just testing */ icOpen.pV1Reserved = icOpen.pV2Reserved = NULL; /*ignored*/ icOpen.dnDevNode = 0; /*ignored*/ // send the DRV_OPEN message pInst = DriverProc(hInstance, 0, DRV_OPEN, 0, &icOpen); /* the returned value would be passed to in all the calls to the DriverProc from now on until DRV_CLOSE. If the function returns NULL, then icOpen.dwError contains the error code. if pInst is not NULL, then it is a pointer to an internal structure allocated by the codec. The codec will use this structure to store all the information it needs. */ Third example: DRV_CLOSE /* (let the codec free the INSTINFO structure and any other memory allocated inside the codec). After this, the INSTINFO structure becomes invalid) */ /* -> would be implemented as -> */ DriverProc((DWORD)pInst, hInstance, DRV_CLOSE, 0, 0); /* Note that the codec will free pInst and you shouldn't use this pointer anymore */ Explaination of Messages by Grouped by Functionality Initialize/free the codec * DRV_LOAD - Required before you do anything with the codec. * DRV_OPEN - The codec will allocate an INSTINFO pointer. Use the pointer to that structure in all communications with the codec. * DRV_CLOSE Allows the codec to free the INSTINFO structure and any other memory allocated inside the codec. * DRV_FREE - After this, the INSTINFO structure becomes invalid. Compression Use the following messages, preferably in the order below. * ICM_COMPRESS_QUERY - Query the codec to discover if it supports compressing this DIB format. * ICM_ SETSTATE - Optional, but useful for controlling the compression settings. * ICM_COMPRESS_GET_FORMAT - Get the DIB that will contain information needed by the decompressor. This information is common to all the frames. * ICM_COMPRESS_GET_SIZE Get the maximum size needed to hold one frame. Allocate a buffer of at least this size and pass this buffer to the compressor. * ICM_COMPRESS_BEGIN - Start compressing, let the codec perform any initialization necessary for compression. * ICM_COMPRESS - Compress one frame into the buffer supplied. ICCOMPRESS.lpbiOutput.biSizeImage contains the size of the compressed data. ICCOMPRESS.lpOutput will contain the compressed data. * ICM_COMPRESS_END - Free any memory allocated for compression. Decompression Use the following messages, in the order below: * ICM_DECOMPRESS_QUERY -Query the codec to see if it can decompress this DIB format. You should pass the DIB returned by ICM_COMPRESS_GET_FORMAT. * ICM_DECOMPRESS_BEGIN - Start decompressing. * ICM_DECOMPRESS - Decompress one frame. The ICDECOMPRESS fields are: o lpbiInput: the input DIB format lpbiInput->biSizeImage needs to be the size of the current compressed data. You need to set this before you decompress each frame. o lpInput points to the compressed data o lpbiOutput is the format of the decompressed data. o lpOutput points to the compressed data. The size of the input data can be different than the size of the output data. If they are different, the LEAD codec will resize and convert the data. For example, a 640x480x24bpp compressed image can de resized to 326x245x16bpp during decompression. The LEAD codec can convert to 8-bit or 16-bit data. There are no restrictions on the resize. Additionally, you need to follow the DIB convention: when biHeight is >0, the image is upside down (BOTTOM_LEFT). When biHeight <0, the image is upside up (TOP_LEFT). * ICM_DECOMPRESS_END You can also use the ICM_DECOMPRESSEX, ICM_DECOMPRESSEX_BEGIN and ICM_DECOMPRESSEX_END messages. Example: /* This is an example of a function that checks that the codec can convert images of type lpbi1 into images of type lpbi2 Return value: TRUE - yes, we can compress lpbi1 into lpbi2 FALSE - no, we can't compress */ BOOL CanCompress(LPBITMAPINFOHEADER lpbi1, LPBITMAPINFOHEADER lpbi2) { ICOPEN icOpen; DWORD pInst; //** DRV_LOAD ** load the driver DriverProc(0, NULL, DRV_LOAD, 0, 0); //** DRV_OPEN ** // initialize the icOpen structure icOpen.dwSize = sizeof(icOpen); icOpen.fccType = ICTYPE_VIDEO; icOpen.fccHandler = mmioFOURCC('L','E','A','D'); icOpen.dwFlags = ICMODE_QUERY; // send the DRV_OPEN message // although the value returned is a pointer to a structure, we can store // it in a DWORD structure for simplicity pInst = DriverProc(0, NULL, DRV_OPEN, 0, (DWORD)&icOpen); if(!pInst) { // an error has occured return FALSE; // error } //** ICM_COMPRESS_QUERY ** // initialize lpbi1 and lpbi2 ... // send the ICM_COMPRESS_QUERY lRet = DriverProc(pInst, NULL, ICM_COMPRESS_QUERY, (LPARAM)lpbi1, (LPARAM)lpbi2); //** DRV_CLOSE DriverProc(pInst, NULL, DRV_CLOSE, 0, (DWORD)&icOpen); //** DRV_FREE ** DriverProc(0, NULL, DRV_FREE, 0, 0); // we can do the compression only if lRet is ICERROR_OK return lRet == ICERR_OK; } Controlling the compression settings Normally, when you open a instance of the codec for compression, the compression settings are those set in the configuration dialog. You can programmatically override the compression settings by using the ICM_SETSTATE message (or the ICSetState macro). You can control the output format using the two parameters for the ICM_SETSTATE message: wParam: Value specifies the format of the output data. The allowed values are: mmioFOURCC('L','j','p','g') - use lossless compression mmioFOURCC('L','J','1','1') - use JPEG 4:1:1 compression mmioFOURCC('L','J','2','2') - use JPEG 4:2:2 compression mmioFOURCC('L','J','4','4') - use JPEG 4:4:4 compression In all of these cases, the codec assumes that you are going to use the individual frames; therefore, the output is saved as regular lossless JPEG files or regular lossy JPEG files. This means that the Huffman tables will be written in the file (MJPG frames do not always contain Huffman tables to optimize the size) and that the interleave option will be ignored (data AVI MJPG files might use this option to reduce the size for videos that came from interlaced cameras). lParam: set to 4 (the sizeof(DWORD)) Example: hLEADIC = ICOpen(ICTYPE_VIDEO, mmioFOURCC('L', 'E','A','D'), ICMODE_COMPRESS); // override the compression setting to create JPEG 4:2:2 files ICSetState(hLEADIC, mmioFOURCC('L','J','2','2'), 4); // ... perform the rest of the compression process as usual... 時間就是金錢---[ 發問前請先找找舊文章]
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#21 引用回覆 回覆 發表時間:2002-08-05 09:51:05 IP:61.70.xxx.xxx 未訂閱
版主, 抱歉忙到今天才回覆. 當程式用capCapture不斷地抓入影像資料時,這個資料其實是以 PVEDIOHDR的結構放在記憶體之中, 這是一頁一頁的影像資料, 攝影機每抓好一頁就會啟動 VidoeCallBackProc一次. 而若你要壓縮這個影像資料, 可以叫用ICCompress這個函數(Windows SDK)。 但是叫用之前要先用 hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); 來設定用那個driver來壓縮 上面的例子就是設定為MPEG4。 你注意到了其中有一個mmioFourCC('M','P','4','2')參數了嗎?(其它的是constant, 參考SDK說明文件) 這是一個VFW的函數, 設定一個4碼的代碼. 每一個驅動程式都有一個代碼, 例如DIVX就是'D','I','V','X' 設定完了之後, 再用 ICCompressBegin(hIC, @EncBiIn, @EncBiOut); 啟始之後, 就可以用 ICCompress(hic, dwFlags, @EncBiOut.bmiHeader, CodeDest, @EncBiIn.bmiHeader, CodeSrc, Nil, @dwFlags, FrameNo, 0, 0, Nil, Nil); 來開始壓縮每一個影像頁(由上例中, 待壓縮的資料是放在CodeSrc參數所指向的位址) 壓縮完之後, 壓縮的結果也在記憶體中(CodeDest所指向的位址). 對了, EnbiOUTBMI的內容也要先設定,(一樣可查SDK文件) 用完了,再叫用 ICCompressEnd(hic); ICClose(hic); 來結朿壓縮函式. 解壓縮則是用ICDecopress 其實真的很麻煩喔...................................... 範例片段: 宣告 EncBiIn, EncBiOut: BITMAPINFO; 執行 VideoW := 352; VideoH := 288; CodeSrc := PChar(AllocMem(VideoW*VideoH*3 64)); CodeDest := PChar(AllocMem(VideoW*VideoH*3 64)); // hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('D','I','V','X'), ICMODE_FASTCOMPRESS); hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); if hic=0 then MessageBox(Handle, 'Error Init compressor', '', MB_OK); EncBiIn.bmiHeader.biSize := sizeof(BITMAPINFOHEADER); EncBiIn.bmiHeader.biCompression := BI_RGB; EncBiIn.bmiHeader.biWidth := VideoW; EncBiIn.bmiHeader.biHeight := VideoH; EncBiIn.bmiHeader.biPlanes := 1; EncBiIn.bmiHeader.biBitCount := 24; EncBiIn.bmiHeader.biSizeImage := EncBiIn.bmiHeader.biWidth*EncBiIn.bmiHeader.biHeight*EncBiIn.bmiHeader.biPlanes*(EncBiIn.bmiHeader.biBitCount div 8); EncBiIn.bmiHeader.biXPelsPerMeter := 0; EncBiIn.bmiHeader.biYPelsPerMeter := 0; EncBiIn.bmiHeader.biClrUsed := 0; EncBiIn.bmiHeader.biClrImportant := 0; EncBiOut.bmiHeader.biSize := sizeof(BITMAPINFOHEADER); // EncBiOut.bmiHeader.biCompression := mmioFOURCC('D','I','V','X'); EncBiOut.bmiHeader.biCompression := mmioFOURCC('M','P','4','2'); EncBiOut.bmiHeader.biWidth := VideoW; EncBiOut.bmiHeader.biHeight := VideoH; EncBiOut.bmiHeader.biPlanes := 1; EncBiOut.bmiHeader.biBitCount := 24; EncBiOut.bmiHeader.biSizeImage := EncBiIn.bmiHeader.biWidth*EncBiIn.bmiHeader.biHeight*EncBiIn.bmiHeader.biPlanes*(EncBiIn.bmiHeader.biBitCount div 8); EncBiOut.bmiHeader.biXPelsPerMeter := 0; EncBiOut.bmiHeader.biYPelsPerMeter := 0; EncBiOut.bmiHeader.biClrUsed := 0; EncBiOut.bmiHeader.biClrImportant := 0; hVideoWnd := capCreateCaptureWindow('capture', WS_CHILD or WS_VISIBLE, Panel1.Left 1, Panel1.Top 1, VideoW, VideoH, Handle, 0); capSetCallbackOnVideoStream(hVideoWnd, @VideoCallbackProc); gogowin
------
gogowin
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#22 引用回覆 回覆 發表時間:2002-08-07 17:35:17 IP:61.218.xxx.xxx 未訂閱
引言: 版主, 抱歉忙到今天才回覆. 以下恕刪! gogowin
請別叫我版主,我跟大夥一樣都是來這求知識的! 您的解說很清楚,我已瞭解了,也謝謝您願意把您的成果公佈給大夥參考!謝謝! 那可不可順便說一說您用UDP傳送的架構與方法,有沒有什麼需特殊注意的? 可即時全雙工傳送嗎?每秒傳送的畫面能有幾張?(即時全雙工傳送) 防火牆的問題如何解決? 麻煩您抽空回覆一下!謝謝! ________________________________________________________________________ 時間就是金錢---[ 發問前請先找找舊文章]
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#23 引用回覆 回覆 發表時間:2002-08-11 14:11:12 IP:61.70.xxx.xxx 未訂閱
利用UDP傳送是再簡單不過了, 只要將要傳的資料切割成一小段一小段來傳就好. 可切成1024 bytes 也可2048bytes, 但是好像不能太大(還沒試清楚). 接收端當然也是一段一段地收, 再放到指定的記憶區去. 比較值得注意的是漏資料的問題. UDP本來就不會重送..... 而當你用MPEG4來壓縮時, 若漏了重要的iframe,那就會有一段時間整個影像都不清楚, 直到下一個iframe被清楚地接收到為止. 其他沒有什麼啦. 只是細節很多. 又防火牆我沒時間試.應該用IP POrt number可以確定防火牆後面的電腦是那一部就可以了吧. 到時後傳送端只要指定IP POrt number, 應該沒有問題, 除非防火牆還管制封包類型..... gogowin
------
gogowin
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#24 引用回覆 回覆 發表時間:2002-08-12 09:33:32 IP:61.218.xxx.xxx 未訂閱
引言: 利用UDP傳送是再簡單不過了, 只要將要傳的資料切割成一小段一小段來傳就好. 可切成1024 bytes 也可2048bytes, 但是好像不能太大(還沒試清楚). 接收端當然也是一段一段地收, 再放到指定的記憶區去. 比較值得注意的是漏資料的問題. UDP本來就不會重送..... 而當你用MPEG4來壓縮時, 若漏了重要的iframe,那就會有一段時間整個影像都不清楚, 直到下一個iframe被清楚地接收到為止. 其他沒有什麼啦. 只是細節很多. 又防火牆我沒時間試.應該用IP POrt number可以確定防火牆後面的電腦是那一部就可以了吧. 到時後傳送端只要指定IP POrt number, 應該沒有問題, 除非防火牆還管制封包類型..... gogowin
UDP傳送時如何確認資料的正確性?有用檢查法去查證資料的正確性? 時間就是金錢---[ 發問前請先找找舊文章]
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#25 引用回覆 回覆 發表時間:2002-09-01 12:19:43 IP:61.70.xxx.xxx 未訂閱
Dear Axsoft, 影像傳輸之所以可以採用UDP或RTP的原因就是它不必在乎資料的正確性. 一兩幀影像出錯沒關係, 因為已經過去了, 新的影像又出現了...... gogowin
------
gogowin
天外來客
初階會員


發表:22
回覆:199
積分:44
註冊:2001-11-27

發送簡訊給我
#26 引用回覆 回覆 發表時間:2002-09-04 00:33:24 IP:210.66.xxx.xxx 未訂閱
引言: 另外另外請教各位大大一個問題,就是現在我面臨要把CCD影像由server端透過TCP/IP傳送到client端,請問一下該怎麼做會比較好比較有效率呢??找了很多資料但是還是理不出頭緒ㄋㄟ...麻煩各位救救命囉.. ^^~
請問您傳給 Client 端是 streaming 的方式, 或是以傳 image 圖的方式? thanks!
pcplayer99
尊榮會員


發表:146
回覆:790
積分:632
註冊:2003-01-21

發送簡訊給我
#27 引用回覆 回覆 發表時間:2004-01-16 14:59:41 IP:218.17.xxx.xxx 未訂閱
引言: Dear Axsoft, 影像傳輸之所以可以採用UDP或RTP的原因就是它不必在乎資料的正確性. 一兩幀影像出錯沒關係, 因為已經過去了, 新的影像又出現了...... gogowin
请教一下:您是使用DirectX来播放的吗?它是否支持流播放?也就是说,不是打开一个完整的文件,而是播放刚刚从UDP收到的数据。 不知道MPEG1是否也支持流播放,如果丢了一个数据包,MPEG-1会继续播放吗?
favinc
一般會員


發表:22
回覆:19
積分:8
註冊:2003-03-11

發送簡訊給我
#28 引用回覆 回覆 發表時間:2004-03-06 21:13:13 IP:211.147.xxx.xxx 未訂閱
引言:
引言: To 天外來客:
引言: 我是用capDlgVideoCompression函式來處理壓縮的,安裝BCB5.x企業版選擇完全安裝就會有了,原本一分鐘的AVI影像要90幾M的空間,壓縮後只剩300多K而已喔~~ 另外可以用capDlgVideoFormat來設定影像格式,詳細的說明再help裡的windows SDK有說明..可以參考看看.. ^^
那可否將您的源碼Post上來給大家參考一下!我找了一下BCB5企業版裡好像沒您說的函式耶? 時間就是金錢---[ 發問前請先找找舊文章]
上述cap開頭的函式都是window SDK, 不是BCB的函式, 只是BCB引用它吧... 底下是我寫的程式, 不過是delphi code, 差不多啦.. capCaptureGetSetup(hVideoWnd, @CapParam, sizeof(CapParam)); CapParam.fAbortLeftMouse := False; CapParam.fAbortRightMouse := False; CapParam.fYield := True; CapParam.dwRequestMicroSecPerFrame := 1000000 div 20; //20 FPS capCaptureSetSetup(hVideoWnd, @CapParam, sizeof(CapParam)); capPreviewRate(hVideoWnd,100); capOverlay(hVideoWnd, True); // capPreview(hVideoWnd,true); // capDlgVideoSource(hVideoWnd); // capDlgVideoFormat(hVideoWnd); // capDlgVideoDisplay(hVideoWnd); // capDlgVideoCompression(hVideownd); StartBtn.Enabled := False; StopBtn.Enabled := True; if (ICCompressBegin(hIC, @EncBiIn, @EncBiOut)<>ICERR_OK) then begin MessageBox(Handle, 'Error Initializing compressor', 'error', MB_OK or MB_ICONSTOP); exit; end; 要停止時使用下列函式 capCaptureSequenceNoFile(hVideoWnd); gogowin
请问如何使用Cap开头的函数?hic如何宣告? 兵临城下,快活如故。
------
兵临城下,快活如故。
sew
一般會員


發表:2
回覆:54
積分:21
註冊:2003-08-25

發送簡訊給我
#29 引用回覆 回覆 發表時間:2004-03-26 16:31:18 IP:140.124.xxx.xxx 未訂閱
引言: 用DlgCompression()或許可以, 不過我是用 ICOpen來將壓縮格式設定為MPEG4, 當然, 你的電腦必須先將有這個driver. 可安裝免費的Widows media SDK 8.0就可以有了. 使用時,code如下: hic := ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','P','4','2'), ICMODE_FASTCOMPRESS); 還要有一個VFW 模組. 粉麻煩的啦.... 你可參考windows SDK關於ICOPEN的部份... gogowin
請教大大 上面所提的Widows media SDK 8.0是到microsoft的網站抓嗎? 因為我到microsoft的網站找不到這個東西.. 但是有找到plamform sdk 還有directx sdk 就是找不到上面所提的的sdk 有沒有大大能幫個忙.. 加油!
------
加油!
a8960905
一般會員


發表:30
回覆:47
積分:20
註冊:2003-09-19

發送簡訊給我
#30 引用回覆 回覆 發表時間:2004-04-15 00:42:54 IP:221.169.xxx.xxx 未訂閱
引言: axsoft大大~~ 以下是我的部分程式碼,大家可以參考看看給點意見喔~~ ^^ capture的部分,以下可產生預視~~ hCapWnd = capCreateCaptureWindow("My Capture Window", WS_CHILD |WS_VISIBLE,0, 0, 400, 300,Form1->Handle, 0);//產生預視視窗 capDriverConnect (hCapWnd, 0);//連接CCD裝置 capPreview(hCapWnd,true);//啟動預視 capPreviewRate(hCapWnd,2);//設定畫面更新率 capOverlay(hCapWnd,true); BITMAPINFO bmi; capGetVideoFormat(hCapWnd, &bmi, sizeof(BITMAPINFO)); SetWindowPos(hCapWnd, 0, 25, 25, bmi.bmiHeader.biWidth,bmi.bmiHeader.biHeight,0); 以下可存檔成AVI格式~~ char save_path[50] ; strcpy(save_path,Form1->Edit1->Text.c_str()); capFileSetCaptureFile(hCapWnd,save_path);//設定存檔路徑檔名 capCaptureSequence(hCapWnd);//存取畫面視訊流 capCaptureStop(hCapWnd);//停止錄影 壓縮部分~~ 在開始錄影前呼叫capDlgVideoCompression()函數設定壓縮格式即可壓縮.. 至於DirectShow的方式我不知道耶...哪裡有相關的資料可參考嗎?? ^^
RickyT 大大您好~ 想請問幾個問題喔.. 1. capDlgVideoCompression() 可否預設好選擇某種格式然後不跳出視窗? 2. 開始錄影後Timer就會失效. 我想做到的功能市開始錄影後60秒自動停止錄影 我用了一個方式測試過了,程式結果顯示在錄影時Timer真的無效 測試程式的概念如下 : Timer每五秒ShowMessage一次開始預覽時還是會每五秒Show出一次 但是開始錄影後就完全不會反應了 不知道這個問題要怎麼解決耶... 麻煩各位大大囉...感激...
sew
一般會員


發表:2
回覆:54
積分:21
註冊:2003-08-25

發送簡訊給我
#31 引用回覆 回覆 發表時間:2004-04-25 19:24:10 IP:140.124.xxx.xxx 未訂閱
引言: RickyT 大大您好~ 想請問幾個問題喔.. 1. capDlgVideoCompression() 可否預設好選擇某種格式然後不跳出視窗? 2. 開始錄影後Timer就會失效. 我想做到的功能市開始錄影後60秒自動停止錄影 我用了一個方式測試過了,程式結果顯示在錄影時Timer真的無效 測試程式的概念如下 : Timer每五秒ShowMessage一次開始預覽時還是會每五秒Show出一次 但是開始錄影後就完全不會反應了 不知道這個問題要怎麼解決耶... 麻煩各位大大囉...感激...
The capDlgVideoCompresion macro displays a dialog box in which the user can select a compressor to use during the capture process. The list of available compressors can vary with the video format selected in the capture driver's Video Format dialog box. You can use this macro or explicitly send the WM_CAP_DLG_VIDEOCOMPRESSION message. 這是capDlgVideoCompresion的說明 所以應該是沒辦法不跳出dialog 如果要不跳出dialog可使用ICOpen 參照幫助大大的code.. 加油!
------
加油!
[<<] [1] [2] [>>]
系統時間:2024-05-11 1:40:20
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!