Streaming to batc.tv with Raspberry Pi
NOTE: This page has been amended to describe streaming to the new BATC Streaming Server at batc.org.uk/live.
The Portsdown can stream directly to batc.org.uk/live from the composite video input on the EasyCap dongle, enabling it to be used as a low power consumption streaming appliance at repeater sites. It will only stream reliably in SD Definition, and the only video sources that are guaranteed to work are the EasyCap, the static test card and the Pi Camera; although some webcams may work. The streaming parameters are pre-set to H264 encoding at 576Kbit/s (without audio) or 512Kbit/s (with 2 channels of audio). You can select 576p 16:9 modes but 720p tends to max out the RPi.
There are 3 repeater streaming modes: one for manually switched streaming (by selecting TX), one for always-on streaming, and one for hardware-switched streaming. Full details are below, but the first step is to set up the stream so that it works for manually switched streaming in the normal manner.
Setting up Your Stream
The streamer software was updated in release 201809150. Please make sure that you have upgraded to the latest version before doing anything else.
You do not need a Touchscreen to operate in streaming mode. If you are not using the touchscreen, you can set up your stream name and key in the console menu. See below for instructions.
Setting Up Using the Touchscreen
If you are using a touchscreen, you can use the "Set Stream Outputs" Menu (accessed from Menu 3) to set up your BATC stream (and 7 preset alternate streams). Simply touch "Amend Preset" (which will turn red) and then the button that you want to set your stream on (top left for the first stream?). Then press "Clear" to delete the previous information, select lower case, and enter your stream name (for example: g8gkq). Press enter to enter the stream key. Again press clear and then enter your 6-character stream key. Make sure that you get the upper case and lower case right. Press enter again. If you then Exit to the main menu, you can select "Output to" and Streamer, and then select your video source. Press TX and it should stream to the BATC streamer.
Using Menu 35 you can set up multiple streams, and then simply go back to the menu to select them once they are set up.
Setting Up Without a Touchscreen
To set up from the console, using Putty or Kitty, log in to the console and then select a valid video source for the stream. On the console menu, select Source:
Then select SD MPEG-2
Then use the arrow keys to highlight CAMMPEG-2, ANALOGMPEG-2 (for the EasyCap) or CARDMPEG-2. Then press the space bar to select the chosen input and press enter. If you have selected the EasyCap, suse Auto for device selection. Note that even though the name includes MPEG-2, all these sources will be streamed as H264. The BATC server will stream the H264 in a Flash container, or as an HTML5 (HLS) stream.
Next, to enter your stream name and key, select Output from the main menu:
Then select Output Mode
Then use the arrow keys to highlight STREAMER, press the space bar to select and then press enter.
The next screen should show the new BATC Streamer address. If as shown, press enter. If not amend to this address and press enter.
Now enter stream key. This is your username (callsign) in lower case, followed by a hyphen and then the 6 character "Stream RTMP Input URL" as listed on your BATC "Account Dashboard". The correct format is shown here:
Now you can test your stream simply by selecting transmit. Do this test before trying to set up continuous or keyed streaming.
Repeater Streaming Functions
Important - Change Your Password First!
If you are going to use your Portsdown to stream a Repeater, it will be constantly connected to the Internet. You should not run a Portsdown-configured Raspberry Pi constantly connected to the internet without changing the default password. Before setting up the repeater streaming you should change the password. From the console, select Shutdown and Reboot options. Then select Option 3, "Exit to Linux". At the command prompt type passwd and press enter. It will ask you for the current password (raspberry), but will not echo anything to the screen as you type it in. It should then ask you for the new password (twice). Again it will not show anything on the screen. When complete, type
and press enter to return to the console menu. Don't forget to write the password down (yes!) and put it out of view, but attached to your streaming hardware (on the underside of the box?). If a hacker has physical access to your streaming hardware, you have bigger problems than the hacker simply knowing the password.
You can now set your Portsdown to stream a repeater in one of 2 modes:
Continuous Streaming Mode
The first thing to do is to set up your Portsdown to boot-up into Constant Streaming Mode. From the console, go to the System Setup Menu, and select option 1, Autostart. Then use the arrow keys to highlight "Cont_Stream_boot" and then (very important) press the space bar to select it. Then press enter.
You can now test the streaming from the console by selecting "Shutdown and Reboot Options". Then select Option 2, "Reboot Now". If that works, and you are happy with the stream, you can disconnect your PC and leave the streamer to run.
The streamer will stop (for 5 seconds) and restart once every 12 hours to prevent the build-up of excessive latency. If the Raspberry Pi has been able to access the time over the internet, this will happen at 0300 and 1500 UTC each day. Otherwise it should happen at 3 hours and 15 hours after startup and repeat every 24 hours. From software version 201710081 onwards, the streamer will automatically restart (within 10 seconds) if it crashes due to noisy video input.
Keyed Streaming Mode
In keyed streaming mode, the stream is only sent when a GPIO pin is raised from 0v to 3.3v. An LED connected through a current limiting resistor (470 ohm?) to ground is illuminated when the stream is active. By default, the key signal is input on pin 12 of the GPIO connector. This input is also known as WiringPi 1 or BCM 18. The default pin for the indication LED is pin 7 (WiringPi 7 or BCM 4). These pins are marked as 12 and 7 on the Digithin connector on the Portsdown GPIO Extender Card.
If you want to use different pins, refer to this chart https://wiki.batc.tv/PTT_and_band_switching#Summary_of_GPIO_connections to look up the WiringPi Numbers and then edit line 209 of rpidatv/scripts/startup.sh.
/home/pi/rpidatv/bin/keyedstream 1 7
The WiringPi number for the switch is first, followed by the WiringPi number for the indicator.
Once you have the hardware in place, you can set up your Portsdown to boot-up into Keyed Streaming Mode. From the console, go to the System Setup Menu, and select option 1, Autostart. Then use the arrow keys to highlight "Keyed_Stream_boot" and then (very important) press the space bar to select it. Then press enter.
You can now test the streaming from the console by selecting "Shutdown and Reboot Options". Then select Option 2, "Reboot Now". Test that the stream stops and restarts in response to the switch and that the LED works. If you are happy with the stream, you can disconnect your PC and leave the streamer to run.
The streamer will stop and, if keyed on, restart once every 12 hours to prevent the build-up of excessive latency. If the Raspberry Pi has been able to access the time over the internet, this will happen at 0300 and 1500 UTC each day. Otherwise it should happen at 3 hours and 15 hours after startup and repeat every 24 hours. From software version 201710081 onwards, the streamer will automatically restart (when keyed on) if it crashes due to noisy video input.
Optimising The Quality
You can use a de-noising filter to optimise the quality of your stream. This page has more details: https://wiki.batc.org.uk/Repeater_Streaming
- How do I prevent regular clicks/thumps on Streamed audio?
Check the following:
- A valid video signal must be present at the input to the EasyCap before you turn the streaming on.
- The supply voltage, measured on the GPIO pins, should be between 5.0 and 5.1 volts during streaming.
- The EasyCap should be plugged directly into the RPi or connected by a short, good quality, USB lead.
- How do I reduce the background noise/hum on Streamed audio?
The poor quality USB leads supplied with the EasyCaps should not be used. The EasyCap should be plugged directly into the RPi or connected by a short, good quality, USB lead.