Include file for native Directshow support in PB4

Developed or developing a new product in PureBasic? Tell the world about it.
Niffo
Enthusiast
Enthusiast
Posts: 504
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Post by Niffo »

OK, i've found the problem. There is no "Release()" of the pEnum object at the end of the FilterGraph Print Loop.

The code should be :

Code: Select all

        While pEnum\Next(1, @pFilter, @cFetched) = #S_OK 
          pFilter\QueryFilterInfo(@FilterInfo)
          Debug PeekS(@FilterInfo\achName, #MAX_FILTER_NAME, #PB_Unicode) 
          If FilterInfo\pGraph <> #Null
            FilterInfo\pGraph\Release()
          EndIf 
          pFilter\Release();
        Wend
        penum\Release()
Niffo
Philippe-felixer76
User
User
Posts: 57
Joined: Mon Dec 18, 2006 2:02 pm
Location: Holland

Post by Philippe-felixer76 »

ricardo wrote:Any way to point to a buffer instead of a file using this method? or to access the buffer?
You need to create a filter and use Render instead of RenderFile,
but the ins and outs i don't know yet.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Nice code!

Anyone know ways to draw graphics or PB Sprites over top of the video for on screen display?
Image Image
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

very nice :)

Post by Motu »

I have tried it and everything work well. I only have a small problem when playing 16:9 videos - the border of the window is grey (it should be black).

if have tried to use:
*p\pWindow\put_BorderColor(0) - without any result.

Anybody has an idea what went wrong?


:cry:
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Just take a look here: http://forum.inmatrix.com/index.php?showtopic=5661 I think you've got a driver problem. Best solution to this problem is to use haali video renderer :)
The Human Code Machine / Masters' Design Group
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

...

Post by Motu »

mmh - I fear that is not the problem - it's really grey (127/127/127)...
:(

I also tried to clear the screen by hand (Startdrawing and black box etc.), but it's not working.

I am really talking about the border of the video (Screen Height is something like 768, video is only played on 512 of the pixels) and I want the rest of the pixels to be black instead of windows lovely grey...

Any other suggestions? :)
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

whats your video type? Means what codec used for decoding the compressed videodata?
Check out OOP support for PB here!
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

wmv

Post by Motu »

it's .wmv - do you thing it can have anything to do with that? Because I am not sure if the border rendering has to do with the codec used - I would think there is some mytic flag I forget to set.

Here is the code I use to create the video (only a part of it):

If Parent
*p\pVideo\get_SourceWidth(@vw): *p\pWindow\put_width(vw)
*p\pVideo\get_SourceHeight(@vh): *p\pWindow\put_Height(vh)
*p\pWindow\put_Left(0)
*p\pWindow\put_Top(0)
*p\pWindow\SetWindowPosition(0,0+WindowHeight(0)*0.433/2,WindowWidth(0),WindowHeight(0)*0.567)
*p\pWindow\put_Owner(Parent)
*p\pWindow\put_WindowStyle(#WS_CHILD| #WS_CLIPSIBLINGS)
*p\pWindow\put_Visible(#OATRUE)
*p\pWindow\put_BorderColor(0)
EndIf

and the play code:


hMedia = InitMedia()
If hMedia
File.s = "DATA\Intro.wmv" ; OpenFileRequester("Choose media file","","All Files (*.*)|*.*",0)
If File
If LoadMedia(hMedia, File, hwnd, #VMR9_Windowed, #WaveOutRenderer)
mWidth = MediaWidth(hMedia) : mHeight = MediaHeight(hMedia)
PlayMedia(hMedia)

Repeat
Delay(5)
*Legend_Key = DX9_InputExamineKeyboard()
ev = WindowEvent()
If ev = #WM_GRAPHEVENT
ReturnValue.l = OnMediaEvent(EventlParam())
EndIf
Until *Legend_Key\Key[1] = 2 Or *Legend_Key\Key[1] = -1 Or ReturnValue = 1
MediaPutVolume(hMedia,0) ; '0' means 0db = maxVolume --> this is necessary! Otherwise the system sound device will keep the vol state even when appl. has been closed.
FreeMedia(hMedia)
EndIf
Else
DX9_ErrorMsg("Cannot open " + File)
EndIf
EndIf
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

Ahhhhhhh

Post by Motu »

I found the problem:

when any other window (like a requester or what ever) is painted over the video window it forgets the background color - and I have to repaint the upper and lower part with some black box :D

Thanks everyone for help anyway :)
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

BTW:

Post by Motu »

If someone hast the problem that his color range is reduced, I have converted the little code THCM has linked to Purebasic (without the message requesters). If you need it, feel free to use it. :)

; Begin
Pointer.l = 0 ; Handler of the key
lpType.l = 0 ; Registry Pointer Typ
lpData.s = Space(256) ; Pointer to the data
lpcbData.l = 255 ; Memory Size

If 0 <> RegOpenKey_(#HKEY_LOCAL_MACHINE,"HARDWARE\DEVICEMAP\VIDEO",@Pointer)
MessageRequester("Regkey could not be read","HARDWARE\DEVICEMAP\VIDEO",0)
End
EndIf

RegQueryValueEx_(Pointer,"\Device\Video0",0,@lpType,@lpData,@lpcbData)

RegCloseKey_(Pointer): Pointer = 0

lpData = Left(lpData,Len(lpData))
lpData = Right(lpData,Len(lpData)-Len("\Registry\Machine\"))

If 0 <> RegOpenKey_(#HKEY_LOCAL_MACHINE,lpData,@Pointer)
MessageRequester("Regkey could not be read",lpData,0)
End
EndIf

ValueX.l = 3 ; 1: Reduced color range 3: Full color range
RegSetValueEx_(Pointer,"VMRCCCSStatus",0,#REG_DWORD,@ValueX,4)

RegCloseKey_(Pointer): Pointer = 0

; End
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

@Motu - Nice! Too bad the registry switch has no effect on newer drivers.
The Human Code Machine / Masters' Design Group
Motu
Enthusiast
Enthusiast
Posts: 160
Joined: Tue Oct 19, 2004 12:24 pm

on my card it works

Post by Motu »

Thanks :)
But on my card it works (and it didn't without)

I have a GeForce 8800 GTX - newest drivers installed...

If anyone had an idea how to make the reg chance take place directly (without reboot) this would be really nice :)
Brice Manuel

Post by Brice Manuel »

I am curious to see how this works for Vista users since DirectShow is no longer supported and uses Media Foundation instead?
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

@Motu XP? Vista? Driver? I Have a Geforce 8600 GTS and tried a few drivers like 158.22, 162.15 beta and 160.03 beta. What about dual display setups? I don't think your programm works with the second display.
The Human Code Machine / Masters' Design Group
GIDO
New User
New User
Posts: 2
Joined: Mon May 12, 2003 11:09 am

Post by GIDO »

Hi Everybody,
I try to use GetRate or SetRate( IMediaseeking ) , but I don't have any results :
I use Mpeg1 file .

Have some ideas ? :?:
Post Reply