|
|
MPEG in Director
Just wanted to point out that you can not play MPEG in Director for Windows
without using MCI, or an Xtra, or possibly the ActiveX Xtra to insert the
ActiveMovie ActiveX component. In some machines you can use the import
button and try to bring the MPEG file as a digital video castmember: since
ActiveMovie is replacing the Video for Windows API (which Director uses), in
some machines the ActiveMovie/DirectShow will kick in and actually attempt
to display the video for you. But this is not supported and will break
fairly easily in a couple of minutes. You can not control the video
reliably, and it will not work in Projectors. Most important, it will not
work if you save the movie, or try to bring it to other machines. So this
leaves you with the following options to play MPEG content in Director:
1. Macintosh:
Only one practical option: Quicktime 3. Open the MPEG file in the Movie
Player application, selecting CONVERT. This will create a Quicktime movie
with an MPEG track. Save the resulting movie, and this can be imported in
Director. Quicktime 3 and 4 for Windows do not support MPEG. MPEG2 is only
supported by some proprietary boards with supply an XTRA, like the Wired
board. Does anyone have more information about DVD/MPEG playback on the Mac
that can be shared with the list?
2. Windows:
Let's branch again: there are two interfaces used to play MPEG files on
Windows : MCI (Media Control Interface) and ActiveMovie/DirectShow.
2.1 MCI: MCI was created for Windows 3.1, and it is was recently deprecated
by Microsoft (but it will be around for several years, yet...) MCI devices
are configured in the SYSTEM.INI and WINDOWS.INI file on a Windows 3.1/95/98
machine (we will talk about NT in a second.) Only one MCI device can be
active for a given file extension at any given type, and this typically
leads to misconfiguration issues when people start to install and uninstall
MPEG players on their system, and the installer mess with the .ini files. A
properly configured system usually shows something like:
WIN.INI
[mci extensions]
....
mpg=MPEGVIDEO
vob=MPEGVIDEO
...
Here, you can see that the mpg extension is associated to the MPEGVideo
device. It is not necessarily associated with this device on all machines. A
given player may want to associate the mpg extension with another device,
named MYPLAYERDEVICE, for example. What is important is that the name of the
device will be used to determine which driver will kick in when you attempt
to play a file ending with this extension using MCI. This is defined in
SYSTEM.INI:
SYSTEM.INI
[mci]
cdaudio=mcicda.drv
sequencer=mciseq.drv
waveaudio=mciwave.drv
avivideo=mciavi.drv
videodisc=mcipionr.drv
vcr=mcivisca.drv
MPEGVideo=ctencmci.drv
you can see that in this machine, MPEGVideo device is associated with the
ctencmci.drv file. What the hell is this? This is CreativeLabs PC_DVD Encore
driver, a DVD decoder. So in this particular machine, every time a program
try to open a .mpg or .vob file through MCI calls, the Creative Driver will
kick in. I have two other decoders installed on this machine (Microsoft's
ActiveMovie/DirectShow is one of them), but MCI does not know anything about
them. Again, as far as MCI is concerned, .mpg files will be opened by the
MPEGVideo device, and it is currently linked to a file named ctencmci.drv,
which happens to be CreativeLabs driver.
A parenthesis: Microsoft includes a MPEG capable system architecture,
formerly known as ActiveMovie, now renamed DirectShow, with every Windows
95B or Windows 98 system. This architecture was meant to replace MCI as the
default way to play Media in Windows. To make the transiction easier,
Microsoft included a MCI driver for the ActiveMovie/DirectShow engine with
the default installation. Think of it as a compatibility layer: what this
driver does is to make possible to use ActiveMovie/DirectShow services from
applications that were coded to use MCI, provided the system has this driver
enabled. It usually shows up as:
MpegVideo=mciqtz.drv
in SYSTEM.INI. So in a system configured like this you can access the
underlying ActiveMovie/DirectShow engine through MCI, and it will behave
like any other MCI-driven MPEG decoder. While this is good, it will only
work if the MCI configuration shown above is correct, and by default
ActiveMovie/DirectShow does NOT register itself as the default player for
MCI content if it finds another MPEG player already registered. To guarantee
that your code will use ActiveMovie/Directshow in all systems you would have
to use an Xtra/technique that talks directly to the ActiveMovie/DirectShow
engine, not via the MCI driver mciqtz.drv. These techniques are described in
the next part of this message.
Back to MCI: you can use MCI directly from Director using the mci Lingo
keyword, but the tricky part is to get the handle to the stage windows (can
be done with Xtras like BuddyAPI, or using the technique described in the
MPEGFAQ which I wrote about 4 years ago, and it is archived at
www.mcli.dist.maricopa.edu/director). If you have Director 6, a freeware,
Lite version of MpegXtra is included in the 3rd party Xtras folder on the
CD. It will give you more or less the same functionality you can get using
these MCI-only techniques.
If you need more control, then you should probably use an Xtra that wraps
the MCI calls for you. There are a lot of advantages in doing so, even if
you are a very good Lingo programmer.
I will certainly plug our MpegXtra (http://www.tbaiana.com ) , of
course. With the latest version you have the ability to create cuepoints,
use the behaviors included to create slider bars, and most important, you
can detect mouse and key events that occur over the MPEG video area
reliably. You can also detect the end of playback reliably, even if your
presentation is deployed to systems with different MCI drivers, which report
slightly different durations for the same file. These are the things you can
not do if you use the MCI-directly approach. Additionaly, the Xtra also
keeps track of the linked MPEG files for you, adjusting the presentation so
that it will still work if you burn a CD and the user has it mounted in a
strange drive letter. This saves you additional Lingo coding time and
hassle. So for a project with moderate complexity, you should definately
consider using an Xtra: it will save you hours/days of work, and you can
benefit from experiences shared by the developers that have been working
with a bunch of MPEG MCI drivers using all versions of this software in the
past 4 years, and ended up included as new features or workarounds for
specific pitfalls built into the Xtra code.
There is another MCI-based Xtra to control MPEG: it's OnStage SE, from
Visible Lights. They claim "Lingo emulation" of MpegXtra commands, but this
is not accurate. This is in relation to MpegXtra 1 and 2, and MpegXtra 3 has
been shipping for more than an year now, with the features I described
above. Of course I don't feel confortable talking about a competitor's
product, and you will not believe my oppinions about it anyway. Since both
Xtras exist in trial form, the best thing to do is to get both, install
them, and see which one fits your needs better. Visible Lights also offers a
more expensive version of OnStage that includes the unique ability of
bundling a MPEG player on your CD, paying a royaty fee per CD distributed.
More information can be found at their site (www.visiblelights.com.) Now
that Microsoft makes ActiveMovie/Directshow freely redistributable this is
not very cost-effective anymore, but may be a good solution if you must
target Windows 3.1 machines.
Now for the bad part: even with a good Xtra or a solid MCI code, the
presentation WILL break on some machines, if the MCI driver is not
configured correctly. This is very common, unfortunately. We estimate (based
on past experiences) that almost 25% of developer's machines are not
configured correctly. This percentage drops to about 15-20% if you consider
end-user's machines, since they typically do not have the habit of
installing/uninstalling software that messes with the MCI configuration, but
it is still a high number. This is caused by the inherent flaws of the MCI
registration process, maintained in Win.ini and system.ini files, which can
be easily corrupted. And you should pay special attention if your
presentation is targeting Windows NT: MCI configuration in NT is even more
complex, and you actually have to modify the registry to fix it if things do
not work right out of the box. Not a pleasant experience. Still, almost all
hardware-based MPEG decoders can only be used via MCI. Popular MPEG2-DVD
decoder boards like CreativeLabs PC-DVD, Sigma Designs Hollywood Plus and
others only provide MCI drivers, so you have to use MCI techniques if you
want to take advantage of these decoders. MCI will still be around for at
least a couple of years, mainly for MPEG2 projects that require hardware
acceleration, but if your project calls for MPEG1 media only, and you can
define a minimum hardware requirement of a Pentium 133MHz CPU, you can
bypass MCI flaws by using the techniques described below, which address the
ActiveMovie/Directshow engine directly. Read on.
2.2 ActiveMovie/DirectShow
The ActiveMovie/DirectShow engine does not suffer from MCI major flaw: once
installed, it can coexist with other MPEG players, since all invocation of
its services is done directly using its register GUID. What this means is
that if an application is coded to use its services directly, it will work
if the services are installed, period. No messing with win.ini and
system.ini files. Microsoft's standard installation of
ActiveMovie/Directshow contains MPEG1 decompression filters since version 1,
so you are guaranteed to get MPEG1 playing if the services are installed.
ActiveMovie shipped with all Windows 95B machines (since Nov/96), and its
successor, DirectShow, is installed with Internet Explorer 3 and 4, and
comes pre-installed with Windows 98. For older machines you can still
include the latest DirectShow installer on your CD, free of royalties. Most
MPEG1 projects target at least a Pentium 133 as a minimum requirement. It is
safe to assume that over 90-95% of Windows systems with Pentium 133 and
higher processors did ship with at least ActiveMovie 1 pre-installed. So the
installed based is big, and as we move on the number of machines that do not
have it will be reduced dramatically. This clearly puts the
ActiveMovie/DirectShow engine as the preferred way to get guaranteed MPEG1
playback for projects that will get distributed in large quantities, for the
average multimedia user. And if you are committed to using the
ActiveMovie/Directshow engine, you probably should consider talking to it
directly from your code, in order to remove the MCI driver layer, and its
associated configuration issues.
There are two ways to talk to the DirectShow engine directly from your
Director application: one is to use our DirectMedia Xtra, and the other is
to embed the ActiveMovie ActiveX control using Macromedia's ActiveX Xtra.
The later is discussed in a technote at Macromedia's site. I should point
out that this solution, while free, does have some drawbacks: there are no
easy ways to customize the appearance of the ActiveX control, and to resize
it easily, or get around the border issue. The control also does not pass
mouse and key events to Director, and using it requires intermediate to
advanced Lingo skills. But the biggest problem is that this method in
reality does not address the DirectShow engine directly: you get to it via
an ActiveX control, which in turn calls the DirectShow API. What happened?
The new Windows Media Player replaced the original ActiveX control on newer
systems, with a different set of methods, so if you had a job coded for the
original ActiveX control this movie does not work any longer in the new,
upgraded machine! This somehow defeats the whole purpose of using the
Directshow API, but it is still an option worth investigating for some
projects.
I (of couse!) will advocate the use of our DirectMedia Xtra, for several
reasons (shameless plug mode engaged:) the code calls the DirectShow API
directly. It works with ActiveMovie version 1, version 2, and with all
incarnations of the DirectShow engine, including several minor revisions. It
will work if you have the original Activemovie control or the new Media
Player, or any future player technology built on top of the same API, as
long as the core services are still supported. The media appears as a true
castmember in Director: you can drag it to stage and resize/position it
freely, with WYSIWYG feedback. You have access to mouse and key events that
occurs over the sprite area. Cuepoints can be created easily, and you can
use the tempo channel to wait for a cuepoint or the end of playback. The
Xtra also keeps track of linked media for you, gives you the ability to play
only segments of the media, hide/show the cursor, etc... Playback is 100%
guaranteed on every system that has the ActiveMovie/DirectShow engine
installed, even if you have multiple, conflicting MCI-based MPEG players in
the system. To make things easier, we offer a pre-packaged installer that
will check the user's system and install the latest Directshow package only
if needed, so you have an easy way to guarantee playback for older machines,
also. Finally, a trial version is available at http://www.tbaiana.com.
There is a drawback... you do pay a price for the Xtra, since it is a
commercial product. I believe it will pay for itself many times in the first
project that you use it into, but one of the free alternatives presented
above may be more indicated for some projects, depending on the complexity
of it.
Hope the above information helps. It is accurate as far as I can tell. If
you have different information, let's talk about it. MPEG playback is a very
complicated topic, but the results are well worth the time invested in
learning it, IMO.
Regards,
Mauricio Piacentini
Tabuleiro da Baiana
|