We will need a encoder software to encode our IP camera feed into stream-able data. I will be using OBS Studio which is free to use. It can be installed on Linux, Macintosh and Windows. If you are planing to have your own streaming server instead of using services such as youtube, twitch. I strongly recommend you to use either mac or linux version of OBS. I had really bad experience with OBS Windows while testing HLS on my streaming server.
Go ahead and download the installation file from.
The software is really easy to use. To add your IP Camera, Right click in Scene section and Add > Media Source
The RTSP Url depends on the camera brand and model you have. You can see your camera rtsp url format from http://www.soleratec.com/support/rtsp/rtsp_listing
I use Sony cameras and the RTSP URL format for my camera is: rtsp://username:[email protected]/media/video1
Uncheck Local File checkbox and enter the RTSP address in the input field and hit OK.
And here it is. This is the preview of my camera.
Now we can enter Encoder Settings.
GENERAL TAB: is self explanatory.
You can select streaming services like youtube or you can enter your own streaming server’s address. I will use NginX server with RTMP module, so I will enter my own server’s address here.
Stream Key: You can type any key you want here (for example “test”)
Encoder=x264, Rate Control=CBR, Bitrate=1024 (These values totaly depend on the quality of your stream and available bandwith. You need to optimize these settings accordingly)
IMPORTANT: RATE CONTROL SHOULD BE CBR IF YOU ARE STREAMING RTMP AND IT IS RECOMMENDED TO USE VBR IF YOU ARE STREAMING HLS. I TESTED VBR AND CBR WHILE TESTING HLS AND DIDNT SEE ANY PROBLEM WITH EITHER ONE.
Stream Rate Control Methods:
CBR, VBR or ABR has no influence on your stream quality . What determines the quality of your video is always the bitrate. Higher the bit rate will result in better video quality. The mode simply decides how the bits are distributed. Both VBR and ABR are not great for livestreaming due to the bandwidth fluctuations it causes. CBR uses more overall bandwidth, but the transmission is generally a bit more “stable”. It prevents data from going wildly up and down. CBR is recommended for Rtmp streaming but if you are streaming HLS, then recommended rate control is VBR. I tested my hls streaming with VBR and CBR, I didnt see a difference Both worked fine, but recommeded way of hls streaming is VBR rate control.
Higher result in better quality but consume more bandwith. Also your viewer may suffer downloading your stream.
Key Frame Interval:
This setting defines how often keyframe should be sent to the streaming server. Most streaming services recommend to use 2 sec.
CPU Usage Preset:
Faster uses less CPU and lower quality. Lower the value more load on CPU but quality increases greatly.
The resolution and FPS values should be decided bandwith and desired video quality.
Downscale Filter (Bilinear/Bicubic Sharper/Lanczos):
Lanczos seems to be causing weird pixelation/artifacting which in turn makes it look like the video is worse quality.Bicubic does look better.
OBS AUTO START STREAMING USING BATCH FILE
If you need to start and stop OBS automatically, you can use the batch commands below and use windows task scheduler to run them at specific times of the day.
To start OBS and start streaming automatically on Windows
start /d “C:\OBS\obs-studio\bin\32bit” obs32.exe –startstreaming
To stop OBS
taskkill /F /IM obs32.exe
OBS AUTO START STREAMING USING CRONNIX ON MAC OSX
If you are using Mac OSX for your encoder, You can use Cronnix application (free) to schedule start and stop task.
command to start obs streaming: open –a obs –args –startstreaming
command to stop obs: killall obs
OBS AUTO START STREAMING ON UBUNTU USING CRONTAB
On terminal start crontab, the first command below tell crontab to start streaming at 08:30 everyday and second code tells kill obs process at 18:30
30 08 * * * export DISPLAY=:0 && obs –startstreaming
00 18 * * * killall obs
We are finished with Encoder Settings. Now it is time to install and configure our streaming server, Nginx with RTMP Module.