Live RTSP IP Camera to NGINX with RTMP module

I am moving the discussion from my previous thread to make it easier to search for other people with this same issue.

Per my conversation with @jess I am trying to ingest multiple live RTSP feeds into NGINX compiled by Kaltura CE. However, per a discussion on this topic the the libacc nor the libfdk_acc libraries are available in the Kaltura CE version of FFMPEG.

Since the licensing prohibits the distribution of these libraries with Kaltura CE pre-configured in the compile version. If you intend to stream LIve RTSP IP Cameras through NGINX with RTMP after transcoding the feed with FFMPEG you will need to enable the FDK libraries in your version FFMPEG on your system as describe.

@jess

Now I have compile FFMPEG in the past and successfully added the libraries to my installation version of FFMPEG. However, what is not clear to me when reading this information is the following.

  1. Do I need to remove the current version Kaltura CE FFMPEG? If so how do I do this without removing its’ dependencies?

  2. This also applies to the reference of needing to recompile my own verison of NGINX with the RTMP module and I assume this is so I can configure the new version of NGINX to point to my installation of FFMPEG. Again how do I remove the old installation without breaking Kaltura CE?

  3. It is unclear if you are actually suggesting not removing the installations of these components but to recompile them and overwrite the existing configuration with the modified version with the additional libraries and modules configured as described.

Please provide some clarification on this issue and I hope this new thread is helpful to others.

Regards

Hi @hiphopservers,

The most correct solution would be for you to build your own kaltura-ffmpeg RPM/deb, which will be exactly the same as the original one, only the configure line will also include:

--enable-libfdk-aac
--enable-nonfree  

This package can then replace the original. Of course, whenever we switch to a newer FFmpeg version, you’ll need to also build a new package and install it.
Alternatively, perhaps with a smaller effort on your end [I am assuming here you do not have extensive packaging experience], you could build your own FFmpeg manually, again, using all the same dependencies utilised when building kaltura-ffmpeg but install it onto an alternative location. Then, you will need to make sure the alt location is added to PATH [BEFORE the kaltura-ffmpeg binaries so that it takes precedence] and also that the path where the FFmpeg shared objects reside is included in the LD path. For this there are two options:

  • Add it to LD_LIBRARY_PATH and export it from one of the RC files [/etc/profile, /etc/bashrc, etc]
  • Or, the better option, add a file to the LD and profile scandirs, which is what we do for our packages:
/etc/ld.so.conf.d/kaltura*ffmpeg.conf
/etc/profile.d/kaltura*base.sh

Then, in order to make the Kaltura Server use these new FFmpeg binaries, you will need to modify:

/opt/kaltura/app/configurations/batch/batch.ini:params.ffmpeg.*
/opt/kaltura/app/configurations/local.ini:bin_path_ffmpeg

And reload Apache.
That way, you will not have to remove the kaltura-ffmpeg package since indeed, removing it will trigger the removal of many additional packages you must keep and any upgrades made will not override your custom FFmpeg since it is not included in any of the packages, again, installed onto an alt location.
In regards to rebuilding Nginx, the Nginx VOD module only requires libfdk_aac for Audio filtering (for changing playback rate / gain) so unless you need that particular feature, there is not reason to rebuild Nginx. The Nginx RTMP module does not bind directly with any of the FFmpeg libs but instead, triggers the ffmpeg binary from the config so, you can simply change the path to it.

Hope this clarifies things,

@jess

Building RPMs with the GitHub files was a bit tricky even for the freelancer I hired but he did make me a nice “How to document” and compile a repo with all the files I need to rebuild as needed when Kaltura CE changes versions of FFMPG so I can make RPMs with the properly configuration of new versions. I was able to run the conversion commands to CLI to restream my RTSP IP camera feeds. Once I finish updating the host and restore my content from my old instance of 12.19.0 and upgrade to v12.20.0 I will update the FFMPEG and test it again restreaming though Kaltura CE HTML5 players. Then update the thread.

I will note it was hard finding a freelancer that was not grossly charging to complete the task of building the custom RPM which is easy ONLY after your have all the required files and settings.

Hi @hiphopservers,

As I said before, we do have a guide for building the RPMs [https://github.com/kaltura/platform-install-packages/blob/Mercury-13.0.0/doc/building_kaltura_rpms_howto.md] and supply all needed files. I could also give you a source RPM for kaltura-ffmpeg if you want.

It is true that building deb and RPM packages in general and regardless of Kaltura requires a bit of knowledge, no denying that:)

At any rate, will be happy to review your steps once you provide them.

Thanks,

I have tested the Live Streams using NGINX RTMP module with FFMPEG encoding my LIVE RTSP IP Cameras. There are some issues with NGINX RTMP keeping the streams active but that is a work in progress because currently NGINX does not let you run the ffmpeg command in the configuration file to pull in the Live streams from an outside source. I have a few ideas on a work around but again that is a work in progress. Ultimately, I will need to have a custom script written that will start the streams then monitor them to make sure they are active and then restart them if they die. Then create a proper entry that can be published in KMC to work properly in all required formats for smooth playback.