Building sfeMovie on MSYS2 – A Hacky Way

I’m working on a project to automatically generate Groove Coaster beat maps(?) using machine learning. To gather traning data. I need a desktop application that plays video of other’s playing Groove Coaster and I and my friend pressing the appropriate button on a DS4 controller. Getting DS4 button press is easy. SFML has that handled. But SFML does not have video playback functionality. So I need a solution.

sfeMovie

After few minutes of googling. The internet says that there are 2 ways to pay video on SFML.

  1. Call ffmpeg yourself.
  2. A library called sfeMovie can help

The apparent solution is to use sfeMovie. Using ffmpeg will be a pain(It’s a low level library).

Reading trough the getting started page of sfeMovie’s site. It supports MSYS2! (the developmenting enviroment I use). But there is no pre built package for it. I need to build it my self. No problem. Sounds easy.

Sure it is. But some hack is required.

Installing depedency

First, install all the dependency needed by sfeMovie. You need gcc, make, tar, cmake, yasm , sfml and ffmpeg to build it.

Assuming you have a clean 64bit MSYS2 installation. Here is how to install everything needed.

GCC.

pacman -S mingw64/mingw-w64-x86_64-gcc

cmake

pacman -S mingw64/mingw-w64-x86_64-cmake

tar, yasm and make

pacman -S tar yasm make

sfml

pacman -S mingw64/mingw-w64-x86_64-sfml

ffmpeg

pacman -S mingw64/mingw-w64-x86_64-sfml

And you shoud be good with the depedency.

Building sfeMovie

Next, we start to build sfeMovie. Get the source with git or any other means. Then cd into it. For example

git clone https://github.com/Yalir/sfeMovie
cd sfeMovie

After it is done. run CMake with the following command. Note that on Windows. CMake generate makefiles for raw MinGW. But we want CMake to generate makefiles for MSYS. Thus the -G parameter is used to do that.

cmake -G "MSYS Makefiles" .

Now, you will run into a error that shows that only MSVC 2013 or later is supported on Windows. Like this

sfeerror.pngTo patch this out. Go to line 42 of CMakeLists.txt. You will see the following lines. Comment them out.

if (WINDOWS AND NOT MSVC)
    message(FATAL_ERROR "Only Visual Studio (2013 and later) is supported on Windows")
endif()

Then, run cmake .

CMake should execute successfully now. Now, run make to build the project. After a short while. It should report that FFMpeg failed to build caused by cl​ cannot produce required files.

sfeerror2.pngThis is caued by the cl command can’t be found. Which is MSVC’s C++ compiler. I have no idea why FFMpeg is trying to use MSVC’s compiler under MSYS2. But it is a probolem. Run cmake -DSFEMOVIE_BUILD_FFMPEG=FALSE to make sfeMovie to use the ffmpeg we installed eariler.

Now run make again. It should build for a while. Then this error message shuld show up.

error: 'PIX_FMT_RGBA' was not declared in this scope

sfeerror3.png

It seems that some weired thing is happning. fseMovie is not using the headers from the system but using it’s own FFMpeg header. Now, copy the system’s FFMpeg header to sfeMovie’s FFMpeg folder. (acuatlly we only need libavutils ‘s header)

rm -rf FFmpeg/include/libavutil
cp -r /mingw64/include/libavutil FFmpeg/include/libavutil

Then, change all PIX_FMT_RGBA in src/VideoStream.cpp to AV_PIX_FMT_RGBA. There are only 2 of them. At line 63 and line 280.

Then make again. Everything should build proprtly from now. To test if sfeMovie is working properly. run bin/sfeMovieDemo.exe <path to video>. I grab a song  I’m listening to while I’b trying to build sfeMovie from YouTube. It works!

final.png

Install sfeMovie

Depite that I can compile sfeMovie. make install does not work. I need to copy everything manully. We need to copy the headers, dll and the .a linker file.

cp bin/libsfeMovie.dll /mingw64/bin/
cp bin/libsfeMovie.dll.a /mingw64/lib/
cp include/sfeMovie /mingw64/include/

Now I can keep on working on my project. 🙂

Please contect me or leave a message if you have any trouble building sfeMovie on MSYS2. I’ll do my best to help.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: