Sign inSign up

subc/viperfish

By subc

Updated almost 4 years ago

Image
0

326

subc/viperfish repository overview

Introduction (project Viperfish)

Combining the examples:

We were able to write a working browser based WebRTC based sender and receiver.

These examples on their own either worked a little of not at all.

Now we have the SubC WebRTC web streamer (codename Viperfish) and receiver that worked with the modified and existing WebRTC signaling server (that was based on Signal Master).

You can find this Git repo at https://github.com/SubCImaging/SubC-Viperfish

Still in beta stages, but coming along very well. Today, 2022-Sept-30 we did a full test showing that a SubC Rayfin (using a custom app) could access the new online server (as a streamer) and then view that stream from a modified version of SubC Stream and in the MediaLooks desktop viewer at the same time. :)

Installation

The system has several parts to it. The ones this document will focus on are:

  • NodeJS server
  • Usage of the NodeJS server (see Usage section)
  • Usage of the individual sender and receiver html pages if ported to another web server (see Usage section)

The system also has a Blazer page with allows for viewing of the stream and an Android app based on usage of a webview.

Currently we have the option to start a remote stream, but working on the option of stopping that stream once it has been started.

NodeJS server

Currently, we have a custom NodeJS server that can host the pages, sender.html and receiver.html. Depending on usage installation can vary.

You will need:

  • Port 443 available (if you need to change the port number, see the folder config and modify the default.json file section named port)
  • NodeJS installed on the operating system
  • (Linux) Access to sudo or root user (usage of port 443 is limited sometimes to admin's)
From from Windows or Linux Console

Ensure you have NodeJS installed below following the instructions below. See Installing NodeJS section for details.

Steps:

  1. Change directory to the beta folder
  2. Type "npm i" (*)

The node_modules folder is not includes in the Git repo. Using the command npm i or npm install downloads all the needed modules.

From Docker image

Prebuild docker images are available at https://hub.docker.com/repository/docker/subc/viperfish. You have the options of running the docker image using:

  • Docker-compose
  • startDocker.bat file
  • docker run -p 443:443 --name viperfish:dev-1.0 -d subc/viperfish
  • docker run -p 443:443 --name viperfish:main-1.0 -d subc/viperfish
  • docker run -p 443:443 --name viperfish:debug-1.0 -d subc/viperfish

Note: This readme file is uploaded to the docker hub as well.

Available Images
Image NameDescription
dev-1.0Development version of viperfish server. All debug is disabled in this version.
debug-1.0Debug version of viperfish server.
main-1.0Main version of viperfish server. All debug is disabled in this version.

Usage

Starting the NodeJS Server

Steps:

  1. Download a copy of the repo
  2. Change directory to the beta folder
  3. Type "npm start" or "node server_beta.js"

Using "npm start" takes a reference from the package.json file and run the "scripts" > "start" command.

Running on a Non-NodeJS solution

You can also use this system from something like Apache.

NOTE: Configuration and other related setup is not included in this documentation.

See the Folder structure section for a breakdown of how all the folders are files are available, but the sender.html and receiver.html files are what makes everything work in a non-NodeJS setup.

The browser will need to use & between options instead of the /. Using split you can get any submitted data.

However, to enable this option you need to do a minor edit. See instructions below.

  1. Open the file sender.html and change: i. var room = undefined; to var room = location.search && location.search.split('&')[1]; ii. var vidEncoder = undefined; to var vidEncoder = location.search && location.search.split('&')[2]; iii. var vidBitrate = undefined; to var vidBitrate = location.search && location.search.split('&')[3]; iv. var signalingServer = undefined; to var signalingServer = location.search && location.search.split('&')[4];
  2. Open the file receiver.html and change: i. var room = undefined; to var room = location.search && location.search.split('&')[1]; ii. var signalingServer = undefined; to var signalingServer = location.search && location.search.split('&')[2];

IMPORTANT NOTES:

  • You can hardcode the signaling server into the .html files as well.
  • You can move the signaling server var to the /js/common.js file.
  • You can move the collection of data from the address var to the /js/common.js file. (It is setup inside of the .html files for NodeJS to do a replacement operation on the read in html string data.)
  • When you call the sender.html and receiver.html files from the browser, use the format:
    • https://{domain}:{port}/{path}/{receiver.html}?{receiver}&{stream_name}
    • https://{domain}:{port}/{path}/{sender.html}?{sender}&{stream_name}&{video_encoder}&{video_bitrate}

Streaming A Video

The web server will start listening on the provided port. From the console, it will show possible addresses you can use to access the server.

The format you need to follow is:

https://{domain}:{port}/sender/{stream_name}/{video_encoder}/{video_bitrate}

Steps

  1. Determine the domain you have the server installed on
  2. Open the browser to that domain with needed options of /sender and /{stream_name}. For example, https://www.someserver.com/sender/sample_stream.
  3. When prompted to allow access to your camera and microphone, click Allow
  4. Now your streaming that camera out

Allowed Video Encoders

NameDescriptionLinks
vp8VP8 is an open and royalty-free video compression format released by On2 Technologies in 2008.https://en.wikipedia.org/wiki/VP8
vp9VP9 is the successor to VP8 and competes mainly with MPEG's High Efficiency Video Coding (HEVC/H.265).https://en.wikipedia.org/wiki/VP9
h264Advanced Video Coding (AVC), also referred to as H.264 or MPEG-4 Part 10, is a video compression standard based on block-oriented, motion-compensated coding. It is by far the most commonly used format for the recording, compression, and distribution of video content, used by 91% of video industry developers as of September 2019. It supports resolutions up to and including 8K UHD.https://en.wikipedia.org/wiki/Advanced_Video_Coding
gpu_h264H.264 encoder that is done on the graphic's card.https://developer.nvidia.com/blog/turing-h264-video-encoding-speed-and-quality/
cpu_h264H.264 encoder that is done on the CPU.https://en.wikipedia.org/wiki/Advanced_Video_Coding

Allowed Video BitRates

Bit rate (bitrate or as a variable R) is the number of bits that are conveyed or processed per unit of time.

When submitting your entry, please provide it in bits per second.

When quantifying large or small bit rates, SI prefixes (also known as metric prefixes or decimal prefixes) are used, thus:

  • 0.001 bit/s = 1 mbit/s (one millibit per second, i.e., one bit per thousand seconds)
  • 1,000 bit/s = 1 kbit/s (one kilobit per second, i.e., one thousand bits per second)
  • 1,000,000 bit/s = 1 Mbit/s (one megabit per second, i.e., one million bits per second)
  • 1,000,000,000 bit/s = 1 Gbit/s (one gigabit per second, i.e., one billion bits per second)

Binary prefixes are sometimes used for bit rates. The International Standard (IEC 80000-13) specifies different abbreviations for binary and decimal (SI) prefixes (e.g. 1 KiB/s = 1024 B/s = 8192 bit/s, and 1 MiB/s = 1024 KiB/s).

Value(bit/s)Value(Kb/s to Mb/s)
6400064K
128000128K
256000256K
512000512K
768000768K
10240001024K
20480002048K
40960004096K
51200005120K

Stream Name

The stream name but be only numbers or letters. All other characters will be removed by the server upon sending the data to the sender.html or receiver.html pages.

Opening A Video from the Browser

To view a stream, you will need to know the domain name and the name of the stream.

The format you need to follow is:

https://{domain}:{port}/receiver/{stream_name}

You may be access for access to your camera and microphone, please allow.

Stream Name

The stream name but be only numbers or letters. All other characters will be removed by the server upon sending the data to the sender.html or receiver.html pages.

Troubleshooting

Streaming appears ok, but unable to view the stream.

Just because you can get access to your camera and have what appears to be a valid stream outgoing, does not mean it is working.

Checking if able to view it from a browser is helpful, but using the formatted url, https://{domain}:{port}/receiver/{stream_name}. But some it's not working try checking the below.

  1. Open up Dev tools by pressing F12, click on the sources tab and choose (index) from the list. Inside the source code, there are globals defined, make sure none of them are showing = undefined. If you see this issue, there is something mis-configured in the /config/defaults.json file or the server needs to be restarted from the console.

Keep in mind, for a viewer, you only need to see two global(s), the room and the signaling server.

// Set room (will be assign by server)
var room = "bob";
// Set the signaling server.
var signalingServer = "https://testserver.subcservices.com/";

However, for the sender application, you need to have the below present for it to work.

// Set room (will be assign by server)
var room = "bob";
// Set video encoder.
var vidEncoder = "h264";
// Set video bitrate.
var vidBitrate = "64000";
// Set the signaling server.
var signalingServer = "https://testserver.subcservices.com/";

Technical Breakdown

Below is a full technical breakdown of the sender and receiver files and how they work. These include code samples and research links for further reading.

Folder Structure

graph TD;
    ROOT-->./js;
    ./js-->receiver.js;
    ./js-->common.js;
    ./js-->sender.js;
    ./js-->simplewebrtc-with-adapter.bundle.js;
    ROOT-->./css;
    ./css-->common.css;
    ROOT-->./ssl;
    ./ssl-->cert.pem;
    ./ssl-->key.pem;
    ROOT-->./sender.html;
    ROOT-->./receiver.html;
    ROOT-->./204.html;
    ROOT-->./404.html;
    ROOT-->./server_beta.js;
    ROOT-->./startServer.bat;
    ROOT-->./startServer.sh;
FilenameDescriptionLocation
204.htmlError page for the NodeJS server, for when a error 204-No content issue happens.root
404.htmlError page for the NodeJS server, for when a error 404-Page cannot be displayed issue happens.root
common.cssCSS file for whole system, used by the files sender.html and receiver.html../css/
sender.htmlWebRTC based sender application. Uses the SimplyWebRTC library located in ./js/.root
sender.jsJavascript file for the sender.html file../js/
received.htmlWebRTC based receiver application. Uses the SimplyWebRTC library located in ./js/.root
received.jsJavascript file for the receiver.html file../js/
server_beta.jsNodeJS serverroot

Tag summary

Content type

Image

Digest

sha256:45608ea92

Size

377.4 MB

Last updated

almost 4 years ago

docker pull subc/viperfish:dev-720p