Welcome, Guest. Please login or register.

Author Topic: sfeMovie project [v1.0 RC1 available]  (Read 22464 times)

0 Members and 1 Guest are viewing this topic.

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« on: October 31, 2010, 05:38:42 PM »
Update from July 30th, 2012

sfeMovie 1.0 is available, see http://en.sfml-dev.org/forums/index.php?topic=8701.msg58578#msg58578


=============================

Update from March 15th, 2012

sfeMovie 1.0 RC1 is available, see http://www.sfml-dev.org/forum/viewtopic.php?p=48199#48199


=============================
Hello everyone,

Information update from 2011-05-12
I'm writing here to give you the latest news about the sfeMovie project.

sfeMovie is a small C++ library that lets you play movies in SFML based applications. It relies on SFML for the rendering process and FFmpeg for the decoding process. It supports both audio and video, and basic controls. This project has been written to work closely with SFML and tries to keep the same easy-to-use paradigm, while remaining coherent with SFML's conventions.


Information and download:
Most of the information is available through the wiki page, including the download links.

For now, sfeMovie is available to Windows and Mac OS X, and is in a beta state. Thanks to FFmpeg, sfeMovie can read many formats, including AAC, MP3, Vorbis, WMA, H.264, MPEG4, Theora, VP6 and WMV.
There is still a lot of work to do, but the current version already lets you use the main features.

I'm inviting you to test the library and write your feedback about bugs or any other issue you encountered. The bug tracker allows you to check the already-reported bugs or upcoming features and improvements.


As for the differences with the previous versions:
- all of the precompiled FFmpeg binaries have been dropped
- a script to compile everything for you has been added, it also allows you to exactly choose which decoders you want to enable
- FFmpeg is statically linked to sfeMovie, thus you don't have to care about FFmpeg dlls
- some minor bugs have been fixed


Ceylo


Original post:
Quote
Hellooo everyone,

I'm posting here to get some comments about a video class I'm currently working on. The purpose is to be able to display a video with its audio soundtrack, and to get something as easy to use as sf::Music.

It's supposed to work on all the OSs supported by SFML and has been currently successfully tested on Windows and Mac OS X. It uses SFML 1.6 and FFmpeg 0.6.1. It can be used to play videos but also to play music formats that are not supported by SFML (such as MP3).

Here is a short example on how to use the sfe::Video class :
Code: [Select]
int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "SFE Video");
    sfe::Video video;
   
    if (!video.OpenFromFile("video.avi"))
        return 1;
   
    video.Play();
   
    while (window.IsOpened())
    {
        sf::Event ev;
        while (window.GetEvent(ev))
        {
            if (ev.Type == sf::Event::Closed)
                window.Close();
        }
       
        window.Clear();
        window.Draw(video);
        window.Display();
    }
   
    return 0;
}

The sources, dependencies and project files (currently CodeBlocks 10.05 project for Windows and Xcode project for Mac OS X) can be downloaded from here.

Currently known issues :
- if your computer is too slow to decode the video, no video frame will be skiped, thus the video will get late
- video decoding is still not very efficient on high resolution videos on Windows (such as 1280x720)

Currently implemented features :
- video support with these formats* (short list) : FLV, H264, MPEG4, Theora, WMV
- audio support with these formats* (short list) : AAC, AC3, FLAC, MP3, PCM, Vorbis, WMA
- audio and video synchronization**
- getting some properties such as the video duration, size and framerate
- setting the sound volume
- scaling the video to fit a any frame (and every other sf::Drawable's features)
- basic video controls : play, pause, stop

Once the class gets stable enough, it'll be posted on the wiki :) .

* this list depends on the configuration options you use when building the FFmpeg binaries. It can includes GPL and non-free dependencies, but the default FFmpeg configuration is under the LGPL licence. See Video.h for a more detailed list of the video and audio formats supported with a basic build.

** video is synchronized until your CPU is fast enough to support the requested video framerate. If your CPU is faster, the video will keep a normal speed, but if it's too slow the video will get late. There is currently no support for skipping frames when the video decoding is late.
« Last Edit: August 13, 2012, 11:10:19 AM by Ceylo »
Want to play movies in your SFML application? Have a look at sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #1 on: November 01, 2010, 02:56:46 PM »
Some news here. I've added the following methods to the sfe::Video class:
- HasAudioTrack()
- HasVideoTrack()
- GetVolume()
- GetSampleRate()
- GetChannelsCount()
- GetPlayingOffset()
- GetImageCopy()

So.. nothing really interesting except maybe the latest method : GetImageCopy(). It allows you to get a copy of the current image of the video. I've just been doing some testing and.. it works quite well with small resolutions. With a video resolution of 320x240 px and live file saving, there's about 1 MB/s written to the disk and each image file weights about 120 KB. But on bigger video resolutions, you will definitely notice the difference.

I'm also thinking of a way to modify the next picture to be displayed right after it's been decoded, thus you can apply some effects like shader effects. I think I'll do something similar to how sf::Thread works : provide a function pointer or use inheritance. Anyway, if you wish to modify the image, you'll have to handle raw RGBA data.
Want to play movies in your SFML application? Have a look at sfeMovie!

Nexus

  • Hero Member
  • *****
  • Posts: 4572
  • Thor developer and interim SFML maintainer
    • View Profile
    • Bromeon
sfeMovie project [v1.0 RC1 available]
« Reply #2 on: November 01, 2010, 06:53:25 PM »
Hey, this sounds great! A video implementation in addition to SFML is really interesting. I especially appreciate that you are trying to design an API that is close to SFML's. It will make the usage more intuitive.

Keep us up to date! :)
Thor C++ Library: Particle systems, animations, dot products, event handlers and much more!
Learn SFML while developing a complete game in the book SFML Game Development!

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #3 on: November 01, 2010, 09:17:53 PM »
Thanks for the comment !

If you want to get the latest information and can read French, here is the original topic.

But don't worry, I'll still post all of the updates here too though :) .
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #4 on: November 02, 2010, 06:27:45 AM »
Hi Celyo,

Wow, your Video class is better than mine :)

The only thing I like better about mine is that the my Video doesn't contain a Sprite within, and I defined implicit cast (operator const sf::Image&), so that the video can be used as an image and linked to many sprites.

Also, I hope you don't mind, I blatantly copied a little part of your code into mine. The part in which you calculate the frame rate. My frame rate calculation was wrong (I think it changed in ffmpeg).

Xorlium

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #5 on: November 02, 2010, 04:15:13 PM »
Well, I don't really mind until you write you took some parts from another author. Anyway I'm pleased, it means my work looks good to you :D .

Otherwise, I don't really understand why you would like to link the image to many sprites ? I mean, do you have a example where this would be useful ?


As for the news, it's been decided there would not be any support for shader effects on the video, especially because we could not find any example where the users NEED to apply an effect to the movie only. And as SFML already supports effects on the whole window, it means less useless work for me :) .

For now, I have to change the 'Video' name to 'Movie' as suggested on the French forum and fix the Move::Stop() method that does not go back to the beginning of the movie. I also have a few surprises that, I hope, you'll appreciate :P .

By the way, as sf::SoundStream in SFML 1.x does not support audio seeking, I may not implement movie seeking for now.
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #6 on: November 02, 2010, 05:33:08 PM »
Hi Ceylo,

I mentioned in the download (wiki), but not in the actual source code. Should I?

Anyway, in my project, I use many sprites with the same video all the time. And I also use shaders on the video, and that comes for free with my design, since the programmer has full control on when and where to render the video.

Imagine the same video being played in many different parts of the screen, or the "game world". Maybe it's a special effect, or a video texture.

And it's not hard to do (it's actually easier), check it out: http://www.sfml-dev.org/wiki/en/sources/video_integration

Anyway, good luck.

Xorlium

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #7 on: November 02, 2010, 05:52:07 PM »
It does look fine to me as it is now. Giving the name on the wiki and explaining what has been used is really enough :) . Anyway, it's more like something I appreciate rather than an obligation.

As explained by the zlib/ligpng licence :
Quote
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.


Well.. here you only used a really small part of it, but I think it's similar. At least, that's the idea.


As for your project, do you mean you use movies to display animations ? Do you have a screenshot or something like that to show us ?

It does look like you planned to use your movie class for a very specific use (which may also explains why you do not support audio), whereas I'm trying to do something rather general and for a basic use : display an introduction movie for a video game, or display transition movies.


Edit: by the way, I'm not saying I did all of the work too. The first work I've been noticing is the video integration tutorial posted by timidouveg, although it's mostly copied from the ffmpeg tutorial with some improvements especially as for the deprecated functions. I admit I did not post any thanks for now, but you can be sure they will be present when sfe::Movie get posted on the wiki.
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #8 on: November 02, 2010, 06:20:06 PM »
Hi Celyo,

Sure, but don't laugh ;) Here's an image:
http://grola.no-ip.org/snapshot.png

The two weird-looking things (pointed to in red; I realize most of it is weird looking :)) are video textures, generated from a video source file (in mkv format) and shaders, so that it can take different shapes.

I made mine for this particularly, but I realized it can be used as a "moving texture".

But for example, say someone wants to add subtitles to the intro movie. How would they do it with yours?

Of course, the problem with mine is that it doesn't have any sound :)

Xorlium

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #9 on: November 02, 2010, 06:38:58 PM »
Well, as for the subtitles, I guess the developer would have to hardcode it in the movie, or display it with a sf::String on the movie's image. FFmpeg can also read the subtitles from the movie's file, but I didn't add any support for this point.

So, from what I understand, you used a movie to display an animation. Wouldn't a basic image sequence or animation sheet be easier to use ? You can also apply shaders with these.
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #10 on: November 02, 2010, 06:53:24 PM »
Hi Celyo,

Well, considering the image size is about 700x700 and there are about 10000 frames, it really is better with video :)

The thing is, I'm thinking of a video as an sf::Image that just happens to change over time.

For simple animations with 25 frames or so, sure, multiple images might be better, but when you get in the thousands...

And then if you have a consistent way to interchange videos and images, then why not?

Xorlium

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #11 on: November 02, 2010, 07:46:00 PM »
Ok I understand better now. Indeed I had never considered so big and long animations :D . But I'm still curious about why you need these. I mean, on your screenshot, I can only see a animation that is about 100x100 pixels, and I don't really realise why you would need a 10 000 frames' animation. It represents an animation of more than 6 hours with 25 FPS :o .

And can you easily change the video ? Because encoding 6 hours is.. well... quite long :mrgreen: . Whereas with basic animations you can change only the concerned image.
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #12 on: November 02, 2010, 08:25:58 PM »
Check your math there :)

10000 frames at 25fps is 6 minutes, not 6 hours :) And it takes about 1-2 hours to generate (I generate them using libnoise), and another hour or so to encode.

On the screenshot I showed a zoomed out version (in my game, you can zoom in and out) so that you'd see both "nebulas".

Xorlium

Ceylo

  • Hero Member
  • *****
  • Posts: 2144
    • View Profile
    • http://lucas.soltic.etu.p.luminy.univ-amu.fr/
    • Email
sfeMovie project [v1.0 RC1 available]
« Reply #13 on: November 02, 2010, 08:32:52 PM »
Oh well, please forgive me for the 6 hours, I'm a bit tired :mrgreen: .

And sooo.. you don't mind having to wait for.. 2-3 hours to get your movie ready to use ? Did you do some testing with basic animations ?
Want to play movies in your SFML application? Have a look at sfeMovie!

Xorlium

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
sfeMovie project [v1.0 RC1 available]
« Reply #14 on: November 02, 2010, 08:47:04 PM »
Hi Celyo,

Yes, I tried first to generate it on the fly, but it dropped my framerate abruptly. I tried maany different ways until I came to this one.

The reason I must have 10000 frames is that I wanted it to be cyclical. Libnoise generates coherent 3d noise, so what I do is I take a torus and generate it like that, so that the last frame is the same as the first frame. If I take less than that many frames, it "moves" too fast (or too choppy if I decrease fps), and if I decrease the radius of the Torus, I get the right of the image moving way faster than the left.

Also, I encoded the video a long time ago and haven't had to re-encode since. And at the beginning I generating it on the fly, which meant that at least for small (like 200x200 pixels) it was still fast enough for me to test and tweak as much as I wanted in real time. Once that worked well, I just scaled up. Nailed it in the second try :) (I did have to encode two times because I was using only 1000 frames and that made it jump way too fast, but whatever)

Xorlium