Succesfull CasparCG 2.2 linux build

We have been able to build CasparCG 2.2 in ubuntu 18.04.
We followed the following steps:

  1. We downloaded code from https://github.com/CasparCG/server/releases
  2. executed the following steps
  3. Install dependencies apt-get install git cmake build-essential g++ libglew-dev libfreeimage-dev libtbb-dev libsndfile1-dev libopenal-dev libjpeg-dev libfreetype6-dev libglfw3-dev libxcursor-dev libxinerama-dev libxi-dev libsfml-dev libvpx-dev libwebp-dev liblzma-dev libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libx264-dev libx265-dev libbz2-dev libssl-dev libcrypto++-dev librtmp-dev libgmp-dev libxcb-shm0-dev libass-dev libgconf2-dev
  4. Install Docker by following installation instructions from [Docker Docs][1]
  5. git clone --single-branch --branch master https://github.com/CasparCG/server casparcg-server-master
  6. cd casparcg-server-master
  7. Extract Boost, FFmpeg and CEF from the docker images via sudo ./tools/linux/extract-deps-from-docker. Alternatively these can be prepared manually by following the steps laid out in each Dockerfile
  8. mkdir build && cd build
  9. cmake ../src
  10. make -j8

When we tried to run the build we got an error message.missing ā€œErrNo.ā€
We included the follwoing to resolve the error.
In Casparcg server master folder inside src>tools there is a bin2c.cpp file.There we have added
#include<errno.h>
From staging folder we were able to start CasparCG 2.2 linux server successfully

Hey @Syscaspar - thank you for putting this info up here. I have struggled with getting things working on Linux and the official documentation seems to be lacking a bit. (Iā€™m looking at submitting some changes once Iā€™ve got everything running correctly!)

A few questions, if you donā€™t mind:

  1. Do you have any updates to this method or is this still working well for you?
  2. Is this running on Ubuntu Desktop or Server?
  3. Are you using this on a headless server or with a GUI/desktop on the Caspar box?

Many thanks

The steps above look to be directly copied from https://github.com/CasparCG/server/blob/master/BUILDING.md#development, with a fix applied to a file because it caused the build to fail.

What have you been struggling with for building? Those steps work for me, but only on ubuntu18.04. On any other version or distro, ā€˜Extract Boost, FFmpeg and CEFā€™ step has to be done differently.

Those steps are targetting Ubuntu desktop. Doing it on server should work too, but will likely need more dependencies installed. (Also expect it to install a lot more packages than those listed)

Thanks @Julusian, I am indeed trying to install and run on a headless server, running in AWS ec2. (A g3.4xlarge instance)

Running CGC results in

[0618/203706.396046:ERROR:browser_main_loop.cc(1653)] Unable to open X display.

Iā€™m making some slow progress in understanding the issues Iā€™m facing but youā€™ll still need to bear with me! Here is what I know so far:

The output of readelf -d casparcg | grep NEEDED is

 0x0000000000000001 (NEEDED)             Shared library: [libtbb.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libtbbmalloc.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libtbbmalloc_proxy.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libsfml-graphics.so.2.4]
 0x0000000000000001 (NEEDED)             Shared library: [libsfml-window.so.2.4]
 0x0000000000000001 (NEEDED)             Shared library: [libsfml-system.so.2.4]
 0x0000000000000001 (NEEDED)             Shared library: [libGLEW.so.2.0]
 0x0000000000000001 (NEEDED)             Shared library: [libGL.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libX11.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libvpx.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libwebpmux.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libwebp.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [liblzma.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libfdk-aac.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libmp3lame.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libopus.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libtheoraenc.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libtheoradec.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libvorbis.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libvorbisenc.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libx264.so.152]
 0x0000000000000001 (NEEDED)             Shared library: [libx265.so.146]
 0x0000000000000001 (NEEDED)             Shared library: [libbz2.so.1.0]
 0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [librtmp.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-shm.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-shape.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-xfixes.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libass.so.9]
 0x0000000000000001 (NEEDED)             Shared library: [libfreetype.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libicui18n.so.60]
 0x0000000000000001 (NEEDED)             Shared library: [libicuuc.so.60]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libopenal.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcef.so]
 0x0000000000000001 (NEEDED)             Shared library: [libfreeimage.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

And so it looks like I might be able to somehow manually link CasparCG to the correct drivers and also to use an ā€œOpenGL contextā€, as per the Nvidia blog, but I will need a bit of help to join up those dots (if indeed that is the correct path to go down).

Thanks as always

Xvfb doesnā€™t support hardware acceleration so itā€™s no good as a dummy X server.

Ah. Itā€™s been a while since I have tried any of this, so I was probably thinking of a 2.1 (cpu mixer) setup without a gpu then.

Maybe an X server (dummy or otherwise) isnā€™t necessary anymore as the Nvidia driver supports EGL

I looked into using EGL a while ago, but SFML which is used to get the OpenGL context only works with X11. I havent checked since then, so it might have changed in newer versions.

1 Like

Hi @peedrr have you made any progress on the headless server?, Iā€™m looking to do the same but on google cloudā€¦ for now Iā€™m stuck at the same point as you.

I found the same article and also This updated post on stackoverflow and this blog post from Nvidia but I donā€™t really understand anything at this point, hehe

btw for me was a lot easier to install and build Casparcg using the Building inside Docker procedure and then just use ./tools/linux/extract-from-docker.

Not really, no. Iā€™m hoping to take another bash at it one evening this week. Current thoughts are to implement VirtualGL as it seems to do whatā€™s needed, plus it has a very short guide specifically for Nvidia Headless Servers which seems to fit the bill.

Iā€™ll post my findings in here, but let me know if you get a chance to try this out before me. Would be good to pool our knowledge on here.

Iā€™ve got to say, Iā€™m slightly relieved to hear that Iā€™m not alone in this struggle, although Iā€™m finding it hard to believe that weā€™re trailblazers! Surely others in this community have already solved this problem. If anyone has any specific pointers, or knows of others who are running CasparCG headless on Linux, please shout! Iā€™m keen to get a detailed how-to guide together.

@Julusian - has CPU Mixer development been abandoned? I always thought this sounded promising, especially for cloud stuff where GPU is still a bit of a novelty and often difficult to configure

VirtualGL looks interesting. Not 100% sure if it will just work though, as caspar expects an x server to get the opengl context from, so it might still require running one manually. But VirtualGL looks like it could still be useful to provide access to an xserver/opengl over ssh.

has CPU Mixer development been abandoned?

All I know is that it has been removed from 2.2 as it was a burden and to allow some abstractions to be removed.
Personally I agree that it has its uses. Cloud instances is a good example, or even caspar channels which dont need any compositing. (eg a channel being a simple html ā†’ decklink)

I donā€™t fully understand but I was thinking the sameā€¦ I did find this on StackOverflow about creating an OpenGL context without an X server.

NVIDIA recently published an article detailing how to use OpenGL on headless systems, which is a very similar use case as the question describes.

In summary:

Link to libOpenGL.so and libEGL.so instead of libGL.so. (Your linker options should therefore be -lOpenGL -lEGL

Call eglGetDisplay, then eglInitialize to initialize EGL.
Call eglChooseConfig with the config attribute EGL_SURFACE_TYPE followed with EGL_PBUFFER_BIT.
Call eglCreatePbufferSurface, then eglBindApi(EGL_OPENGL_API);, then eglCreateContext and eglMakeCurrent.

From that point on, do your OpenGL rendering as usual, and you can blit your pixel buffer surface wherever you like. This supplementary article from NVIDIA includes a basic example and an example for multiple GPUs. The PBuffer surface can also be replaced with a window surface or pixmap surface, according to the application needs.

The linked source URL (in my previous post) gives an example, the following snippet compiles an application with support for both EGL and GLX contexts.

find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL GLX)
add_executable(your_binary_name main.c)
target_link_libraries(your_binary_name PRIVATE OpenGL::OpenGL OpenGL::EGL OpenGL::GLX)

What do you think @Julusian, Does any of this look like It could be helpful?

Depends on what functionality you need.
Caspar currently has a hard dependency on a running X server because of the library used to setup OpenGL, but that can easily be replaced with EGL, a few messages back I linked to a very outdated branch where I was playing around with that. I think that would be a pretty easy port, so doing something like that is an option.
However, CEF/Chromium also requires a running X server. I did not look much into fixing that, and that is going to be a much more difficult task to fix. It might be possible with a recompilation of CEF. Ozone looks to be the required thing to configure Log in with Atlassian account https://chromium.googlesource.com/chromium/src/+/master/docs/ozone_overview.md.
I didnā€™t have a need to run caspar on a headless machine, I was only experimenting so that is where I stopped.

I donā€™t fully understand but I was thinking the sameā€¦

What I was trying to say is that Caspar needs an X server to setup OpenGL. But even with X running, it is not easily possible to run caspar over ssh, but VirtualGL looks like it might resolve that ssh problem.

Got it, that makes total sense! thanks!

Does anybody have any progress on the front of running CasparCG on a linux server?
I have one running VNC (for headless streaming with VLC) and tried running CasparCG, but I got the message that I do not have a GPU.
Iā€™d love to look into some light use of Caspar for Video Mixing and Overlaying, with a maximum of 1080p (but even 720p would be fine with me).
Looking forward to hearing and learning more.

Hi trying to get going on Ubuntu 18.045 and CasparCG 2.2 as described in at the top of this post as I cannot find any other guide. Maybe I should be using a newer guide/ versions? If so, can someone please point me in the direction?

Followed the guide above, all looked good until the end, got these errors:

[ 98%] Linking CXX executable casparcg
/usr/bin/ld: cannot find -lopencore-amrwb
/usr/bin/ld: cannot find -lsnappy
collect2: error: ld returned 1 exit status
shell/CMakeFiles/casparcg.dir/build.make:183: recipe for target ā€˜shell/casparcgā€™ failed
make[2]: *** [shell/casparcg] Error 1
CMakeFiles/Makefile2:808: recipe for target ā€˜shell/CMakeFiles/casparcg.dir/allā€™ failed
make[1]: *** [shell/CMakeFiles/casparcg.dir/all] Error 2
Makefile:83: recipe for target ā€˜allā€™ failed
make: *** [all] Error 2

Then where/ how do I launch the server, new hereā€¦

Grateful for any help or guidance, thanks in advance!

Hi, I would recommend building with Docker using this guide: server/BUILDING.md at master Ā· CasparCG/server Ā· GitHub If your situation requires building without the use of Docker, troubleshooting might take longer, but the problem that it is encountering according to the log you posted is likely missing libsnappy1v5 and libopencore-amrnb0. You can install them via apt.

You will be able to run the server using run.sh script in the folder you build it in. For build extracted from docker, it will be in casparcg_server subfolder.

Ok thank you. I went through everything from the GitHub you linked, seems to have made it a little furtherā€¦

Error still seems to be looking for lopencore-amrnb

[ 99%] Building CXX object shell/CMakeFiles/casparcg.dir/linux_specific.cpp.o
[100%] Linking CXX executable casparcg
/usr/bin/ld: cannot find -lopencore-amrnb
collect2: error: ld returned 1 exit status
shell/CMakeFiles/casparcg.dir/build.make:183: recipe for target ā€˜shell/casparcgā€™ failed
make[2]: *** [shell/casparcg] Error 1
CMakeFiles/Makefile2:808: recipe for target ā€˜shell/CMakeFiles/casparcg.dir/allā€™ failed
make[1]: *** [shell/CMakeFiles/casparcg.dir/all] Error 2
Makefile:83: recipe for target ā€˜allā€™ failed
make: *** [all] Error 2

I cannot find info on lopencore-amrnbā€¦
Should I be looking for libopencore-amrnb0 and lopencore-amrnb is a typo or something?

If I do-
apt install libopencore-amrnb0
I get:

Reading package listsā€¦ Done
Building dependency tree
Reading state informationā€¦ Done
libopencore-amrnb0 is already the newest version (0.1.3-2.1).
libopencore-amrnb0 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.

Not sure on this, any ideas? Thanks!!

Added:

sudo apt update
sudo apt install libopencore-amrnb-dev

No errors but not finding the proper casparcg_server folder with casparcg.config and allā€¦

Ran basic user, only doing sudo as needed, I was full root before. May try again in root but not for Docker?

run.sh was no go but ./run.sh got thisā€¦ looks like I need a newer graphic card?

Type ā€œqā€ to close application.
Logging [info] or higher severity to log/

[2021-08-20 22:10:34.105] [info] ############################################################################
[2021-08-20 22:10:34.105] [info] CasparCG Server is distributed by the Swedish Broadcasting Corporation (SVT)
[2021-08-20 22:10:34.105] [info] under the GNU General Public License GPLv3 or higher.
[2021-08-20 22:10:34.105] [info] Please see LICENSE.TXT for details.
[2021-08-20 22:10:34.105] [info]
[2021-08-20 22:10:34.105] [info] ############################################################################
[2021-08-20 22:10:34.105] [info] Starting CasparCG Video and Graphics Playout Server 2.3.3 865502c09 Dev
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 4.5 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = true ; debug = false ; sRGB = false
Created: version = 4.3 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = true ; debug = false ; sRGB = false
[2021-08-20 22:10:34.292] [info] Initializing OpenGL Device.
[2021-08-20 22:10:34.294] [info] Initialized OpenGL 4.3 (Core Profile) Mesa 20.0.8 nouveau
[2021-08-20 22:10:34.314] [info] [asio] Shutting down global io_service.
[2021-08-20 22:10:34.314] [info] [asio] Global io_service uninitialized.
[2021-08-20 22:10:34.314] [error] Exception: /root/casparcg-server-master/casparcg-server-master/src/accelerator/ogl/util/device.cpp(113): Throw in function caspar::accelerator::ogl::device::impl::impl()
[2021-08-20 22:10:34.314] [error] Dynamic exception type: boost::exception_detail::clone_implcaspar::not_supported
[2021-08-20 22:10:34.314] [error] [caspar::tag_msg_info*] = Your graphics card does not meet the minimum hardware requirements since it does not support OpenGL 4.5 or higher.
[2021-08-20 22:10:34.314] [error] [caspar::tag_stacktrace_info*] = 0# caspar::stacktrace_info() in bin/casparcg
[2021-08-20 22:10:34.314] [error] 1# caspar::accelerator::ogl::device::impl::impl() in bin/casparcg
[2021-08-20 22:10:34.314] [error] 2# caspar::accelerator::ogl::device::device() in bin/casparcg
[2021-08-20 22:10:34.314] [error] 3# caspar::accelerator::accelerator::get_device() const in bin/casparcg
[2021-08-20 22:10:34.314] [error] 4# caspar::server::impl::impl(std::function<void (bool)>) in bin/casparcg
[2021-08-20 22:10:34.314] [error] 5# caspar::server::server(std::function<void (bool)>) in bin/casparcg
[2021-08-20 22:10:34.314] [error] 6# caspar::run(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::atomic&) in bin/casparcg
[2021-08-20 22:10:34.314] [error] 7# main in bin/casparcg
[2021-08-20 22:10:34.314] [error] 8# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
[2021-08-20 22:10:34.314] [error] 9# _start in bin/casparcg
[2021-08-20 22:10:34.314] [error]
[2021-08-20 22:10:34.314] [error]
[2021-08-20 22:10:34.314] [error] 0# caspar::log::get_stack_traceabi:cxx11 in bin/casparcg
[2021-08-20 22:10:34.314] [error] 1# main in bin/casparcg
[2021-08-20 22:10:34.314] [error] 2# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
[2021-08-20 22:10:34.314] [error] 3# _start in bin/casparcg
[2021-08-20 22:10:34.314] [error]

Hi,
you are running OpenGL 4.3 and current version of CasparCG needs 4.5. I donā€™t know what GPU you have, but maybe you just need different drivers.