線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:4674
推到 Plurk!
推到 Facebook!

使用DirectShow 將影片內容轉成圖檔

尚未結案
terence_lee
初階會員


發表:62
回覆:82
積分:28
註冊:2004-07-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-13 16:29:25 IP:211.74.xxx.xxx 未訂閱
各位先進大家好: 請請問大家,小弟要如何將影片擷取出來成為圖片呢?請有經驗的大大能 給小弟一個方向...若是directshow 的sdk可以將圖片擷取出來嗎?謝謝大大們的指教
bearmaster
一般會員


發表:36
回覆:45
積分:16
註冊:2004-05-27

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-13 23:55:08 IP:220.139.xxx.xxx 未訂閱
若你要開發 DirectShow 想必一定有安裝 DiretX SDK 吧. 可參考 AMCap 的寫法, Source: (SDK root)\Samples\C \DirectShow\Capture\AMCap 或是(從DirectX SDK擷取的資料): The AVI Mux filter takes the video stream from the capture pin and packages it into an AVI stream. An audio stream could also be connected to the AVI Mux filter, in which case the mux would interleave the two streams. The File Writer filter writes the AVI stream to disk. To build the graph, start by calling the ICaptureGraphBuilder2::SetOutputFileName method, as follows: IBaseFilter *pMux; hr = pBuild->SetOutputFileName( &MEDIASUBTYPE_Avi, // Specifies AVI for the target file. L"C:\\Example.avi", // File name. &pMux, // Receives a pointer to the mux. NULL); // (Optional) Receives a pointer to the file sink. The first parameter specifies the file type — in this case, AVI. The second parameter gives the file name. For AVI, the SetOutputFileName method cocreates the AVI Mux filter and the File Writer filter and adds them to the graph. It also sets the file name on the File Writer filter, by calling the IFileSinkFilter::SetFileName method, and connects the two filters. The method returns a pointer to the AVI Mux in the third parameter. Optionally, it returns a pointer to the IFileSinkFilter interface in the fourth parameter. If you don't need this interface, you can set this parameter to NULL, as shown in the previous example. Next, call the ICaptureGraphBuilder2::RenderStream method to connect the capture filter to the AVI Mux, as follows: hr = pBuild->RenderStream( &PIN_CATEGORY_CAPTURE, // Pin category. &MEDIATYPE_Video, // Media type. pCap, // Capture filter. NULL, // Intermediate filter (optional). pMux); // Mux or file sink filter. // Release the mux filter. pMux->Release(); The first parameter gives the pin category, which is PIN_CATEGORY_CAPTURE for capture. The second parameter gives the media type. The third parameter is a pointer to the capture filter's IBaseFilter interface. The fourth parameter is optional; it lets you route the video stream through an intermediate filter, such as an encoder, before passing it to the mux filter. Otherwise, set this parameter to NULL, as shown in the previous example. The fifth parameter is the pointer to the mux filter. This pointer is obtained by calling the SetOutputFileName method. To capture audio, call RenderStream with the media type MEDIATYPE_Audio. If you are capturing audio and video from two separate devices, it is a good idea to make the audio stream the master stream. This helps to prevent drift between the two streams, because the AVI Mux filter adjust the playback rate on the video stream to match the audio stream. To set the master stream, call the IConfigAviMux::SetMasterStream method on the AVI Mux filter: IConfigAviMux *pConfigMux = NULL; hr = pMux->QueryInterface(IID_IConfigAviMux, (void**)&pConfigMux); if (SUCCEEDED(hr)) { pConfigMux->SetMasterStream(1); pConfigMux->Release(); } The parameter to SetMasterStream is the stream number, which is determined by the order in which you call RenderStream. For example, if you call RenderStream first for video and then for audio, the video is stream 0 and the audio is stream 1. You may also want to set how the AVI Mux filter interleaves the audio and video streams, by calling the IConfigInterleaving::put_Mode method. IConfigInterleaving *pInterleave = NULL; hr = pMux->QueryInterface(IID_IConfigInterleaving, (void**)&pInterleave); if (SUCCEEDED(hr)) { pInterleave->put_Mode(INTERLEAVE_CAPTURE); pInterleave->Release(); } With the INTERLEAVE_CAPTURE flag, the AVI Mux performs interleaving at a rate that is suitable for video capture. You can also use INTERLEAVE_NONE, which means no interleaving — the AVI Mux will simply write the data in the order that it arrives. The INTERLEAVE_FULL flag means the AVI Mux performs full interleaving; however, this mode is less suitable for video capture because it requires the most overheard. Encoding the Video Stream You can encode the video stream by inserting an encoder filter between the capture filter and the AVI Mux filter. Use the System Device Enumerator or the Filter Mapper to select an encoder filter. (For more information, see Enumerating Devices and Filters.) Specify the encoder filter as the fourth parameter to RenderStream, shown in bold in the following example: IBaseFilter *pEncoder; /* Create the encoder filter (not shown). */ // Add it to the filter graph. pGraph->AddFilter(pEncoder, L"Encoder); /* Call SetOutputFileName as shown previously. */ // Render the stream. hr = pBuild->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pCap, pEncoder, pMux); pEncoder->Release(); The encoder filter might support IAMVideoCompression or other interfaces for setting the encoding parameters. For a list of possible interfaces, see File Encoding and Decoding Interfaces.
KENI_LIN
中階會員


發表:86
回覆:267
積分:90
註冊:2004-05-31

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-04-14 12:45:51 IP:220.228.xxx.xxx 未訂閱
可以參考以下兩個討論區: (1)DirectShow原始程式:http://delphi.ktop.com.tw/topic.php?TOPIC_ID=54652 (2)影像程式介紹:http://delphi.ktop.com.tw/topic.php?TOPIC_ID=66402 第(1)項裡面,應該就有你要的capture功能,DXSDK9.0安裝和使用方法可以參考第(2)項討論內容. 寒窗苦讀十年書;只待今朝狀元時!~~ ︵ / / ︵ ( ∩ ∩ ) ○ ︶ ○ Keni Lin
------
Keni Lin
KENI_LIN
中階會員


發表:86
回覆:267
積分:90
註冊:2004-05-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-04-14 14:25:09 IP:220.228.xxx.xxx 未訂閱
不好意思更正第(1)項一下,DirectShow source code位置在 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=40601 寒窗苦讀十年書;只待今朝狀元時!~~ ︵ / / ︵ ( ∩ ∩ ) ○ ︶ ○ Keni Lin
------
Keni Lin
terence_lee
初階會員


發表:62
回覆:82
積分:28
註冊:2004-07-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-04-15 09:29:34 IP:211.74.xxx.xxx 未訂閱
bearmaster 大大謝謝你的回應, 小弟這就去試試...
terence_lee
初階會員


發表:62
回覆:82
積分:28
註冊:2004-07-15

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-04-15 09:34:08 IP:61.221.xxx.xxx 未訂閱
KENI_LIN大大:             小弟下載了souce檔後,要先compile Tvideocapture 的元件,發生      如附圖的錯誤,是否是小弟使用bcb60的關係呢?
KENI_LIN
中階會員


發表:86
回覆:267
積分:90
註冊:2004-05-31

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-04-15 16:59:11 IP:61.220.xxx.xxx 未訂閱
Dear terence_lee 這個程式在BCB5.0是可用的;但是BCB6.0會出問題,我也找不出原因?跟vcl元件有關吧;注意看一下當安裝
------
Keni Lin
terence_lee
初階會員


發表:62
回覆:82
積分:28
註冊:2004-07-15

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-04-25 08:55:56 IP:61.221.xxx.xxx 未訂閱
KENI_LIN大大, 謝謝你的回覆,小弟再試試看..
系統時間:2024-05-12 21:53:01
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!