SE BlitzMovie
Blitz3D Forums/Blitz3D Userlibs/SE BlitzMovie
| ||
Hi there, As I needed to enhance movie playing poor capacities of Blitz3D, I developed my own DLL for handling this task. I had a hard time to find bits and pieces of information to make it working, so I think it may interest some people. The DLL is provided with an example and the DLL source code (C++) Features: - Play movie directly on a 3D texture. - If the movie is 25FPS, the 3D rendering is not anymore capped to 25 FPS. - you can pause movie playing. - you can add some filter to the movie. - you can change the volume of the sound. - play movie in loop. Maybe some important features are missing, because this library has been developed for my needs for my software ( http://www.slide-effect.com ) so if you need something else you can check the source code to add what you need. Commands: SEM_Init(): to be called before using the library SEM_Clear(): to be called before leaving SEM_OpenMovie%(filename$,bLoop%,fx%,startPaused%) : to start playing a movie. Returns: a handle to the movie Filename: filename of the movie to be used. bLoop: true if the movie will restart when ending fx: a value between 0 to 14 to add special fx to the movie: 0: no effect 1: grayscale 2: TV scan effect 3: Blue filter 4: Green filter 5: Red filter 6: White as transparent 7: Black as transparent 8: Green as transparent 9: Black and white 10: Black and white (black as transparent) 11: Black and white (white as transparent) 12: Negative 13: Blur 14: Edge detection SEM_CloseMovie(handle%): close movie SEM_DrawMovie(handle%,texture%,x%,y%): draw the movie to the texture SEM_MovieWidth%(handle%): get the movie width SEM_MovieHeight%(handle%): get the movie width SEM_MoviePlaying%(handle%): to know if a movie is still playing SEM_PauseMovie(handle%,bPause%): to pause a movie SEM_PauseAllMovie(bPause%): to pause all movies SEM_MovieVolume(handle%,volume%): to change the volume (0-100) of a movie SEM_MovieAllVolume(v%): to change the volume (0-100) of all movies These following are useful if you want to know the size of a movie without playing it: SEM_InitMovieDimension(filename$): call this one to read information SEM_MovieDimensionWidth%(): get the width SEM_MovieDimensionHeight%(): get the height I know the source code is a bit messy, don't blame me for that :) Download link for the DLL, userdecls, example and source code: http://www.devsoft.ch/SEBlitzmovie/SEBlitzMovie.zip |
| ||
This is very cool, thanks for sharing. |
| ||
Are the filter effects something built-in with DirectX 7 or earlier, or are they processed by DLL functions? |
| ||
Not built-in, it is processed by the DLL. I have to copy byte by byte the bitmap from Directshow to the texture, so filters do not cost much processing time. |
| ||
Good to know! Thanks, alain! |
| ||
OMG! THANK YOU! I'VE BEEN WAITING FOR THIS FOREVER! O_O Here's a fix to get rid of that nasty black line on the video on the cube, this also adds the ability to not only pause the movie, but the rotation of the cubes as well: ; SE_BlitzMovie Example ; --------------------- SEM_Init() ;set up fps counter fps_milli=MilliSecs(): fps_counter=0: update_frequency=1000 Graphics3D 640,480,32,2 SetBuffer BackBuffer() AmbientLight(255, 255, 255) camera=CreateCamera() CameraClsColor camera,102,102,255 ; Create cube cube1=CreateCube() cube2=CreateCube() cube3=CreateCube() PositionEntity cube1,-3,0,5 PositionEntity cube2,0,0,5 PositionEntity cube3,3,0,5 w=512 h=512 tex1 = CreateTexture(w,h,1+16+512) tex2 = CreateTexture(w,h,1+16+512) tex3 = CreateTexture(w,h,1+2+16+512) SetBuffer BackBuffer() hm1%=SEM_OpenMovie("example.avi",True,0,0) hm2%=SEM_OpenMovie("example.avi",True,12,0) hm3%=SEM_OpenMovie("example.avi",True,10,0) EntityTexture cube1,tex1 EntityTexture cube2,tex2 EntityTexture cube3,tex3 ScaleTexture(tex1, 1.50, 1.50) ScaleTexture(tex2, 1.50, 1.50) ScaleTexture(tex3, 1.50, 1.50) pause=False While Not KeyDown( 1 ) If(KeyHit(28)) pause=1-pause SEM_PauseAllMovie(pause) EndIf If Not pause RotateEntity cube1,MilliSecs()/100.0,MilliSecs()/100.0,MilliSecs()/100.0 RotateEntity cube2,MilliSecs()/100.0,MilliSecs()/100.0,MilliSecs()/100.0 RotateEntity cube3,MilliSecs()/100.0,MilliSecs()/100.0,MilliSecs()/100.0 EndIf RenderWorld() SEM_DrawMovie(hm1,tex1,0,0) SEM_DrawMovie(hm2,tex2,0,0) SEM_DrawMovie(hm3,tex3,0,0) ; fps counter-------------------------------- fps_counter=fps_counter+1 If fps_counter=update_frequency fps=1000.0/Float(((MilliSecs()-fps_milli))/Float(update_frequency)) fps_milli=MilliSecs() fps_counter=0 EndIf Text 0,0,"FPS:"+fps ;-------------------------------------------- Text 0,20,"Press [Return] to pause movie. height:"+SEM_MovieHeight(hm)+" width:"+SEM_MovieWidth(hm) Flip 0 Wend SEM_CloseMovie(hm) SEM_Clear() End |
| ||
Thanks to Alain, (& THUNDROS too). {I've never had a reason to use movies with Blitz3D; but maybe someday I can.} |
| ||
very nice one! |
| ||
Hehe, lets just say I'm working on an upgrade for my old, above code. You guys are going to LOVE this! :D |
| ||
@Thundros Can't wait to see that. |