Web server & Webcasting

The mobile apps (iOS / Android) and the web interface (UI3) provides remote access to cameras for users.
Post Reply
Posts: 90
Joined: Thu Jul 11, 2019 9:52 pm

Web server & Webcasting

Post by varghesesa »

Besides being a Video Management System, Blue Iris is also a Streaming Server. This allows users to share their camera feeds externally. The best way to understand how to leverage BI's streaming services is via the following use cases.

BI webcasting.png
BI webcasting.png (63.81 KiB) Viewed 18817 times

Webcasting (video streaming) Pipeline

Standard streaming pipeline: IP Cameras -> Media Server -> Endpoint
  • IP Cameras
    The process starts with a video capture device otherwise known as a IP camera. The camera is dedicated hardware that usually captures 15-30 frames per second.
    IP Cameras are high performance computers which is why they are so expensive. Compression algorithms are responsible for shrinking each frame to manageable chunks which can be transported over the internet. H.264 and H.265 are standard compression algorithms supported by Blue Iris.
    Packaging involves bundling all the compressed frames into manageable sizes that can be transported over the network. Think of packaging as grouping 1-3s of video frames into one chunk of data that is transported across the network. HLS, MPEG DASH, RTMP and RTSP are all common protocols for video streaming.
  • Network: Responsible for moving the data from cameras to Blue Iris.
  • Blue Iris. Media server + Video Management System
    Blue Iris is also a media server. Media servers can take streams in one format, for example RTSP from a camera and convert them to another format, for example, RTMP so that users can, for example, share their camera streams elsewhere such as YouTube. Media servers are responsible for taking video/audio inputs and streaming the content to various endpoints.
  • Network
  • And the final destination is the endpoint playing the video, for example a browser on a laptop, a mobile device, a TV, a gaming device etc.
In terms of the video pipeline as defined in the BI Streaming Overview article:
Source -> Decode -> Encode -> Endpoint
  • IP Cameras = Source
  • Media server = Decode + Encode
  • Endpoint = Endpoint

Web server

Global settings -> Web server tab

Every time a user accesses BI via a remote endpoint (mobile app, web browser), a connection is made between the BI web server and the endpoint.
BI web server.png
BI web server.png (28.27 KiB) Viewed 16814 times

Web server streams

Global settings -> Web server tab -> Advanced

BI allows for three types of streams from the web server.

webserver streams.PNG
webserver streams.PNG (75.95 KiB) Viewed 16814 times

Streaming 0 profile: Leveraged by the UI3 endpoint. I would leave these settings as default.
Streaming 1 profile: LAN. Create a profile that works well in your LAN. Since these endpoints only sit on the LAN, you may want to provide a richer user experience via higher resolution streams.
Streaming 2 profile: WAN. Network bandwidth may be challenging on the WAN so you may want to make stream adjustments, e.g. trade-off resolution (small screen any way) for smooth video.
See mobile apps section below for some streaming recommendations.

Web server encoding settings

Global settings -> Web server tab -> Advanced -> Configure button

webserver encoding.PNG
webserver encoding.PNG (135.87 KiB) Viewed 16814 times

H.264 Encoding Settings
  • H.264 video encoding
  • Hardware acceleration: Usually set to No. Many GPUs do a poor job of HA encoding which leads to streams that cannot be played by media players. Best to leave off.
  • Quality: Value from 0 - 100. Lower the value, lower the quality. The marginal difference in quality after a certain point is minimal. For example, 100 does not produce an image that is twice the quality of a 50 setting. In most cases, quality = 50 is plenty good.
  • Rate control: If selected, you are choosing a Constant Bit Rate (CBR). Choose if you have bandwidth concerns.
    If unchecked, you are using a Variable Bit Rate (VBR).
  • Frame type layout
    Maximum keyframe interval (GOP): 300
    Maximum B-frames between P-frames: 0 (only applies to Main profiles or above)
  • Profiles: H.264 provides features that are encapsulated in profiles.
    Baseline restricts the encoder to certain basic features only. Baseline can easily be played back on most devices. Main and High add features on top of Baseline. Baseline profiles were widely used for mobile devices. However, now more and more mobile devices support Main or High profiles.
    Main: B frames (above) are only allowed in the Main profile or above. They can be used to save on bandwidth but harder to decode. Widely used for web streaming.
    High profile is often used in broadcasting. Used on high definition TVs. Also adopted by the Blu-ray disc storage format.
  • Presets: Presets are a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression. This means that, for example, if you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset.
Audio encoding
  • Audio: AAC or MP3
  • Bitrate (kbps): 192

Streaming formats

BI support M-JPEG, H.264 and other formats. The Http interface -> Direct image and video requests section in the Help file has details.

Use cases

UI3 web endpoint

This is one of the most common ways to access cameras remotely from a web browser (laptop) or mobile browser (phone).
Hit the Help button from Global settings -> Web server tab for details.

The Blue Iris Web Interface webinar walks through the user interface and all its features/functionality.
See Web Interface (UI3) gotchas article for learnings from past tickets.

Large screen TVs

ui3 tv.png
ui3 tv.png (184.36 KiB) Viewed 16622 times

Many users are using TVs to display their cameras. Since these devices are usually on the LAN, they want to take advantage of their high resolution screens with high resolution video streams, since they know their network can handle the load.

With UI3, it is easy to experiment with higher and higher resolutions to determine what works best with your monitor. Simply choose different resolutions by using the gear icon in the lower right corner.

web server_tv gear icon.png
web server_tv gear icon.png (33.49 KiB) Viewed 16622 times

One final comment. If you have a monitor or TV that does NOT have internet connectivity a popular solution is to purchase an Amazon Firestick and run UI3 from there to the monitor. Firestick + Silk browser + UI3 interface is the goto solution for many resellers when trying to display the cameras on a TV or monitor.

Mobile apps (iOS / Android)
The streams used by the mobile apps are set in Camera settings -> Web server tab -> Advanced page. See Web server streams section above for details. The default resolution for Streaming 0 is 720p.

web server_default stream.png
web server_default stream.png (1.9 KiB) Viewed 16247 times

If the request from the app (720p default) is <= the sub stream resolution, the sub stream is streamed. Below are LAN/WAN suggestions that generally deliver smooth video based on higher/lower network bandwidth.

LAN / WAN streaming profiles

What's great about BI is it allows the ability to assign different streaming profiles for the LAN / WAN. A common convention is to assign Profile 1 for LAN connections and Profile 2 for WAN connections.

Video Pipeline: Camera video / feed -> Decode -> Encode -> Endpoint (high resolution tablet / low resolution phone)

A tablet with a bigger screen and always connected to the LAN may have value in a higher resolution stream. Being on the LAN, the network considerations are usually not as stringent either.

However, a WAN profile may entail a lower resolution stream. Most WAN profiles are used by mobile phones with small screens. Why unnecessarily send a stream with a high resolution that provides no additional value on a phone screen and also adds unnecessary load to the network and perhaps results in choppy video.

LAN settings

As stated above, according to our convention, LAN settings would be assigned to Streaming Profile 1

To get high resolution, smooth video, try the following settings for one of your web server video streams.
  • Use variable bit rate instead of constant bit rate. Unselect Rate control. Crank up Quality value. Gotcha: If network bandwidth too high, adjust.
  • Profile = high Uses more bells and whistles such as b-frames to optimize bandwidth while delivering quality. Gotcha: If endpoint cannot decode, adjust.
  • Preset = veryfast. Set to lowest to maximize quality. Gotcha: If CPU utilization is high adjust.
  • Uncheck Resize output frame. Send the full camera resolution to the device. Gotcha: If network bandwidth spikes, adjust. If the player at the endpoint starts to choke, adjust
  • b-frames are great for increasing quality and optimizing bandwidth. Gotcha: However, if you have a PTZ camera, b-frames can cause delays displaying the new view after a camera position changes.
web server_LAN settings.png
web server_LAN settings.png (87.76 KiB) Viewed 16276 times

Don't forget to choose the appropriate stream for the mobile app. Below is a reminder on how to do so.
Home tab -> Gear icon -> LAN. Profile 1 is the LAN stream.

ios settings 320.png
ios settings 320.png (45.01 KiB) Viewed 16811 times

WAN settings

The below settings generally provide a good user experience on mobile phones connected to the WAN (cellular network).

encoder options.png
encoder options.png (49.83 KiB) Viewed 16810 times

Differences between WAN vs LAN:
  • Switch from variable bit rate to constant bit rate to reduce network load.
  • Changed profile to superfast. Trade quality for lower CPU load and processing time.
  • Resize frame. Reduce resolution since stream is going to a small screen any way.

Multiple servers
Because BI is also a media server (RTSP server), you have the flexibility to pull video from one BI server to another.

Use case: Enterprises with large deployments may have multiple servers because they have >64 cameras. However, they may want to pull video from one server to another. Why? Because suppose five cameras belong to a user group and 3 cameras reside on Server A and the other two reside on Server B. In order to display all 5 cameras to the users belonging to this group, admins will pull the two cameras from Server B to Server A. The admin can then create a camera group for the corresponding user group, thus providing one pane of glass for all the cameras belonging to the group.

In order to pull a camera from one server to another, first confirm Webcasting is enabled for the camera.

web server_webcast.png
web server_webcast.png (33.92 KiB) Viewed 16805 times

Attain the following information for the remote server:
  • IP / Port of the web server
  • Username / password for a user that has access to the camera.
  • Pull camera or group stream
    rtsp://ip:port/cam1 (camera)
    rtsp://ip:port/groupname (group)
In example below, I have a camera called ADF7.
I was testing locally so IP address was My web server is running on port 7000.

web server_rtsp feed.png
web server_rtsp feed.png (54.75 KiB) Viewed 16805 times

Embed video in your website
Many users like to share a camera on their website. Below are two code snippets showing how to do so.
Change url to meet your environment
  • server is a placeholder for the ip address or hostname of your BI server
  • The web server listens on port 81 by default. Use the port you specified if different from 81.
  • ADF_Cameras is a placeholder for the camera name or camera group name in your server.
<iframe> tag

Code: Select all

<iframe src="http://server:81/livestream.htm?cam=ADF_Cameras&audio=0" allowfullscreen="true" width="640" height="360" />
<img src> tag

Code: Select all

<img src="http://server:81/mjpg/ADF_Cameras/video.mjpg?q=50&w=640" style="width: 640px; height: 360px" />
livestream.htm is a web page that loads a video player and feeds it an HLS stream from Blue Iris. This is the best thing to embed in an iframe if you want minimal user interface functionality. This method adds several seconds of video delay though, making it not ideal for all use cases.

The page source of livestream.htm includes the usage details. It takes different URL parameters than UI3.

livestream.htm supported URL parameters:
  • cam=short: Select camera or group with [short] name
  • autoplay=0: Disables autoplay.
  • audio=1: Unmute at startup. Also disables autoplay.
  • mode=2: Hide video player controls
  • mode=3: Use browser's standard video player controls
Two other considerations when embedding streams:

1. Authentication must be dealt with, either by enabling anonymous access or by turning off secure login and embedding credentials in the URL.

2. If the web site is hosted with HTTPS, the link to embed a video stream must also use HTTPS which will mean setting up stunnel or a similar secure proxy in front of Blue Iris.

Embed video in your website via RTSP.Live site
If the above is too complicated, you can also try the RTSP.Live free service.

YouTube - Streaming

Use case: Pushing Blue Iris live camera stream(s) to YouTube's media server via RTMP.

YouTube architecture.png
YouTube architecture.png (133.13 KiB) Viewed 19894 times

YouTube provides URLs to connect to 3rd party software such as Blue Iris.
youtube setup.png
youtube setup.png (69.32 KiB) Viewed 19894 times

BI setup is just as simple. Camera settings -> Webcast tab.
youtube BI settings.PNG
youtube BI settings.PNG (168.53 KiB) Viewed 19894 times

You do need to supply the correct stream settings that will work with YouTube.
  • Audio: Set to AAC. 128 kbps
  • Max bitrate (kbps): 2048. YouTube prefers 9500 kbps so go higher if network can support bandwidth.
  • Maximum keyframe interval (GOP): 60
  • Profile: main
  • Preset: superfast
  • Zero frame latency: Unchecked
  • Resize output frame width x height: Checked. 1280 x 720. YouTube prefers 2560 x 1440 (double 1280 x 720) so go higher if network can support bandwidth and camera has the resolution. No point increasing the resolution if your camera is 1 MP (1280 x 720).
YouTube will provide Stream status feedback based off which, you can adjust BI settings further.
youtube stream feedback.png
youtube stream feedback.png (57.67 KiB) Viewed 19550 times

Amazon Echo Show + Monocle Coming soon!

Pro tip 1: Leverage UI3 to help set optimal encoding settings on your mobile device

Global settings -> Web server tab -> Advanced tab
Encoder profiles: <streaming profile> Configure button.

The encoder dialog box is a bit daunting. What are good values for all those settings?
If like most, you are not well versed on encoder settings, use the UI3 interface for help!

The issue here is if you bring up a browser on your phone and go to the BI web interface, playback and live view work fine. When doing the same through the app, the streaming is choppy, jittery etc.
  • Test 1: Need to make sure live stream and playback are first smooth on the BI Server. Garbage in = Garbage out.
  • Test 2: If you open a browser on the phone/tablet and go to the BI web interface (UI3), are the live view and playback a good experience. If so, then you know the problem is not with the network.
If you are still reading, then the problem probably means the player used by your device cannot handle the incoming stream well. The short answer is to go to Global settings -> Web server -> Advanced -> Encoder profiles (Choose Streaming 1 (LAN) or 2 (WAN)) -> Configure dialog. Use the below settings to start and see if they work.

encoder options orig.png
encoder options orig.png (85.93 KiB) Viewed 16628 times

Below are the changes from the default settings:
  • First, I turned on Constant Bit Rate (CBR). This settings caps the amount of data going to the player at 1024 kbps.
  • Next, I reduced the resolution to 856 x 480. You are streaming to a mobile device, so reducing the resolution will probably have no affect on your viewing experience. I played with "Retain aspect ratio within frame". On iOS devices, the setting seemed fine. But I noticed instability and crashes on some Android devices. It does not really change/help the user experience, so my conclusion was to just leave it off unless required for another reason.
  • Finally, I set Hardware encode = No. The hardware encoding often will not play on mobile players. Best to encode using BI software.
Reference: If you want a deeper understanding of the settings in the encoder dialog or how encoding generally works, a great reference article was created by IPVM titled "H.264 vs MJPEG - Quality and Bandwidth Tested". If you are not familiar with IPVM, they are a great resource for research and information regarding surveillance and security cameras.

So how did I choose the values for the bit rate and resolution?

I cheated and used the expertise of the BI development team! If you click on the gear icon in UI3 (lower right), you can select any predefined resolution and hit the pencil button up top. You then see the encoding settings for the selected resolution. I just copied those values into the encoder dialog on the console.

ui3-streaming-settings-trick_smaller.png (100.61 KiB) Viewed 16628 times

Once I made the stream adjustments, I went to the mobile app settings and chose the appropriate settings for my LAN and WAN connections.

video streaming gotcha smaller.png
video streaming gotcha smaller.png (22.98 KiB) Viewed 16628 times
Post Reply