Dspack various use methods

Source: Internet
Author: User

1. Dspack 2.3.4 Installation

A. Download
Since SourceForge is inaccessible recently, you can go tohttp://www.progdigy.com/Download.
DownloadHttp://www.progdigy.com/files/DSPACK234.zip, unzip to a directory (I'm using C:\Borland\VCL\DSPACK234).

Two. Installation

1 Add search Path (Dspackdir) \src\directx9 and(Dspackdir) \src\dspack

Select the menu "Tools"-"enviroment options" in the Delphi7 and select the Library tab in the Open window, in the library Pathadd these two directories in an item C:\Borland\VCL\DSPACK234\src\Directx9; C:\Borland\VCL\DSPACK234\src\DSPack

(Paste it directly behind the original content, or click the library PathThe back of the ... button to add)

2 compiling(Dspackdir) \packages\directx9_d7.dpk

Double-click (Dspackdir) \PACKAGES\DIRECTX9_D7.DPK, in Delphi7, a dialog box about recreating the resource file is displayed, click OK.
Click the Compile button in the open window in Delphi7 to complete the compilation.
Select the menu "File"-"Close all" in Delphi7, and select Save when asking whether or not to save.

3 compiling(Dspackdir) \packages\dspack_d7.dpk

Double-click (Dspackdir) \PACKAGES\DSPACK_D7.DPK, in Delphi7, a dialog box about recreating the resource file is displayed, click OK.
In the open window in Delphi7, click the Compile button to complete the compilation.

Select the menu "File"-"Close all" in Delphi7, and select Save when asking whether or not to save.

4 Compiling and installing(Dspackdir) \packages\dspackdesign_d7.dpk

Double-click (Dspackdir) \PACKAGES\DSPACKDESIGN_D7.DPK, in Delphi7, a dialog box about recreating the resource file is displayed, click OK.
In the open window in Delphi7, click the Compile button to complete the compilation. Click the Install button to complete the installation.
Select the menu "File"-"Close all" in Delphi7, and select Save when asking whether or not to save.

Now that the installation is complete, you can find the Dspack tab on the Delphi Control Panel.

If installed in Delphi5 or 6, select the corresponding D5 or D6 file.

(a compilation error was encountered during installation, saying that Jedi.inc could not be found.) This file is in the src\directx9 directory, why cannot search. The original document is written in the path is (Dspackdir) \src\directx9, and the actual extracted directory name is DirectX9, so add the search path must pay attention to this problem. After changing x to X, the compilation is passed.)

2. Play Video with Dspack

After installation, start learning Dspack.
First, to read(dspackdir) \Help directory under the Help.chm file, a cursory look at the content too much to see the clue.
Let's learn it first.(dspackdir) \Demos\d6-d7 the list of examples, learn it by doing it on the side.

The first example of the study is Playwin. studied, mainly using tfiltergraph and Tvideowindow to complete.
Tfiltergraph is the core class in Dspack, and other classes revolve around it, but it's unclear how to understand it. Tvideowindow is a control that displays video playback. The relationship of these two classes seems to be the same as the relationship between a DataSet control and a DBGrid control in a database control.

After seeing it almost, I divert imitation one.

1. Create a new app and put 4 or 5 buttons on the interface first.
2. On the Control Panel, select the Dspack page and place the first two controls (Tfiltergraph and Tvideowindow) on each of the windows.
3. Association
With the VideoWindow1 control selected, set the Filtergraph property to FilterGraph1 in the Properties window.
Check the FILTERGRAPH1 control to confirm that the Mode property in the Properties window is gmnormal.

4. Add a OnCreate event handler for Form1.
The contents are:
If not filtergraph1.active then filtergraph1.active: = true;
Filtergraph1.cleargraph;
Filtergraph1.renderfile (' E:\v\951.wmv '); Simplify a little bit here with a video file on your local hard drive

5. Add a Onclosequery event handler for Form1.
The contents are:
Filtergraph1.active: = false;

6. Change the caption of Button1 to start and add an onclick event
The contents are:
Filtergraph1.play;

Run it and it's ready to play. Add a few more function buttons below, such as pause, stop.

7. Change the button2 caption to pause and add an onclick event
The contents are:
Filtergraph1.pause;


8. Change the button3 caption to stop and add an onclick event
The contents are:
Filtergraph1.stop;

You can see that 4-8 steps are methods that call the Tfiltergraph class.

Next, add a full screen function.
9. Change the button4 caption to fullscreen and add an onclick event
The contents are:
Videowindow1.fullscreen: =true;

10. Add an onclick event for VideoWindow1
The contents are:
If Videowindow1. Fullscreen then
Videowindow1. Fullscreen: = false; Exit Full Screen mode

General video Play The window has a progress bar, now we also add one.
A.1. On the Dspack Control Panel, select the bottom 2nd control (Tdstrackbar) and place it on the window.
A.2. Associations
With the DSTrackBar1 control selected, set the Filtergraph property to FilterGraph1 in the Properties window. (This step seems to be very familiar with OH)

Rerun the program, you will see a progress bar and be able to use this progress bar to adjust the playback progress.

3. Turn on the camera using Dspack

Now let's see.(dspackdir) \Demos\d6-d7 directory of Playvideocap, which is an example of a video input device that turns on this machine.

In this example, a new class is used: Tfilter.

Before we draw a gourd, you have to install a camera or a virtual camera. Virtual cameras can use software such as Vcdcut, Softcam or Vcam, or virtual video with 9158 (http://www.9158.com/) or Mvbox (http://www.mvbox.cn/).

Same as last time:

1. Create a new application, put 4, 5 buttons on the interface, this time put a ListBox, this list box will list the video input devices installed in the system.
2. On the Control Panel, select the Dspack page and place the first two controls (Tfiltergraph and Tvideowindow) on each of the windows.

Here's the difference.

3. Select the Tfilter control in the Dspack and place it on the window.
4. Select the FILTERGRAPH1 control and set the Mode property to Gmcapture in the Properties window.
5. Association
Select the VideoWindow1 control and set the Filtergraph property to FILTERGRAPH1.
Select the Filter1 control and set the Filtergraph property to FILTERGRAPH1.

6. In code mode, add in uses after interface
Dsutil, DirectShow9,
Added in Var in front of implementation
Sysdev:tsysdevenum;


7. Add a OnCreate event handler for Form1 to read the video input device in the system.
The contents are:
Var
I:integer;
Begin
Read the video input device in the system
sysdev:= tsysdevenum.create (clsid_videoinputdevicecategory);
If sysdev.countfilters > 0 Then
For I: = 0 to Sysdev.countfilters-1 do
Begin
LISTBOX1.ITEMS.ADD (Sysdev.filters[i]. FriendlyName)
End

End

7. Ibid. Add a Onclosequery event handler for Form1.
The contents are:
Sysdev.free;
Filtergraph1.cleargraph;
Filtergraph1.active: = false;

8. Add an OnClick event handler for Listbox1
The contents are:
Filtergraph1.cleargraph;
Filtergraph1.active: = false;
Set filter to the selected video input device
Filter1.BaseFilter.Moniker: = Sysdev.getmoniker (Listbox1.itemindex);
Filtergraph1.active: = true;
To open the selected video input device
With FILTERGRAPH1 as ICaptureGraphBuilder2 do
Renderstream (@PIN_CATEGORY_PREVIEW, Nil, Filter1 as Ibasefilter, Nil, VideoWindow1 as Ibasefilter);
Show up
Filtergraph1.play;


Run a try and see if you can see the contents of your webcam.


A few buttons are useless, just wait for the next example.

4. Dspack Capture FrameIn the example Playvideocap, there is also the ability to grab frames and play back. This is used for the 4th control Tsamplegrabber.

Our previous two examples are based on the ability to increase the capture frame.
Open the previous example, and then:

1. Select the Tsamplegrabber control in the Dspack and place it on the window. Then set its Filtergraph property to FILTERGRAPH1.
2. In the Select a standard control Timage (in the Additional tab), place it on the window.
3. The caption of a useless button is changed to "Snapshot", which is written in its onclick event:
Samplegrabber1.getbitmap (IMAGE1.PICTURE.BITMAP);

The above two examples can be used to increase the frame capture function. However, for the second example (that is, the operating camera example), additional modifications are required:
Will
Renderstream (@PIN_CATEGORY_PREVIEW, Nil, Filter as Ibasefilter, Nil, Videowindow as Ibasefilter);
Switch
Renderstream (@PIN_CATEGORY_PREVIEW, Nil, Filter as Ibasefilter, Samplegrabber as Ibasefilter,Videowindow as Ibasefilter);

That's it.5. DirectShow Basic Concepts

Here, I basically used dspack to do something, understand the dspack of the 3 basic classes and some of its methods. But to understand them, you need to understand the basic concepts of filter Graph, filter, and pin in DirectShow.

Found some information on the Internet, the address of the better information is http://www.yesky.com/259/1854259.shtml , most of the information is from Lu Qiming wrote the "DirectShow Development Guide" and " The two books of DirectShow practical selection.
Summarized as follows:

1) system Structure of DirectShow

DirectShow is shown in Architecture 1.


Figure 1 DirectShow system


The DirectShow is located in the application layer. It uses a model called filter graph tomanage the process of the entire data flowEach function module involved in data processing is called filter, and each filter is connected in a certain order in the filter graph to work together as a "pipeline".

(You can see that tfiltergraph is a filter container)

By function, filter is broadly divided into three categories: Source Filters, Transform Filters, and rendering Filters.
Source filters is mainly responsible for obtaining data, the data source can be files, the Internet, or computer capture cards, digital cameras, and then transfer data down;
Transform Fitlers is mainly responsible for the data format conversion, transmission;
Rendering Filtes is mainly responsible for the final whereabouts of the data, we can send the data to the sound card, video card for multimedia demonstration, can also output to the file for storage.

On top of the DirectShow system, what we see is our application (application). The application should establish the corresponding filter graph according to certain intention, then control the whole data processing process through the Filter Graph manager. DirectShow can receive various events while the filter graph is running and send them to our application via a message. In this way, the interaction between the application and the DirectShow system is realized.

2) filter Overview and connection

Filters (filter) are the most basic concepts in DirectShow. The DirectShow is managed by the filter graph.Filter graph is the "container" for filter, and filter is the smallest function module in the filter graph

Filter is a COM component that, for each filter, has its own pin, which is a COM object created by filter. The filter uses a PIN to connect between them.

There are two types of pins: the output pin and the input pin. The output pin transfers the filter-processed data to the outside of the filter, while the input pin receives the data outside of the filter into the filter so that the filter can process the data.

The connection diagram for the three types of filter (Source filter,transform filter,rendering filter) is as follows:

Figure 2 Connection of the filter

The type of filter can be judged based on the proficiency of the input pin and output pin included in the filter:
Only output pin, no pin entered, source Filter
Both the output pin and the input pin are transform Filter
No output pin, only input pin, rendering Filter


3) Important interface of DirectShow

DirectShow uses the COM standard, so many important functions are done through COM interfaces. The following is a list of some important DirectShow interfaces.

(1) Igraphbuilder interface

Used to construct the interface of filter graph, establish and manage a series of filter, filter and process the source media stream.

(2) IMediaControl interface

Used to control the flow of multimedia streams in the filter graph, starting and stopping the flow.

(3) Imediaevent interface

Used to capture events that occur during playback and to notify applications such as Ec_complete.

(4) Ivideowindow interface

Used to control the properties of the video window.

(5) Imeadiaseeking interface

The interface for finding media, locating streaming media, and controlling multimedia data playback provide precise control.

(6) Ibasefilter interface

Inherit from the Imediafilter interface to define a specific filter pointer and process the multimedia data.

(7) Ipin interface

Used to manage a pin between two filters to connect the filter.

(8) ISAMPLEGRABBERCB interface

is an interface to the sample grabber filter that is used when streaming media data is sampled through the filter to obtain frame images.


There is also a reference to the address:http://www.yesky.com/259/1854259.shtml

Filter is a COM component. To achieve uniform operation in the filter graph, at least one Ibasefilter interface is implemented on each filter. The file that implements the filter is typically a DLL, and the extension can be a. dll, but more often it is. Ax.

Filter must be added to the filter graph and connected to the work link in order to function. If you want to bypass filter graph and directly use the function module implemented by filter, then you need to port the filter function to the DirectX Media Object (DMO).

You must register before you use the filter. The command format is
regsvr32 C:\YOURDIRECTORY\YOURFILTER.AX

The filter chain is a filter link connected to each other, and each filter in the link has an input pin in the connected state, at most one output pin in the connected state. The data stream in this filter link does not depend on other filter outside the link. The Filter chain operates through the Ifilterchain interface.

When the filter graph is in the running state, the filter chain can switch between the running and the Stop States;
When filter graph is paused, the filter chain can toggle between pause and stop states. This is the only two state transitions of filter chain.

Data transfer of filter
The filter transmits data in the form of sample. Sample is a COM component that encapsulates a certain size of data memory. The Imeminputpin interface that is implemented on the input pin is generally used for data transfer.

Filter has 3 states: Stop, pause, and run.

Dspack various use methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.