Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to initialize on linux #17

Closed
steyrboy opened this issue Apr 7, 2016 · 29 comments
Closed

Failing to initialize on linux #17

steyrboy opened this issue Apr 7, 2016 · 29 comments
Assignees

Comments

@steyrboy
Copy link
Contributor

steyrboy commented Apr 7, 2016

I've compiled libvlc.so and libvlccore.so from the 2.2.2 source, and I get this error when trying to load a project (running on linux):

[2016.04.07-03.32.42:711][ 0]LogVlcMedia:Warning: Failed to import VLC function libvlc_media_new_callbacks
[2016.04.07-03.32.42:711][ 0]LogVlcMedia:Warning: Failed to initialize libvlc

Any ideas? I'm running a fresh 4.11 (non-preview) source build.

@gmpreussner
Copy link
Contributor

As mentioned in the README, you need to use libvlc 3.x.x

@steyrboy
Copy link
Contributor Author

steyrboy commented Apr 8, 2016

Thanks for the quick reply! I did try this out earlier today, and got different errors.

vlc: unknown option or missing mandatory argument --vmem-chroma' Tryvlc --help' for more information.
[2016.04.08-02.13.22:061][ 0]LogVlcMedia:Warning: Failed to create VLC instance ((null))

EDIT: Same error on both Ubuntu 15.10 and 14.04

@gmpreussner gmpreussner reopened this Apr 8, 2016
@gmpreussner
Copy link
Contributor

Can you try changing this to "RV16"?

I'm not exactly sure what the error message indicates. Maybe --vmem-chroma has been removed or replaced in the very latest versions. I'll see if I can repro it on Windows this weekend.

@gmpreussner
Copy link
Contributor

I had a quick look at the VLC code. It looks like vmem-chroma is still there. Maybe your video_output module isn't loaded for some reason? Is there anything else in the log? Can you attach the whole output?

@gmpreussner
Copy link
Contributor

Oh, you know what, I know what it is. It's not finding your VLC plug-in modules. The Linux build rules are not yet configured in the VlcMedia module. I haven't had time yet to work on that. There's likely stuff missing in VlcMedia.Build.cs and Vlc.cpp. The plug-in directory is configured in VlcMediaModule.cpp

The main issue is that I haven't figured out yet how to deal with VLC binaries on Linux. It is not clear what should be redistributed and how. It might be best to assume that libvlc is installed on the machine, although that may not be user friendly.

If you have any ideas, please let me know.

@steyrboy
Copy link
Contributor Author

I've tried to hack it together on my end, but still no luck. in VlcMedia.Build.cs I added the following code:

            if (Target.Platform == UnrealTargetPlatform.Linux)
            {
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so.5")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so.5.5.0")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so.5.5.0T")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlccore.so")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlccore.so.8")));
                RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlccore.so.8.0.0")));
            }

and Vlc.cpp:


#if PLATFORM_LINUX
    const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Linux"));

I added the executables and plugins built from VLC into the ThirdParty and ThirdParty/Linux/plugins folders in my engine source plugins folder along side the files you provide. The files do get copied over correctly during the build process. I am still stuck with the following error, with no other errors/warnings:

[2016.04.10-22.26.08:923][ 0]LogVlcMedia:Warning: Failed to create VLC instance ((null))

Before trying all of this, I built VLC form source and did a make install. The correct version of VLC is installed on the PC, but it still errors out saying the executables are missing.

@gmpreussner
Copy link
Contributor

We're still trying to get Linux support done and may look into it this week.

@steyrboy
Copy link
Contributor Author

I was able to get it working, but not in the most optimal way. I had to build VLC from source, then add symlinks to the project's binaries folder that point to the correct libs/execs in the installed directory in Linux. Ideally the correct libs/execs will be packaged with the project, but this workaround fits my needs (for now).

gmpreussner added a commit that referenced this issue Jul 15, 2016
@djiamnot
Copy link

Thank you for the comments in #24. So, those comments and this issue got me much further, the plugin compiles, loads and seems to initialize. For the record, I resorted to compilation of vlc by hand as well.

I can now play videos, however, they are rendered wrong, as in most of the time I get screen-fulls of solid green with occasional flickering of images that actually belong to the video. I wonder if @steyrboy has experienced this kind of artifact, or anyone else for that matter. I used vlc master branch and even tried it against ffmpeg tagged n3.1.3. I tried playing mjpeg and h264 encoded videos with the same results (both in the editor in "game"). I think it's still related to this issue...

@faemir
Copy link

faemir commented Oct 10, 2016

Using vlc-nightly from the AUR, then symlinked the files as @steyrboy mentioned got this running for me on Arch Linux. I get a green band at the bottom of the clips, regardless of format and video container. No sound is played (using the media sound wave uasset) either, with these errors logged:

[2016.10.10-22.16.03:138][177]LogVlcMedia:Warning: Possible loss of audio quality due to sample rate != 44100 Hz
[2016.10.10-22.16.03:140][177]LogALAudio:Warning: ALSoundBuffer wave 'TVclips_MediaPlayer_Sound' has an invalid decompression type 5.
[2016.10.10-22.16.03:140][177]LogALAudio:Warning: ALSoundBuffer init failed for wave 'TVclips_MediaPlayer_Sound', decompression type 5.
[2016.10.10-22.16.03:140][177]LogALAudio:Warning: Failed to initialize sound source with WaveInstance 'TVclips_MediaPlayer_Sound'.
[2016.10.10-22.16.03:141][177]LogALAudio:Warning: SampleRate 44100
[2016.10.10-22.16.03:141][177]LogALAudio:Warning: Channels 2
[2016.10.10-22.16.03:141][177]LogAudio:Warning: Failed to start sound source for TVclips_MediaPlayer_Sound

@gmpreussner
Copy link
Contributor

I added a new issue for the green bar. It's a known issue, but I forgot to bug it.

As for the sound problem, it looks like Linux doesn't support procedural sound sources (DTYPE_Procedural) yet. @RCL @amcleran Any idea on when this is coming?

@JoernMueller
Copy link

I'm also hitting the VLC instantiation error stating:
[33m[2017.05.23-14.06.52:698][ 0]LogVlcMedia:Warning: Failed to create VLC instance ((null))

I'm using VLC binaries from the nightly builds of 10th Nov. 16 and 20. March 17 and try to resemble the Win or Mac folder within the plugins ThirdParty directory for Linux. I already tried it with a categorized plugin folder (like Win) and with a flat plugin folder (like Mac) as well as with a symlink to the install path of the nightly build snap of VLC as suggested by @steyrboy. So far all without success. Although libvlc.so and libvlccore.so are loading and all function pointers are initialized well. The call FVlc::New(Argc, Args); returns NULL without any further logs messages from VLC. I guess some required files are missing or my folder layout is not in the shape desired by VLC.
I had to disable the --plugin-path command line argument, because when passing it I recieve
Warning: option --plugin-path no longer exists.
So this might be another chance for the UE4 plugin to miss it's VLC plugin folder.

So I would highly appreciate any hints or help on this issue, especially on any of the following topics:

  • Is there any precompiled libvlc binary (from the nightlies) that is confirmed to work with this plugin in its version compatible with UE4.14?
  • What are the required dependencies of libvlc and it's expected folder layout for the ThirdParty/vlc/Linux directory? I really would like to see these files already included in this repo.
  • Is there any known way to make VLC a bit more talkier? I already tried to enforce the --verbose=2 param, but at least at this instantiation issue it seems to have no effect.

Thanks in advance for any advice.

@gmpreussner
Copy link
Contributor

gmpreussner commented May 24, 2017

Is there any precompiled libvlc binary [..] that is confirmed to work with this plugin

No, Linux is completely untested.

What are the required dependencies of libvlc and it's expected folder layout

ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu
ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu/plugins

I really would like to see these files already included in this repo

Agreed, but which distro/version shall we ship for?

Is there any known way to make VLC a bit more talkier?

--verbose=0

@JoernMueller
Copy link

@gmpreussner Many thanks for your hints and the great work on this project.

I finally figured out form studying the libvlc unit tests that the --plugin-path param was replaced with a VLC_PLUGIN_PATH environment variable that has to be set properly for FVlc::New(Argc, Args); to succeed. This seems to fix this initialization issue for me.
Sadly this doesn't mean video playback is working for me right now on Linux, while it did right out of the box for Windows. If I should come upon some insights on this worth sharing I certainly will report on it.

@JoernMueller
Copy link

I finally got it working for Linux and would like to share some of my findings.

Logging and error reporting of vlc
turned out to be the major obstacle for me to get things working. --verbose=2 seems to be the right way to go for debug output, while 0 only seems to print regular messages and errors. Besides this I added

[Core.Log]
LogVlcMedia=VeryVerbose

to the DefaultEngine.ini to get the logs of the plugin itself. But all this did not reveal any problems. I also tried to extend FVlcMediaPlayer::StaticEventCallback() for error events but it also remained without effect. Finally I set --file-logging --logfile=/home/<USER>/vlc-log.txt as additional arguments for libvlc and observed that the logfile did contain other output than the log vlc writes to stdout. From this logfile I could at least figure out which binary dependencies libvlc couldn't load. But when trying to play a video file there were no complaints or errors in any of the logs. I just observed a black screen and the FVlcMediaOutput::StaticVideo...Callback() methods never got called while the audio callbacks did.

Binary dependencies
To fix the missing *.so files reported by the vlc logfile I did not use symlinks but added the required folders of the snap install to the LD_LIBRARY_PATH. This works for a development setup and looks like LD_LIBRARY_PATH=/snap/vlc/x1/usr/lib/:/snap/vlc/x1/lib/vlc/:/snap/vlc/x1/usr/lib/x86_64-linux-gnu/:/snap/vlc/x1/lib/x86_64-linux-gnu/:/snap/vlc/x1/usr/lib/x86_64-linux-gnu/pulseaudio/ For the shipping version I guess all this stuff (roughly 200 MB) needs to be included.

I hope this might be helpful for anybody and appreciate any comments or suggestions for possible improvements.

@gmpreussner
Copy link
Contributor

verbose=2 seems to be the right way to go for debug output

You're right, the libvlc documentation is wrong. The correct log levels are: 0 = errors, 1 = warnings, 2 = debug. I'll fix it up.

I set --file-logging --logfile=/home//vlc-log.txt as additional arguments for libvlc

Thanks, I will add this for Debug builds as well,

For the shipping version I guess all this stuff (roughly 200 MB) needs to be included

Yeah, we need more time to figure out Linux support in general. In the meantime, I recommend that developers perform this step manually just like you did. Thanks for looking into it! This is a good start.

@dodgyville
Copy link

dodgyville commented Jul 26, 2017

Alas I can't get the method outlined by jmuellerRFG to work on UE4Engine 4.17

sudo snap install vlc --edge (any channel--- they all seem to point same 2017-01-20 release)

LD_LIBRARY_PATH=/snap/vlc/4/usr/lib/:/snap/vlc/4/lib/vlc/:/snap/vlc/4/usr/lib/x86_64-linux-gnu/:/snap/vlc/4/lib/x86_64-linux-gnu/:/snap/vlc/4/usr/lib/x86_64-linux-gnu/pulseaudio/ ./Engine/Binaries/Linux/UE4Editor

Gives:

[2017.07.26-09.02.12:540][ 0]LogLinux: Warning: dlopen failed: /home/user/Projects/UnrealEngine/Engine/Plugins/Media/VlcMedia/ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu/libvlccore.so: cannot open shared object file: No such file or directory
[2017.07.26-09.02.12:540][ 0]LogVlcMedia: Warning: Failed to load required library libvlccore.so. Plug-in will not be functional.
[2017.07.26-09.02.12:540][ 0]LogVlcMedia: Error: Failed to initialize libvlc

@JoernMueller
Copy link

JoernMueller commented Jul 26, 2017

Hello @dodgyville,

please be aware that loading of binary dependencies in this case happens in a sort of cascade and my guess from your logs would be that there is one level of it missing. It should work out like this:

  1. UE4 Engine
  2. VlcMedia-Plugin (from this repo) is compiled into the engine
  3. libvlc and vlccore
  4. all the vlc plugins (mixer, muxer, decoders, ...)

The paths set in LD_LIBRARY_PATH are intended to provide the location of the vlc plugins (4) but the missing vlccore (3) your log is talking about is loaded from the VlcMedia-Plugin (2) which always expect this library in the path <Engine|Game>/Plugins/Media/VlcMedia/ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu/. (You can have a look in Vlc.cpp to get a clue how this path is assembled on different platforms.) So you should make sure these files are present at this location. Then it should be possible to use the vlc plugins from the snap folder for a development setup.

For shipping I included all the binary dependencies of libvlc into subfolders of this plugin in the final package. (See Directory Listing.)
The LD_LIBRARY_PATH then needs to be set to LD_LIBRARY_PATH=./<GAME>/Plugins/VlcMedia/ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH

@dodgyville
Copy link

dodgyville commented Jul 28, 2017

Thanks for your reply @jmuellerRFG - that got it working!

Here's what I did to get it going on Ubuntu 17.04 in case someone else is reading this.


# add the VlcMedia plugin to the engine
cd  <path>/Engine/Plugins/Media/
git clone https://github.com/ue4plugins/VlcMedia

# Now compile UE4Engine (it will build with VlcMedia plugin)
cd  <path>
make

# install vlc and make it available to the VlcMedia plugin
sudo snap install vlc
cd <path>/Engine/Plugins/Media/VlcMedia/ThirdParty/vlc
mkdir Linux
cd Linux
ln -s /snap/vlc/4/lib x86_64-unknown-linux-gnu

Then I added the following lines (relevant to my directory structure) to my ~/.bashrc

LD_LIBRARY_PATH=/snap/vlc/4/usr/lib/:/snap/vlc/4/lib/vlc/:/snap/vlc/4/usr/lib/x86_64-linux-gnu/:/snap/vlc/4/lib/x86_64-linux-gnu/:/snap/vlc/4/usr/lib/x86_64-linux-gnu/pulseaudio/:/snap/vlc/4/lib/:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=<path>/Engine/Plugins/Media/VlcMedia/ThirdParty/vlc/Linux/x86_64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH

Open a new terminal (to pick up the changes in bashrc), run the engine, it should be good to go!

@gmpreussner
Copy link
Contributor

I'd like to find a way for us to include all the required libraries in the VlcMedia plug-in itself. Then users can just download the latest VlcMedia release and be good to go. I don't want to be in the business of compiling VLC myself, so it would be best if we could just use the packages from the VLC Nightly Builds web site. Maybe we can extract the binaries from the snap package, put them into the ThirdParty directory and then add some logic to the Build.cs and Vlc.cpp to wire it all up correctly when packaging and at run-time.

If anyone has any idea about how to best approach this, I'd love to hear from you.

@JoernMueller
Copy link

JoernMueller commented Aug 1, 2017

I can totally agree with this. Getting the binary dependencies in a more automated way would be great. But I would try to stick one version of VlcMedia to one defined version of libvlc rather than getting their latest build, as they might change interfaces and then things get out of sync.

For me these scripts are working:

So far I call the first one manually and the latter by an other script that generates the final package. But I guess it is also possible to integrate them into the Build.cs so that no further manual operation is required.

Also I added the following to VlcMedia.Build.cs to get also the lib folder copied to the final package:

if( Target.Platform == UnrealTargetPlatform.Linux )
{
    string LibDirectory = Path.Combine( VlcDirectory, "lib" );
    if( Directory.Exists( LibDirectory ))
    {
        foreach( string Lib in Directory.EnumerateFiles( LibDirectory ))
        {
            RuntimeDependencies.Add( new RuntimeDependency( Lib ));
        }
    }
}

What I don't like on this approach is that it comes with it's own dependencies to the presence of the snap tools and files on the server of the vlc project.

@Alexei-Kondratiev
Copy link
Contributor

To install "VLC Daily Build of master branch" and build VlcMedia as a project plug-in for UE4.18.0 on Ubuntu 16.04.1 LTS I run bash script from my "Game" project folder:

SetupVlcMedia.sh.txt

This solution (without binary dependencies in plug-in folder) works for me.

@JoernMueller
Copy link

JoernMueller commented Nov 2, 2017

Hi folks,

it seems that the approach I described above to ship all required binary dependencies is not working properly for all distributions/configurations. What I did so far was to ship all of the following files:

  • libvlc and vlccore
  • the vlc plug-ins (mixer, muxer, decoders, ...)
  • the binary dependencies of the vlc plug-ins (basically all .so files from the vlc nightly snap)

I just dumped the files of the last category into a folder and added it to the LD_LIBRARY_PATH. As I did not (and do not want to) build the vlc plug-ins myself, setting rpaths was not an option. This approach worked in my development setup but feedback from our community showed that this led to problems on several distros, probably caused by non-ABI-compatible dependencies of these dependencies installed on the system. Also a closer look at this .so files made clear that some of them are libraries that are part of the Linux Standards Base (LSB) and thus should be expected to exist on any Linux system. So far I have not found a sane and reliable way to separate these system libraries from other libraries contained in the original snap file. Just removing the LD_LIBRARY_PATH did resolve the incompatible dependencies issue for several of our customers but shipping the game this way is also not an option as this would break things for other users.
In general I would consider making a vlc installation a required prerequisite for the game, but I guess this would also mean to enforce a fixed version of it to maintain ABI compatibility with the engine plug-in and I would not like to possibly push our customers to downgrade or not update the vlc version on their system. Also it seems that running the game on the development system is working exclusively with the .so-files from the snap, trying to replace them with a vlc installation via apt results in a core dump.
I'm aware that the issue of providing required binaries on arbitrary distributions is not specific to VlcMedia plug-in, but it is also affected by this problem and I have not found a solution for this that is working for at least the majority of systems it would be great to get some advice or perpetuate the discussion on this.

@dodgyville
Copy link

I wish ue4 used ogg theora

@agrohn
Copy link

agrohn commented Nov 6, 2017

Got this working on a Gentoo box using similar approach as @Alexei-Kondratiev - with the difference of compiling latest vlc version from git repo (using vlc-9999 ebuild).

@gmpreussner
Copy link
Contributor

it seems that the approach I described above to ship all required binary dependencies is not working properly for all distributions/configurations

Please also note that there is a bug in 4.18 that breaks all media playback in Shipping builds. It was fixed for 4.18.1 (https://github.com/EpicGames/UnrealEngine/commit/2f1c3e2a2933acd351c5ca260342f7d05df7fae3)

@JoernMueller
Copy link

Thanks for this hint. We are still using 4.16, so the issues I described are probably not related to this bug, but it's good to know about it.
The general approach for dealing with dependencies like this probably would be either providing source and a makefile or creating a package (apt, rpm, ...) that keeps track of the required dependencies. Both options are obviously not a viable way for distributing a payed game.

@Alexei-Kondratiev
Copy link
Contributor

How to run VlcMedia plug-in on UE4.18.1 and Ubuntu 16.04 LTS:

  1. Create C++ project.
  2. Install VlcMedia plug-in in to this folder: GAME/Plugins/
    2.1 File VlcMedia.Build.cs needs to be corrected:
    comment this lines of code (reason for that - version of VLC libs now is libvlc.so.5.6.0 and libvlccore.so.9.0.0, it is better to keep unversioned shared libs references):

// RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so.5.5.0")));
// RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlccore.so.8.0.0")));
// RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlc.so.5")));
// RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(VlcDirectory, "libvlccore.so.8")));

  1. Run bash script from Project ("GAME") folder to clean-up/install VLC and configure VlcMedia:
    VlcMedia4Linux.sh.txt
  2. Compile and run project. You will get some wornings and errors in a terminal on playing the video, but it will play video. I am using test videos from: http://www.sample-videos.com/
  3. Project packaging:
    5.1 Run packaging for Linux.
    5.2 Run bash script from Project ("GAME") folder to configure GAME/LinuxNoEditor package:
    LinuxNoEditorFix.sh.txt
    5.3 Run packaged project. You will get some wornings and errors in a terminal on playing the video, but it will play video.
  4. For a final package distribution it is better to use a ‘snap’ as a universal Linux package:
    https://www.ubuntu.com/desktop/snappy

Good luck!

@gmpreussner
Copy link
Contributor

Please try Alexei's changes in the 4.19 plugin version, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants