Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfeMovie (video & audio playback library with many codecs)  (Read 148915 times)

0 Members and 2 Guests are viewing this topic.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
sfeMovie (video & audio playback library with many codecs)
« on: July 30, 2012, 01:02:03 am »
What is sfeMovie?

sfeMovie is a C++ library providing a central class that lets you play movies in SFML based applications. It relies on SFML for the rendering process and FFmpeg for the decoding process. It has been written to work closely with SFML and tries to keep the same easy-to-use paradigm, while remaining consistent with SFML's naming conventions.

Main features
  • allow reading and playing audio and video from movie files
  • provide basic controls like play, pause and seeking
  • support a lot of standard file formats and audio/video decoders
  • work on the main operating systems: Linux, OS X and Windows
  • give ability to display the movie within some frame while keeping the original ratio
  • provide access to the current image for external uses
  • support for stream selection
  • support for bitmap subtitles

Main supported decoders

Audio: AAC, AC3, FLAC, MP3, PCM, Vorbis, WMA
Video: H.264 (ie. MPEG-4 AVC), MPEG4, Theora, VP8, WMV

Other information

For the install steps, example code or downloads, see the sfeMovie website :)
http://sfemovie.yalir.org/latest/

Updates
2014 Septembre 26th: new website + forum, sfeMovie 2 binaries downloads, audio stream selection
2014 October 9th: ability to link against external or system FFmpeg binaries
2014 November 22nd: bitmap subtitles support
2014 November 23rd: binaries on the website with all the decoders
2014 November 30th: Added ability to create a static version of the sfeMovie library
2014 December 10th: Updated FFmpeg to version 2.4.3
2015 May 10th: Added seeking support
2015 May 24th: No more MinGW compiler needed on Windows, Visual C++ only.
2015 October 4th: Updated FFmpeg to version 2.8 + added ability to build for Visual Studio 2015
2016 January 2nd: Added optional support for textual (srt, ass/ssa, ...) subtitles
2016 January 2nd: Now providing Visual Studio 2015 binaries instead of Visual Studio 2013 binaries

Any feedback, be it good or not, is welcome!

Ceylo
« Last Edit: January 02, 2016, 04:15:46 pm by Ceylo »
Want to play movies in your SFML application? Check out sfeMovie!

DJuego

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #1 on: July 30, 2012, 01:19:45 pm »
Thank you Ceylo!  :D. Not only games for SFML. Good. And besides it is usable for cinematics (intro, epilogue,...)...  ;D

sfeMovie is cool and its project website is elegant, or if you prefer, sfeMovie is elegant and its Project Website is cool. I am not sure.   ;) In any case I like very much the Movie class.  Two words: minimalist and smart. It is self-explanatory.

P.S: The demo works! (windows 7 64bits)

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #2 on: July 30, 2012, 06:01:54 pm »
Thanks for your feedback DJuego!
I'm pleased to see you like it, and indeed I was (at least!) expecting the demo to work ;D .

There's something weird though, but I think it's related to GitHub... they report the demo has been downloaded 937 times (??!).
Want to play movies in your SFML application? Check out sfeMovie!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sfeMovie Project [v1.0 released]
« Reply #3 on: July 30, 2012, 07:29:42 pm »
As already mentioned earlier, this is a great extension to SFML. I recompiled ffmpeg and sfeMovie on Visual Studio 2010, and after some trouble, it worked! :)

There are some issues however:
  • In Debug mode, the library doesn't build because the VC++ compiler flags /O2 and /RTC1 are incompatible.
  • Do you really want to use an own SFML version instead of the user's one? There might be problems if sfeMovie and the user project use different versions.
  • You should provide an option to link SFML statically.
  • When I compiled the CMake-generated INSTALL project in sfeMovie.sln, the sfeMovie and ffmpeg binaries and headers weren't copied to the install directory (only the ones from SFML were).
  • I suggest to use a bin folder for dynamic .dll files and a lib folder for .lib static/import libraries.
Another problem I see, even if it's not your fault and about which you probably can't do much, is the installation for Windows users. In order to play widespread movie formats, one has to rebuild ffmpeg, which requires the whole MingW/MSYS suite even when compiling on Visual Studio. I also had to move the MSYS installation to a path without spaces, apparently in the year 2012 there are still developers not able to handle those correctly :(

I have also come across a site which provides ffmpeg binaries for Windows, but the dev packages don't seem to offer both .lib and .dll files...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #4 on: July 30, 2012, 08:17:14 pm »
Thanks Nexus :) . Yes I know there's still much to do before it becomes mature, especially as for the build system.

In Debug mode, the library doesn't build because the VC++ compiler flags /O2 and /RTC1 are incompatible.
Yup, I didn't do much to support debug build for now. I've created an issue not to forget this.

Do you really want to use an own SFML version instead of the user's one? There might be problems if sfeMovie and the user project use different versions.
Do you say this because for now building sfeMovie means building SFML too? or because sfeMovie is linked against that freshly rebuilt SFML version?

You should provide an option to link SFML statically.
Hmm I may think of it but I don't like it because I don't know what would happen in case it's statically linked in sfeMovie and the user also links his/her program against a different version/mode of SFML.

When I compiled the CMake-generated INSTALL project in sfeMovie.sln, the sfeMovie and ffmpeg binaries and headers weren't copied to the install directory (only the ones from SFML were).
You're right, I didn't even think of this. I created an issue for this too.

I suggest to use a bin folder for dynamic .dll files and a lib folder for .lib static/import libraries.
Sounds like a good idea, although it only applies to Windows builds.

Another problem I see, even if it's not your fault and about which you probably can't do much, is the installation for Windows users. In order to play widespread movie formats, one has to rebuild ffmpeg, which requires the whole MingW/MSYS suite even when compiling on Visual Studio.
Indeed FFmpeg cannot be built within Visual Studio. However I plan to check whether I can do the whole configuration process within CMake, and let Visual Studio launch a build within a MinGW shell. That way, even if the user have to install MinGW, he would just deal with known tools: CMake and Visual Studio. No more manual command line involved.

I also had to move the MSYS installation to a path without spaces, apparently in the year 2012 there are still developers not able to handle those correctly :(
Could you tell me more about what went wrong when MSYS was installed to a path that contained spaces?

I have also come across a site which provides ffmpeg binaries for Windows, but the dev packages don't seem to offer both .lib and .dll files...
But downloading both the dev and shared packages does seem to do the trick. That could be interesting. I'll have to check whether it can be used.
Want to play movies in your SFML application? Check out sfeMovie!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sfeMovie Project [v1.0 released]
« Reply #5 on: July 30, 2012, 09:55:31 pm »
Do you say this because for now building sfeMovie means building SFML too? or because sfeMovie is linked against that freshly rebuilt SFML version?
In Thor, I let the user specify a path to SFML, inside which the headers are included and the libraries are linked. I wonder why you do it differently... Do you think there are sfeMovie users which don't have SFML already installed?

A problem I see with different SFML versions: The header <sfeMovie/Movie.hpp> includes many SFML headers. When building the library, your own SFML version is used. When I include <sfeMovie/Movie.hpp> in my project, then my include paths are searched, thus other versions of the headers are included.


Hmm I may think of it but I don't like it because I don't know what would happen in case it's statically linked in sfeMovie and the user also links his/her program against a different version/mode of SFML.
When both used the same version (the user's one), this wouldn't be an issue.

I tried to link SFML statically on my side, but I got warnings because sfe::Movie inherits sf::Drawable which doesn't export its symbols when I define SFML_STATIC. When I start the program, only audio is played, the screen remains black. Unless I did something wrong, it seems like a sfeMovie user loses the choice about how to link SFML...


Sounds like a good idea, although it only applies to Windows builds.
True. You can pass RUNTIME and LIBRARY parameters to the CMake install() command. I did such a case differentiation in Thor/src/CMakeLists.txt:
# Install (use "bin" folder for DLL, "lib" for SO files)
if(WIN32)
        install(TARGETS ${THOR_LIB}
                        RUNTIME DESTINATION bin
                        LIBRARY DESTINATION lib
                        ARCHIVE DESTINATION lib)
else()
        install(TARGETS ${THOR_LIB}
                        RUNTIME DESTINATION lib
                        LIBRARY DESTINATION lib
                        ARCHIVE DESTINATION lib)
endif()


Could you tell me more about what went wrong when MSYS was installed to a path that contained spaces?
I installed it to C:\Program Files (x86)\MinGW. When I executed msys.bat, I got a popup with the message:
Code: [Select]
Windows cannot find "C:\Program". Make sure you typed the name correctly, and then try again.
« Last Edit: July 30, 2012, 09:57:37 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #6 on: August 04, 2012, 01:35:33 pm »
In Thor, I let the user specify a path to SFML, inside which the headers are included and the libraries are linked. I wonder why you do it differently... Do you think there are sfeMovie users which don't have SFML already installed?
Actually.. I think that's it, this not a good reason though. I'll change that too. I also think I did this because I wasn't using CMake as a starting point for building so specifying this path wasn't as easy (no cache, etc). You're quite right about the inclusion thing too.

When both used the same version (the user's one), this wouldn't be an issue.
You're right.

I tried to link SFML statically on my side, but I got warnings because sfe::Movie inherits sf::Drawable which doesn't export its symbols when I define SFML_STATIC. When I start the program, only audio is played, the screen remains black. Unless I did something wrong, it seems like a sfeMovie user loses the choice about how to link SFML...
Another user got the same issue when mixing static/dynamic linking. I'll give back the choice if I can get everything to work with CMake as starting building point.

True. You can pass RUNTIME and LIBRARY parameters to the CMake install() command. I did such a case differentiation in Thor/src/CMakeLists.txt:
Thanks, good to know! :)

I installed it to C:\Program Files (x86)\MinGW. When I executed msys.bat, I got a popup with the message:
Code: [Select]
Windows cannot find "C:\Program". Make sure you typed the name correctly, and then try again.
Hmm ok, so this is specific to MinGW.. ok.

Thanks for all of the feedback!
Want to play movies in your SFML application? Check out sfeMovie!

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #7 on: August 20, 2012, 09:49:51 pm »
Ceylo

Are any of the codecs supported able to use alpha? i.e. can I get transparency in videos?

Thanks
Ed
SFML 2.1

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #8 on: August 20, 2012, 10:34:06 pm »
Hello slotdev,

sfeMovie supports the Animation codec (see http://en.wikipedia.org/wiki/Animation_codec) and VP6 with alpha channel (often contained in FLV files).

I tested a FLV movie with alpha channel right now and it works fine. There may be other codecs that support alpha channels but I don't know them.

Ceylo
Want to play movies in your SFML application? Check out sfeMovie!

bluekirby0

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #9 on: September 27, 2012, 08:56:46 am »
Two things I would like to see, and I was wondering if they can be accomplished with a simple rebuild of ffmpeg:

Matroska format support (patent-unencumbered container format that is highly extensible).

Libass support for advanced subtitle rendering.

The first one is pretty important to me, while the second is something I would like to make available, but I understand if I need to implement it separately with the simple text drawing available in sfml. Libass can be a major CPU hog if you abuse its capabilities too much, but anything is a better option than hard-coding subtitles onto video (not only can you not turn them on or off, but they compress particularly poorly causing artifacts around text and bit starvation in other areas of the video).

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #10 on: September 27, 2012, 10:46:28 am »
Hello bluekirby0,

The Matroska container is already supported in the provided binaries. Thus unless you're using your own FFmpeg libraries, you can assume this format is supported. However this is, as you mention, a container only, not a video codec. To be able to read your MKV files, you have to make sure the right audio and video decoder are enabled in the FFmpeg build. Being able to read the container only means the program will be able to find where the audio and video streams are located in the file, it doesn't mean it'll be able to decode these streams though.

As for subtitles, it is not supported yet. The point isn't even about letting you render the subtitles, sfeMovie just can't detect and extract them for now.
Want to play movies in your SFML application? Check out sfeMovie!

bluekirby0

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #11 on: September 27, 2012, 11:15:20 am »
Your FAQ doesn't list matroska, MKV or WebM in the list of supported "formats" (what I call containers), so I assumed it wasn't supported in the binary releases. Sorry for the misunderstanding!

I am very familiar with video containers and codecs, and was looking for a solution that would support everything I need without royalty encumbrance. I am settling in on matroska/webm, ogg, and wav for supported containers (there will be audio-only parts to the program as well), with VP8 and theora (perhaps dirac if they fix some of the portability issues with libschroedinger) options for video and vorbis, FLAC and PCM options for audio. If embedded subtitles can be supported, I'd also like to support ASS/SSA/SRT (need to do some more research on whether patents cover any of these).

Subtitles can be embedded in a matroska container, so if you wanted to add in support for them, that would be a good place to start. I'm not sure if WebM subset supports subtitles or not, but it is basically a subset of the Matroska container. After I've had some time to familiarize myself with sfe::Movie a bit, I may look into adding in subtitle support myself.

On a side note, how well does sfe::Movie support containers with multiple video or audio streams? It isn't important for my purposes, but you do have that possibility with mkv.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie Project [v1.0 released]
« Reply #12 on: September 27, 2012, 01:49:01 pm »
Your FAQ doesn't list matroska, MKV or WebM in the list of supported "formats" (what I call containers), so I assumed it wasn't supported in the binary releases. Sorry for the misunderstanding!
You're right, the FAQ doesn't contain the exhaustive list of supported containers, I'll fix this.

I am very familiar with video containers and codecs, and was looking for a solution that would support everything I need without royalty encumbrance. I am settling in on matroska/webm, ogg, and wav for supported containers (there will be audio-only parts to the program as well), with VP8 and theora (perhaps dirac if they fix some of the portability issues with libschroedinger) options for video and vorbis, FLAC and PCM options for audio. If embedded subtitles can be supported, I'd also like to support ASS/SSA/SRT (need to do some more research on whether patents cover any of these).
As for patents, I'd be interested in your results for the subtitles formats too. And if you find reliable information about free containers/codecs, I'd be pleased to add it in the table of the Legal page and even support these in the provided binaries if they're free.

Subtitles can be embedded in a matroska container, so if you wanted to add in support for them, that would be a good place to start. I'm not sure if WebM subset supports subtitles or not, but it is basically a subset of the Matroska container. After I've had some time to familiarize myself with sfe::Movie a bit, I may look into adding in subtitle support myself.

On a side note, how well does sfe::Movie support containers with multiple video or audio streams? It isn't important for my purposes, but you do have that possibility with mkv.
sfeMovie can read movies that contain several video/audio/subtitle streams, but it'll always use the first one it finds (except for subtitles that are still ignored).

Subtitles support is planned, but I don't know when it'll be done. Anyway before I do this I want to change sfeMovie's design in order to be able to select which stream is to be used (for both video/audio and subtitles). Once this is done, subtitles support can be done without dealing with the MKV container, because the FFmpeg API abstracts this. Support for subtitles will be a general support.

If you want to implement this stream choice + subtitles support, I can help you :) .
Want to play movies in your SFML application? Check out sfeMovie!

bluekirby0

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #13 on: September 27, 2012, 02:17:17 pm »
From what I know now, dirac is the only "free" codec you don't have listed in the faq.
http://diracvideo.org/

libschroedinger can be built into ffmpeg for dirac support, but it has a dependency on liborc, which has given me headaches trying to build in mingw before, so windows support would be difficult to achieve (unless mingw builds have been fixed in the last few months).

From a cursory search, I couldn't find any mention of patents on any kind of subtitle format, but I'll try to contact one of the developers of libass and see if there are any "gotchas".

Stream selection support and subtitle support would be great, but give me some time to break into the code before I start bombarding you with technical questions.

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: sfeMovie Project [v1.0 released]
« Reply #14 on: October 30, 2012, 05:47:58 pm »
I seem to be having some real issues trying to build this library on windows.

I'm running VS 11 with SFML 2

Cmake builds without error.

VisualStudio on the other hand...
Quote
Cannot open input file 'avdevice.lib'

SFML itself compiles just fine, I only get that error on "sfeMovie"

I think I need to compile my own library because if I use a pre compiled library and try to run my program I get the following:

Quote
The procedure entry point at av_samples_copy could not be located in the dynamic link library avcodec-54.dll.

Your website states that for Visual Studio and Cmake I have to run a .sh file, but I really don't know how to begin to run a .sh file on windows. >.>

So, if you could give me some hints as to what I'm doing wrong it would be appreciated. :)

Also, can sfeMovie be compiled as static so it doesn't need all the sfml .dll's right next to it?
« Last Edit: October 30, 2012, 06:09:31 pm by Flash619 »