I am making a simple game for fun and learning using SFML for 2D stuff.
The game is rather simple.. I loath to say it is a HoG (hidden object
game) but I guess that would be a way to get my point across quickly.
Basically I am using SFML to load and display 2D still art and capture
Anyway… I would like to add video clips to my project. All the art is
rendered and for example.. if my image is of a park with a fountain, I
would like to have a looping video of the water running so the image has
some life even though it is just a still.
All I need is the ability to play videos in the window, preferably
compatible with sfml but I am in the planning projects I can swap to
something else if needed. The project will have a set resolution (not
scalable) and I just want to load the video and play them at a certain
pixel location in x,y. So if I have a 1200x720 image I play a 100x100
pixel video on loop at a certain location to make the water of the
Now then I am thinking I can just load 2D sprites onto of the video
matching the background image to do simple masking. There are some
formats like quicktime that can embed an alpha channel directly into the
video and if that is supported awesome.. but some planning in the set
design should mean that is not really needed. Though if that was
supported more options open in set design.
I am pretty good with video as I am a 3D animator by profession, new to
programming as a learning hobby. So the format and container of the
video is not really an issue though I have been working with OGV a lot
What I see as it needing is
Dose anyone know were I would go to start looking into this? It seams
like something that could possibly be a library I could use? Preferably
an open source one as this is just a for fun project nothing commercial.
Thanks in advance for any ideas you may have.
Please log in or register to post a reply.
hi, you could try ffmpeg, or i found this that might be usefull to you
Most people use Bink video for this, not sure if you can get a casual
game licence though.
Doing video without a well designed tool chain is a nightmare.
It is easy to find decoders for some file formats, then find your video
editor doesn’t support that format. So you grab a converter, and find
that it uses a variant codec which the code cannot handle.
It can be done, as long as you are prepared to fiddle with your tool
Probably the easiest way is to pick a file format your tools can handle,
then go looking for a decoder.
Another option is DirectShow. There’s a tutorial about it
only drawback here is that your users will require any special codecs
installed on their machine before they can view your videos. If you
stick to WMV, you should be fine.
I’m not sure how far you’ll get with alpha channel videos. I don’t think
such a format would be hardware accelerated or even a widely supported
feature since most videos are encoded using YUV. I would sooner
implement animated RGBA
instead of a video. A typical sprite sheet can house a dozen images. It
loads fast and you can take advantage of hardware accelerated
If you are interested in the topic connected with C++ technology we can
help You, you can download the teaser of new Game Coder Magazine in
which there are tutorial about the topic I’ve mentioned.
You can use ffmpeg to do all the stuff needed - here is one tutorial how
to use ffmpeg with C -
I also know that OpenCV can stream from some file-formats, but I’ve used
it just for webcam, so I don’t know whether there is any tutorial on it.
And I’m sure there is a lot of other libraries to do this stuff - you
can also try making your own (reading raw avis is brain-dead simple,
compressed … well… a bit harder, but still possible).
Have a think about how many frames of animation you really need.
The example of flowing water is a good one, (ignoring procedural
generation) the most common way of handling animated water is to simply
have a set of 2d textures and swap between them over time.
Rather than spending lot’s of time getting a video decoder working, you
might take the KISS approach and just have a sprite sheet