Are you interested in streaming on Dacast under Linux with ffmpeg? This guide provides a step-by-step explanation to get you started!
To stream on Dacast under Mac with ffmpeg, click here.
Note: this guide covers the following Linux distributions:
- Ubuntu 14.04
- Arch Linux
Requirements:
You will need to compile ffmpeg yourself so that you can access RTMP support through the librtmp library.
Development tools:
Before getting started, make sure that you install the tools necessary to compile ffmpeg, librtmp, and their dependencies.
- Ubuntu 14.04
$ sudo apt-get update $ sudo apt-get install build-essential git libssl-dev
- Arch Linux
# pacman -Sy base-devel git
Installation:
1. librtmp
- First, retrieve the librtmp source code on the official git repository.
$ git clone git://git.ffmpeg.org/rtmpdump
- Next, browse to the local repository’s folder, and then run the compilation process.
$ cd rtmpdump $ cd librtmp $ make
- Finally, install the library in your system’s root directory.
# DESTDIR=/usr make install
2. ffmpeg
Dependencies
You may need to retrieve some additional libraries, such as the audio and video codecs required to broadcast your media content.
Ubuntu 14.04
Please note that you’ll need to manually compile libaacplus.
$ sudo apt-get install libfftw3-dev pkg-config autoconf automake libtool libtool-bin unzip $ wget http://tipok.org.ua/downloads/media/aacplus/libaacplus/libaacplus-2.0.2.tar.gz $ tar -xzf libaacplus-2.0.2.tar.gz $ cd libaacplus-2.0.2 $ ./autogen.sh --enable-shared --enable-static $ make $ sudo make install $ sudo ldconfig
# apt-get install yasm libfaac-dev libfdk-aac-dev libfreetype6-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjpeg-dev libopus-dev libschroedinger-dev libspeex-dev libtheora-dev libvo-aacenc-dev libvorbis-dev libvpx-dev libx264-dev libxvidcore-dev
Arch Linux
Some dependencies are located on the ArchLinux User Repository. Therefore, you must first retrieve their source code and then compile these dependencies manually.
You also have the option to automate this process by installing a useful tool called yaourt.
You can access an installation guide at this address: http://archlinux.fr/yaourt-en.
You can retrieve the required dependencies with the following commands:
# pacman -Sy yasm freetype2 lame opencore-amr openjpeg opus schroedinger speex libtheora libvorbis libvpx x264 xvidcore faac libfdk-aac $ yaourt libaacplus $ yaourt vo-aacenc
Compilation
- Retrieve the ffmpeg source code on their official git repository :
$ git clone https://github.com/FFmpeg/FFmpeg.git
- Browse to the local repository’s folder, then run the compilation process:
$ cd FFmpeg $ ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libaacplus --enable-libfaac --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-openssl --enable-libopus --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --prefix=/usr/local --enable-librtmp $ make
- Install ffmpeg in your system’s root directory:
# make install
Usage
Open your Web Browser, navigate to the Dacast website, and then access your live channel’s settings. Once there, please browse to the Encoder Setup section, as pictured below:
From here, make sure to select Other RTMP Encoder.
At this point, you should see the following information on your screen.
Once here, you’ll need the following data:
Login | 123456 |
Password | 789123 |
Stream URL | rtmp://p.ep246802.i.akamaientrypoint.net/EntryPoint |
Stream Name | dclive_1_1@246802 |
Next, please run the following command:
$ ffmpeg -re -f lavfi -i testsrc -c:v libx264 -b:v 1600k -preset ultrafast -b 900k -c:a libfdk_aac -b:a 128k -s 1920x1080 -x264opts keyint=50 -g 25 -pix_fmt yuv420p -f flv "rtmp://p.ep246802.i.akamaientrypoint.net/EntryPoint flashver=FMLE/3.020(compatible;20FMSc/1.0) live=true pubUser=123456 pubPasswd=789123 playpath=dclive_1_1@246802"
Important Notes (please read carefully)
Note 1: if your credentials are rejected
You must have followed all the steps above and the librtmp manual compilation or this is not gonna work: your credentials will be rejected by the server.
Note 2: common error
A recurring typo in fdk aac usage is that, during the installation process, you need to enter “–enable-fdk–aac” but when you use it in the command it is: “-c:a libfdk_aac”
Note 3: insert your source path
You want to replace
-f lavfi -i testsrc
with
-i /your_source_path
Otherwise, you will just have the test screen (as shown below), not your live stream. If you have not replaced “-f lavfi -i testsrc” with “-i /your source path”, you will see the following test screen:
Note 4: increase buffer for smoother playback
If your playback is not smooth enough, you can increase the size of your buffer by replacing:
-b 900k
with
-bufsize 3000k
Your command will look like this:
$ ffmpeg -re -i /your_source_path -c:v libx264 -b:v 1600k -preset ultrafast -bufsize 3000k -c:a libfdk_aac -b:a 128k -s 1920x1080 -x264opts keyint=50 -g 25 -pix_fmt yuv420p -f flv "rtmp://p.ep246802.i.akamaientrypoint.net/EntryPoint flashver=FMLE/3.020(compatible;20FMSc/1.0) live=true pubUser=123456 pubPasswd=789123 playpath=dclive_1_1@246802"
Note 5: better quality for powerful system
If you want a better quality and your system is powerful enough, you may replace
-preset ultrafast
with
-preset fast
Your command will look like this:
$ ffmpeg -re -i /your_source_path -c:v libx264 -b:v 1600k -preset fast -b 900k -c:a libfdk_aac -b:a 128k -s 1920x1080 -x264opts keyint=50 -g 25 -pix_fmt yuv420p -f flv "rtmp://p.ep246802.i.akamaientrypoint.net/EntryPoint flashver=FMLE/3.020(compatible;20FMSc/1.0) live=true pubUser=123456 pubPasswd=789123 playpath=dclive_1_1@246802"
Note 6: lowest latency for very powerful system
If your goal is to get the lowest latency and you have a very powerful system, you may add the following to the initial command:
-tune zerolatency
Your command will look like this:
$ ffmpeg -re -i /your_source_path -c:v libx264 -b:v 1600k -preset ultrafast -tune zerolatency -b 900k -c:a libfdk_aac -b:a 128k -s 1920x1080 -x264opts keyint=50 -g 25 -pix_fmt yuv420p -f flv "rtmp://p.ep246802.i.akamaientrypoint.net/EntryPoint flashver=FMLE/3.020(compatible;20FMSc/1.0) live=true pubUser=123456 pubPasswd=789123 playpath=dclive_1_1@246802"
Feel free to get in touch with Dacast directly if you need further support with this process.
Hi,
I tried to follow the process for Ubuntu, but while trying to build ffmpeg I got the following error message after ./configure…. command:
Unknown option “–enable-libaacplus”.
According to ffmpeg trac (https://trac.ffmpeg.org/wiki/How%20to%20quickly%20compile%20libaacplus) support (whatever it means here) for libaacplus has been removed from ffmpeg.
Any workarounds?
P.
Hi Piotr!
acc should be supported by default with the latest version of ffmpeg.
Don’t hesitate to get back here to tell me.
Needed to install libtool binaries at step “Please note that you’ll need to manually compile libaacplus”:
sudo apt-get install libtool-bin
Thank for letting us know, just updated it 😉
I also received the above unknown option “- -enable-libaacplus” when trying to build ffmpeg just like Piotr above. Any guidance? Has anything changed?
Hello Ken, let me get back at you with an email in order to give you all the directions needed!
Could not get back at you with an email, let me answer you here:
For what I have understood from them, they say you can remove the –enable-libaacplus option, that would probably solve the problem.
Can you give us more insights on what you are trying to achieve here?
Hi Etieenne – thank you so much for this. I’m having trouble with the config – the latest version of FFmpeg is not supporting the following config switches:
–enable-libaacplus
–enable-libfaac
–enable-libschroedinger
–enable-libvo-aacenc
I was able to build and install after removing those switches from the config, when I try to connect to my dacast channel with FFmpeg using testsrc as you described, and of course copying in my dacast settings my credentials are rejected.
Ok – I figured this out while writing. I did perform the build of librtmp as suggested, and installed it with:
#DESTDIR=/usr make install
When I went to check the install I discovered that the library had been installed in /usr/usr/local/lib, which of course is not on my path. I re-installed without the DESTDIR switch and now everything is working great!
I’m on OpenSUSE Tumbleweed, and it took a bit of work to hunt down all the dependencies. Adding the Packman repo made all the difference! (https://opensuse.pkgs.org/tumbleweed/packman-x86_64/)
Thank you much for the detailed instructions. Can’t wait to start streaming!
Hi Saill, I just forwarded your message to our support team (support@dacast.com). They should contact you ASAP. Also, I wanted to let you know that your account manager is Claire Moodley: clarissa.moodley@dacast.com You can contact her anytime if you have any questions during your trial. Have a great day. Best,