Wednesday, October 16, 2019

nbgitpuller bookmarklet

Using nbgitpuller with JupyterHub to distribute notebooks from GitHub, I got tired of manually formatting the URLs or using a link generator. So here's a basic bookmarklet that automatically generates nbgitpuller links for our CallystoHub:

javascript:(function(){var url=location.href;var res=url.split("/");var site=res[2];var user=res[3];var repo=res[4];var treeBlob=res[5];var branch=res[6];var nbgitputllerUrl="https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=";if(site=="github.com"){if(treeBlob){var urlpath="notebooks/"+repo+url.substring(url.indexOf(branch)+branch.length);nbgitputllerUrl+="https://github.com/"+user+"/"+repo+"&branch="+branch+"&urlpath="+urlpath;}else{nbgitputllerUrl+=url;}}window.prompt("Callysto nbgitpuller link",nbgitputllerUrl);})();

If you're not familiar with bookmarklets, they're basically bits of Javascript in the URL portion of a browser bookmark. To set one up, drag this link to your bookmark bar/menu:

CallystoGitPuller

Then when you are on a GitHub page you can click that bookmark and it will pop up a prompt with an nbgitpuller link to open that GitHub notebook or repository in CallystoHub.

Here is the code as a GitHub gist if you'd like to make your own and perhaps use JavaScript Cruncher to condense it to a single URL-encoded link.

Edit:

I've also posted about a similar bookmarklet to open notebooks in Colab.

Sunday, October 13, 2019

SRT vs NDI

I've previously posted about both NDI and SRT, they are great video transmission protocols. Both are unicast by default, but can support multiple clients or players. There are some differences that might make you choose one over the other, here are a few that I can think of:

SRT is open source, NDI is royalty-free
SRT is low latency, NDI is very low latency
SRT can work over WiFi or across public internet, NDI works best over gigabit LAN
SRT support is coming to OBS, NDI is available in OBS via a plugin
SRT seems to be supported by more digital signage players
NDI seems to be supported by more cameras

For myself, I'll continue to implement both for different use cases.

Please comment below about missing information or errors.

Thursday, October 3, 2019

Low Latency Streaming from OBS to BrightSign Using SRT

There are a few free video streaming services that support low-latency streaming over the internet, notably Mixer and YouTube ultra-low latency. However if you prefer local streaming (perhaps to conserve bandwidth) or prefer open source, let's take a look at how you can stream from OBS Studio to BrightSign players (not open source) or other devices that support SRT streaming protocol such as VLC.

Hopefully at some point soon OBS will support SRT, but for now we'll need to run a separate application. Assuming that you are already using OBS for streaming to an external destination, we'll use the "recording" feature to send to Haivision's srt-live-transmit application.

There's some work required to compile srt-live-transmit, and I'll admit I haven't gotten it to work on Windows yet, but it's easy on Linux (including Windows Subsystem for Linux) and Mac.

SRT for Mac

Getting SRT on Mac just involves launching the "Terminal" program and running two commands:

brew update
brew install srt

This will install srt-live-transmit at:

/usr/local/Cellar/srt/1.4.0/bin/srt-live-transmit

SRT for Linux or WSL

If you have Ubuntu installed under Windows 10 through Windows Subsystem for Linux, you can run the following commands in the terminal:

sudo apt update
sudo apt upgrade
sudo apt install tclsh pkg-config cmake libssl-dev build-essential git
git clone https://github.com/Haivision/srt.git
cd srt
./configure
make

After the compilation process, you should have:

~/srt/srt-live-transmit

Sending from OBS to srt-live-transmit

From the terminal (on Mac, Linux, or WSL), run the following command:

./srt-live-transmit udp://:1234 srt://:5678 -v

On your Mac you may first need to change to the right directory:
cd /usr/local/Cellar/srt/1.4.0/bin/

That command listens for a UDP stream (that we'll send from OBS) and listens for a request to unicast it as an SRT stream. The -v means verbose mode, which allows us to read what it is doing.

In OBS we need to go into Settings, click on Output, switch the Output Mode to Advanced and click on the Recording tab. Switch the Type to Custom Output (FFmpeg) and the FFmepeg Output Type to Output to URL.

The File path or URL should be set to udp://127.0.0.1:1234?pkt_size=1316 (127.0.0.1 means sending to the same computer that OBS is running on) and the Container Format should be changed to mpegts. I haven't done any testing, but I'm assuming that decreasing the Keyframe interval should decrease latency, and decreasing the Audio Bitrate is probably fine to decrease bandwidth usage.



Click OK, then the Start Recording button. Have a look at the terminal window where srt-live-transmit is running. You should see information about the stream.

Add the SRT source to BrightSign or play it as a network source in VLC (if your sending computer is at 10.0.0.200 then srt://10.0.0.200:5678). You should see your stream that is being transmitted from OBS and relayed by srt-live-transmit.

Hopefully this works for you, feel free to comment if you encounter issues.

Using Git from the Command Line

This post is more for my future self, but others may find it useful. Feel free to comment if I've made any errors or missed anything important.

Assuming that Git is already installed, to start using it with terminal commands we need to set up a couple of things:

git config --global user.email "INSERT_EMAIL_ADDRESS_HERE"
git config --global user.name "MisterHay"
git config --global core.editor nano

It's also a good idea to set up SSH keys.

and then clone the appropriate repository:

git clone https://github.com/callysto/curriculum-notebooks.git

or with ssh:

git clone git@github.com:callysto/curriculum-notebooks.git

and some useful commands:

list branches:
git branch -a

get files from GitHub:
git checkout origin/staging

create branch from staging:
git checkout origin/staging -b NameOfNewBranch

change to branch (if not already there):
git checkout --track origin/NameOfBranch

edit files, then (stage changes):
git add changed_file.ipynb
or
git add ./*

check with:
git status

discard all local changes to all files permanently:
git reset --hard

commit to local:
git commit

push to remote:
git push -u origin NameOfBranch

then create a pull request to staging from that_branch using GitHub.com interface

To see what has been happening, check the top of
git log

Hopefully that's enough to get you (future me back) up to speed.