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.
After few minutes of googling. The internet says that there are 2 ways to pay video on SFML.
- Call ffmpeg yourself.
- 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.
First, install all the dependency needed by sfeMovie. You need
ffmpeg to build it.
Assuming you have a clean 64bit MSYS2 installation. Here is how to install everything needed.
pacman -S mingw64/mingw-w64-x86_64-gcc
pacman -S mingw64/mingw-w64-x86_64-cmake
tar, yasm and make
pacman -S tar yasm make
pacman -S mingw64/mingw-w64-x86_64-sfml
pacman -S mingw64/mingw-w64-x86_64-ffmpeg
And you shoud be good with the depedency.
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
To 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()
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.
This 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.
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
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
AV_PIX_FMT_RGBA. There are only 2 of them. At line 63 and line 280.
make again. Everything should build proprtly from now. To test if sfeMovie is working properly. run
bin/sfeMovieDemo.exe . I grab a song I’m listening to while I’b trying to build sfeMovie from YouTube. It works!
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.