Quicktime for Blitzmax

BlitzMax Forums/BlitzMax Programming/Quicktime for Blitzmax

AdamRedwoods(Posted 2010) [#1]
Hi. I've created a Quicktime for BMax module. I've placed the code in the public code archives:
http://blitzmax.com/codearcs/codearcs.php?code=2698

Right now, it's only for MSWin. The reason for this is because the MSWin SDK lags Apple's implementations in OSX. Many of the Windows commands are outdated on OSX. For example, GWorlds are no longer used but instead use CGContexts. So therefore, an entirely new CPP glue would have to be written to handle behind the scenes for OSX (but the Blitzmax interface could stay the same).

UPDATE: MSWin7 and OSX now works.
UPDATE: faster drawing with DrawMovieImage(), OpenGL only

Limitations: only 24 bit, and can't manipulate the pixmap data since QT locks it, but you can read it.

Here's the sample test code. Follow the instructions from the code archives to install. You will need to grab your own .MOV file or pull from a URL. I suggest a trailer from Apple's trailers site.

Use the mouse to click to pause/play and click-hold with a move left/right to scrub the movie.

sample_code.bmx:


Special thanks to all who assisted me, and of course for Brucey forging the path with his many module interfaces.

Enjoy, post any comments or questions. If you find bugs or errors, please let me know and I'll update the code archive as best I can.

(p.s. Blitzmax rocks!)

Last edited 2011

Last edited 2011


AdamRedwoods(Posted 2010) [#2]
Revised the quicktime source based on a couple tips.

This module plays both audio and video.

I chose Quicktime over something like FFMPEG because FFMPEG has so many GPL licensing caveats that I didn't feel like wading through all the legalities. Quicktime is commercial, not GPL, and one could have their users make sure to download Quicktime, or a distribution license could be sought with Apple.

If there's enough interest, I could look into making a Mac version.

//Adam in the Redwoods


ima747(Posted 2010) [#3]
I would be quite interested in a mac version if you had the time, all my current projects target mac and windows so having unified video interface would be fantastic, especially since quicktime is a pretty trivial requirement (all macs already have it and almost all PC's since it's bundled with itunes and comes pre-installed on many systems)


Nigel Brown(Posted 2010) [#4]
I would also like a mac version


ImaginaryHuman(Posted 2011) [#5]
Any progress on this mac version? After all quicktime came from the Mac so it's really more important that it work there?


AdamRedwoods(Posted 2011) [#6]
Updated: now for MacOSX (just plug'n play!). Should work under Lion (I have OSX 10.5.6), but some things are deprecated. Let me know if something broke.

Also added capability to load Movies/MP3s via URL from the internet.

Enjoy.

Last edited 2011

Last edited 2011


Afke(Posted 2011) [#7]
Thanks ,

Awesome :)


ImaginaryHuman(Posted 2011) [#8]
Cool!


col(Posted 2011) [#9]
This is excellent :)
Well done :P


Cobra Blade(Posted 2011) [#10]
Radical. I'm not very good at coding but still managed to get my head around this and it works great. Top stuff!


Cobra Blade(Posted 2011) [#11]
Bummer, just hit a snag. The QuickTime movies don't seem to scale when using SetVirtualResolution leaving me with a tiny video in the corner. Aside from that it worked well.


MacSven(Posted 2011) [#12]
Hi,

The return of the Pix width and height is not shown..
i am using MacOS X 10.6.8 and Blitzmax 1.44...

has done is...


but:

is it possible to implement an fullscreen mode with stretching and centering videos?

Last edited 2011


AdamRedwoods(Posted 2011) [#13]
Re:
Movie width and height (after creating pixmap, class and opening movie):

Print "width: "+myQT.GetMovieWidth()
Print "height: "+myQT.GetMovieHeight()

I'm on OSX 10.6.8, let me know if it still doesn't work.


Re:
Scaling the movie
Yes, the movie is loaded into a pixmap, so you could do this:
SetScale 2.0,2.0
DrawImage (LoadImage(myMoviePixmap),0,0)

but it'll be slow. I'll look into it and see if Quicktime can do the resizing.


Russell(Posted 2011) [#14]
I'd be really surprised if QT doesn't support fullscreen scaling...

Russell


Cobra Blade(Posted 2011) [#15]
Oh I see,
replacing
DrawPixmap (mypix,X,X)
with
DrawImage (LoadImage(mypix),X,X)
allows the video to be scaled along with everything else. Thanks for that!


Russell(Posted 2011) [#16]
Does that affect speed much?

Russell


AdamRedwoods(Posted 2011) [#17]
It certainly does. I'm trying to see what I can do.
I can either make my own routine for moving the data to an opengl texture (then can be drawn with DrawImage, but still may be slow) or try to use Quicktime's built-in overlay which requires me to get the window's handle-- which is not so easy for MacOS since I am using Carbon QT and the BMax window is created using Cocoa.


Cobra Blade(Posted 2011) [#18]
Best of luck finding a workaround Adam.

It's unnoticeable on newer Macs but when I tested it on an older MacBook... boy did I notice the performance hit. Would hate to see how it runs on a Pre-Intel machine.


AdamRedwoods(Posted 2011) [#19]
It's sped up now, full speed on MacMini Intel G950 chipset, Dell windows7 G41 chipset.
Scaling, coloring works. Fullscreen works.

Updated examples on how to use the new DrawMovieImage().
The only code file that was changed was the quicktime.bmx, not the cpp file.

Last edited 2011


Cobra Blade(Posted 2011) [#20]
Thank you for all of the hard work in getting around the speed issues.

I'm really excited to try out this new update but I can't seem to get the module to compile anymore it just gives me this.

Compile Error: Identifier 'TGLImageFrame' not found



AdamRedwoods(Posted 2011) [#21]
DOH! I had the wrong imports in quicktime.bmx:

Import brl.Pixmap
Import brl.glmax2d
Import brl.standardio
Import brl.GLGraphics


I've updated the code archives to reflect this. *sorry*


ADDENDUM:
for those who don't want to sign up with Apple to get the Quicktime SDK, you may be able to get it here:
https://bitbucket.org/lindenlab/3p-quicktime/src

Last edited 2011


Cobra Blade(Posted 2011) [#22]
Thanks again for all of your time and effort in allow Blitz users the freedom to play QuickTime movies within their games...

At this point I feel like I'm just being a nuisance since when I tried compiling my game with the new QuickTime module BlitzMax just complains about
Identifier 'IsMovieDone' not found

I haven't changed any of my code yet, just wanted to test if it would compile with the new QuickTime module...

Running OS X 10.6.8 if that helps at all.


AdamRedwoods(Posted 2011) [#23]
DOUBLE DOH! I somehow deleted that from quicktime.bmx. Updated in the code archives.

Just keep it coming, I'll fix it until it's right.


Cobra Blade(Posted 2011) [#24]
Excellent!!
Third time's the charm. Thank you!

Works great and I look forward to testing this on the older MacBook later today.


Something I spotted in the sample code
Local pixw:Int = mypix.width
Local pixh:Int = mypix.height

Shouldn't they be commented out?


Cobra Blade(Posted 2011) [#25]
Brilliant work Adam!
The other day when tested my game with the older QuickTime mod using DrawImage the video was so choppy and it even caused the App to eventually crash.

Today testing it on that same 2006-07 MacBook with the new module's DrawMovieImage it ran just as well as it does on my 2011 iMac!

Thank you!!


AdamRedwoods(Posted 2012) [#26]
you're welcome. glad it works well.
Blitzmax rocks!


BLaBZ(Posted 2012) [#27]
For some reason I'm getting tons of errors when I attempt to compile

►►ERRORaddons.quicktime was not built
In file included from C:/BlitzMax/mod/addons.mod/quicktime.mod/maxquicktime_glue.cpp:13:
C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/QTML.h:20:22: MacTypes.h: No such file or directory
C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/QTML.h:24:23: MacMemory.h: No such file or directory
C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/QTML.h:28:24: MacWindows.h: No such file or directory
C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/QTML.h:32:21: OSUtils.h: No such file or directory
C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/QTML.h:36:19: Files.h: No such file or directory
In file included from C:/BlitzMax/mod/addons.mod/quicktime.mod/maxquicktime_glue.cpp:13:


etc.

The one part I'm confused about is modifying the Math64.h file, do I just add

#if TYPE_LONGLONG && TARGET_OS_WIN32 && !defined(__MINGW32__)
    #define S64Max() 9223372036854775807i64

..and...

#if TYPE_LONGLONG && TARGET_OS_WIN32 && !defined(__MINGW32__)
    #define U64Max() 0xffffffffffffffffui64



AdamRedwoods(Posted 2012) [#28]
make sure the whole windows "QuickTimeSDK" folder is in that mod folder.

The one part I'm confused about is modifying the Math64.h file, do I just add


find those two places and add the mingw check. line 43 and 714


BLaBZ(Posted 2012) [#29]
Thanks a lot Adam for the help! My apologies for being such a noob about this.

Made the changes in the right pace, the entire QuickTimeSDK folder is in the mod directory.

I'm still getting these errors -




I've been building modules for awhile and have never seen something like this before.

I'm using BLIDE so I don't have any environment variables setup for MinGW, I wonder if that could make a difference?

Last edited 2012


AdamRedwoods(Posted 2012) [#30]
I wonder if your "CC_OPTS" are not working.

in quicktime.bmx:
ModuleInfo "CC_OPTS: -IQuickTimeSDK/CIncludes/"
ModuleInfo "CC_OPTS: -IQuickTimeSDK/CIncludes/CoreFoundation"
ModuleInfo "CC_OPTS: -IQuickTimeSDK/CIncludes/GNUCompatibility"

Should allow pathing for MacType.h, etc...

In a pinch, try giving it the full path name afte rthe "-I". (C:/BlitzMax/mod/addons.mod/quicktime.mod/QuickTimeSDK/CIncludes/)
Also I think i am using BMac 1.42.


BLaBZ(Posted 2012) [#31]
Progress!

Now I'm getting

QuickTimeSDK/CIncludes/Math64.h:87:64: error: invalid suffix "i64" on integer constant


Seems like it's not recognizing

#if TYPE_LONGLONG && TARGET_OS_WIN32 && !defined(__MINGW32__)
    #define S64Max() 9223372036854775807i64
#elif TYPE_LONGLONG && TARGET_OS_WIN32
    #define S64Max() 9223372036854775807i64
#elif TYPE_LONGLONG && defined(__MWERKS__) && (__MWERKS__ < 0x1800)
    #define S64Max() 9223372036854775807
#else


I appreciate all your help Adam!


AdamRedwoods(Posted 2012) [#32]
ah, so "i64" does not work in mingw, so....
#if TYPE_LONGLONG && TARGET_OS_WIN32 && !defined(__MINGW32__)
    #define S64Max() 9223372036854775807i64
#elif TYPE_LONGLONG && defined(__MWERKS__) && (__MWERKS__ < 0x1800)
    #define S64Max() 9223372036854775807
#else


Last edited 2012


BLaBZ(Posted 2012) [#33]
hurray! I'm a happy person today.

Thanks a ton Adam!