Changes between Version 28 and Version 29 of free-video-streaming-technology


Ignore:
Timestamp:
Nov 15, 2018, 8:56:47 AM (2 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • free-video-streaming-technology

    v28 v29  
    33May First/People Link is committed to [https://support.mayfirst.org/wiki/live-video-streaming-support supporting video streaming], as well as free software. These two goals have have challenged us to use tools that allow for high quality video streams using entirely free software.
    44
    5 See also: [wiki:StreamDesktop how to stream your desktop].
     5This page documents how to run a professional quality video stream of an event. If you are in a hurry and want a quick and easy way to stream from your web cam or cell phone, see our [wiki:broadcast broadcast page].
     6
     7If you are running linux, and want a quick and easy way to stream your desktop, see [wiki:StreamDesktop how to stream your desktop].
    68
    79= Video streaming with free software =
    8 The method and tool set that we are now using and recommending was first developed for streaming the annual [http://debconf.org/ Debian Developers Conference], and has since been used to stream other events and conferences such as FOSDEM and Linux Conf Australia. These tools should work on all GNU/Linux distributions.
    910
    10 Many of the notes, and background information come from steady reference to the [http://dvswitch.alioth.debian.org/wiki/ DVswitch Wiki], particularly the [http://dvswitch.alioth.debian.org/wiki/component_interaction/ component interaction], as well as other resources supplied by the developers.
     11We recommend downloading and installing the [https://obsproject.com/ Open Broadcaster Software]. It runs on windows, linux and macintosh operating systems.
    1112
    12 For a simple script that will use your local webcam and microphone see the [http://publish.mayfirst.org/icecast/ Mobi Script]
     13It will broadcast to a number of proprietary services and, with a little tweaking, it can broadcast to May First/People Link's free and open source streaming service as well (thanks to a [https://epir.at/2018/03/08/obs-icecast-streaming/ helpful blog post].
    1314
    14 == Basic Software Components ==
     15Start by [/newticket opening a ticket] requesting a username and password on one of our icecast servers. Once you have a username and password, you can continue.
    1516
    16  * [http://dvswitch.alioth.debian.org/wiki/ dvswitch] (GPLv2)
    17    * dvsource (ships with dvswitch but can be installed independently, and is packaged independently in some GNU/Linux distros)
    18    * dvsink (ships with dvswitch but can be installed independently, and is packaged independently in some GNU/Linux distros)
    19  * [http://v2v.cc/~j/ffmpeg2theora/ ffmpeg2theora]  (GPLv3)
    20  * [http://v2v.cc/~j/oggfwd/ oggfwd] (GPLv2)
    21  * [http://www.icecast.org/ icecast2] (GPLv2)
    22  * dvsink GPLv2
     17Then, launch the obs program.
    2318
    24 you can install those programs by running the following command as root on Debian Whezzy (some packages are not available for 'jessie' yet):
     19== Output settings ==
     20
     21Click `File -> Settings`.
     22
     23Then, `Output`.
     24
     25Then, the `Recording` tab.
     26
     27Make your recording tab match the screen grab below.
     28
     29[[Image(obs-recording-configuration.png)]]
     30
     31Note: the `File path or URL` setting is critical and will contain your icecast username and password as well as your "mount point". It should be in the format:
    2532
    2633{{{
    27 aptitude install dvswitch oggfwd ffmpeg ffmpeg2theora dvsource dvsink libav-tools pulseaudio-utils
     34icecast://USERNAME:PASSWORD@a.stream.mayfirst.org:8000/MOUNTPOINT.webm
    2835}}}
    2936
    30 or this one on Ubuntu:
     37The USERNAME, PASSWORD, and MOUNTPOINT should be replace with values specific to your account.
    3138
    32 {{{
    33 sudo apt-get install dvswitch oggfwd ffmpeg ffmpeg2theora dvsource dvsink libav-tools pulseaudio-utils
    34 }}}
     39Click "OK" to return to the main screen.
    3540
    36 == Hardware ==
    37 Depending on the hardware, bandwidth, LAN, and other physical constraints, there can be some flexibility in how much hardware this requires. There are some general things that will make your life easier.
     41== Input settings ==
    3842
    39  * One ore more DV cameras with firewire. Firewire transfers data at a higher rate, however many newer cameras do not have Firewire. In this case you may be better off with a slightly older camera. Take note that most FW cameras have optical and digital zoom and some other functions, while most usb cameras dont'
    40  * One or more usb cameras.
    41  * A computer with appropriate ports for the camera, and a working NIC (runs dvsource).
    42  * A computer with good graphics support, reasonable processor, at least 2G of RAM and a working NIC (runs dvswitch).
    43  * A computer with a good processor a working NIC with an connection to the Internet
    44  * A computer with running icecast2 with a high speed NIC and good bandwidth (more on that later).
    45  * Ideally a gigabyte switch, with gigabyte NICs on all of the computers should be used on the LAN to cut down on latency, but it should work on a 10/100 LAN just fine.
     43The input settings will depend on your equipment. But for a quick test, you can click the plus sign under the "Sources" box and add "Video Capture Device" to add your web cam.
    4644
    47 There are additional pieces of hardware that can be obtained to increase the quality of your stream.
     45Audio should be using your default mic.
    4846
    49  * A USB audio device that can take inputs. This is helpful as most laptops expect microphone input and so do odd things with gain, reducing audio quality. There are many mixers and other simpler devices available. As long as it works on your version of GNU/Linux with ALSA, it can be used as a source. Thinking about the sound is important, as poor sound quality is more distracting than poor video quality.
    50  * [A VGA converter, such as the TwinPact100 (a model recommended by the DVswitch developers that runs ~$500USD). This will allow you to turn a presenter's computer into a video source for the stream.] <-- this is not needed if the presenter's computer is running debian as (s)he can streams his desktop directly to dvswitch.
     47== Broadcast ==
    5148
    52 The three computers running dvsource, dvswitch and dvsink is an ideal setup. In a pinch all three pieces can be run on fewer machines. We have successfully run all three on an x61 Thinkpad, but the machine ran '''hot'''. Dvsource is very lightweight, and can be run on an old machine with little RAM. DVswitch can be moderately CPU intensive and depending on how many dvsources you are using that scales up. DVsink is processor intensive, mainly because ffmpeg has to convert the dv stream to ogg. If using two machines, it is best to split the sink from the switch.
    53 
    54 == Networking and Bandwidth ==
    55 There are multiple layers of bandwidth and networking in this setup. On site you will need two things, a functional LAN (preferably wired), and at least one connection to the Internet that can be used for forwarding the stream to a server. This connection does not need to be astonishingly fast to achieve a quality stream. It is more important to attempt establishing a stable route to the server than a high bandwidth one.
    56 
    57 Depending on your expected audience size, the bandwidth needs of your Icecast server may vary. In our limited testing, the Icecast software can handle several thousand streams at once, without a huge impact on the hardware, so it is likely that you will hit bandwidth limits before you hit a hardware bottleneck. For MFPL's streams, we have Icecast running from data center connections. If you are anticipating a large audience of stream viewers from within your LAN, it may be worthwhile to set up and Icecast server locally to conserve onsite bandwidth (particularly if you need that space to publish the stream to other servers).
    58 
    59 == Formats and Protocols ==
    60 Provided you are using devices that generate DV, there is only one main conversion; from DV to ogg/theora. DVsource and DVswitch pass their video in DV, DVsink allows you to pipe the DV to other software. Using ffmpeg2theora we convert the DV stream directly to theora, and then forward the ogg stream using oggfwd.
    61 
    62 == Embedding streams onto web sites ==
    63 Once you have an ogg stream running, it is important to make it easy to find and view. Embedding it into the browser is the common choice. There has been a significant  growth of support for the HTML5 video tag as well as in browser support for ogg/theora. Firefox/Iceweasel, Chrome/Chromium, Opera will all embed a video player with just a video tag pointing to a functional stream.
    64 
    65 However, there is still the looming problem of proprietary browsers refusing to support ogg/theora. This problem has been addressed by [http://www.theora.org/cortado/ cortado], which uses a Java applet to supply oggs to browsers that don't support HTML5 video tags and/or ogg/theora.
    66 
    67 [http://current.workingdirectory.net/pages/jxiph/ jxiph] is a simple javascript library that attempts to auto-detect whether a browser should be served the cortado java app or html 5.
    68 
    69 == A Basic Example ==
    70 Here is a simple set up, with some commands to illustrate how the flow of stream works; there are of course different ways to do this.
    71 
    72 Again we are assuming that there is a functional LAN and functional connection to the Internet, and all machines are running functional versions of GNU/Linux with appropriate software installed. All of which are out of scope for this example.
    73 
    74 === On the Icecast server ===
    75  * Double check Icecast is running and make sure you know the port it is listening on, and the password.
    76  * ('''TODO: Add a link to some good information about installing and configuring Icecast''')
    77  
    78 === On the DVswitch machine ===
    79  * Make sure it is connected to the LAN
    80  * Launch "dvswitch" either from a terminal or a window manager launcher.
    81 
    82 You would need two parameters: the port and the host. As for port you can use whatever you want but 2000 is recomended and >1024 is mandatory.
    83 
    84 As for the host, if you want to use cameras connected to other computers, you would need to use the ip of the computer running dvswitch, which you can get running this command and looking for a number different to 127.0.0.1,  which would likely start with 192.
    85 
    86 {{{
    87 /sbin/ifconfig|grep inet
    88 }}}
    89 
    90 outpt exmple:
    91 
    92 {{{
    93 ~$ /sbin/ifconfig |grep inet
    94           inet addr:127.0.0.1  Mask:255.0.0.0
    95           inet6 addr: ::1/128 Scope:Host
    96           inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0
    97           inet6 addr: fe80::aabb:cfff:fe18:349e/64 Scope:Link
    98 }}}
    99 
    100 If you are not planning to send video streams from other computers, you can use 'localhost' insted of the ip address.
    101 
    102 From now on you should use 'localhost' or the ip number, depending of what you have choosen, instead  of DVSWITCHHOST.
    103 
    104 So run this command to start dvswitch:
    105 
    106 {{{
    107 dvswitch -h DVSWITCHHOST -p 2000
    108 }}}
    109  * '''NOTE:''' You have to start DVswitch before starting the source or the sink.
    110 
    111 == On the machine connected to the camera ==
    112 === if using a firewire cam ===
    113  * Connect a DV cam via Firewire to the  machine
    114  * Double check your  LAN connection.
    115  * In a terminal run:
    116 
    117  {{{
    118 dvsource-firewire -h DVSWITCHHOST -p 2000
    119  }}}
    120 
    121  Where DVSWITCHHOST is either the domain, IPV4 or IPV6 address of the machine running DVswitch. The "-p" flag specifies the port on which the DVswitch is listening.
    122  
    123 
    124 === if using an USB cam ===
    125 
    126  * Connect the usb cam to the computer if you want to use a wired cam insted of the built in most laptops come with.
    127  * look for the video input device you are going to use with this command
    128 {{{
    129 ls /dev/video*
    130 }}}
    131 
    132 it should return someting like this:
    133 
    134 {{{
    135 /dev/videoX
    136 }}}
    137 
    138 being X a number depending of the number of cameras connected to the computer. This would show up if you have 2 usb cameras connected to the computer:
    139 
    140 {{{
    141 ls /dev/video*
    142 /dev/video0
    143 /dev/video1
    144 }}}
    145 
    146 * Run the next command to grab the video comming from the usb cam and pipe it to the dvsource-file command to send it to dvswitch.
    147 
    148 {{{
    149 avconv  -f video4linux2  -i /dev/videoX  -target ntsc-dv - | dvsource-file /dev/stdin -p 2000 -h DVSWITCHHOST
    150 }}}
    151 
    152 Notice using the number of the cam insted of the X in the command line above.
    153 Also note you are sending an ntsc-dv video format but it could be pal-dv. This matters if you are using more than 1 camera, as the first video stream sent to dvswitch will set the 'default' format and the other sources would need to stick with it.
    154 
    155 Finally, note you can run this command on different computers at the same time to feed dvswitch with several video streams if you used the ip of the computer running dvswitch instead of using 'localhost'
    156 
    157 === if you want to stream you desktop ===
    158 
    159 First off you would need to get the size of your screen. You can use this command to get it and store it in a variable called 'PANTALLA'
    160 
    161 {{{
    162 export PANTALLA=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }')
    163 }}}
    164 
    165 and verify the size of the screen by echoing that variable with the following command:
    166 
    167 {{{
    168 echo $PANTALLA
    169 }}}
    170 
    171 Now you can stream you desktop to dvswitch running this:
    172 
    173 {{{
    174 avconv -f x11grab -s $PANTALLA -r 29 -i :0.0 -target ntsc-dv -y - | dvsource-file /dev/stdin -p 2000 -h DVSWITCHHOST
    175 }}}
    176 
    177 Note that you would create and infinite (funny) loop if you run this command on the same computer running dvswitch but it won't harm. =)
    178 
    179 
    180 == On the DVsink machine ==
    181  * Make sure that you have the "ffmpeg2theora" and "oggfwd" packages installed.
    182  * Run:
    183 
    184   {{{
    185 dvsink-command -h DVSWITCHHOST -p 2000 tee /dev/null | ffmpeg2theora - -f dv -F 25:5 --speedlevel 0 -v 4 -a 0 -c 1 -H 9600 -o - | oggfwd ICECASTHOST ICECASTPORT ICECASTPASS /mountpoint.ogg
    186   }}}
    187 
    188 Consult the ffmpeg2theora man pages for different conversion values.
    189 
    190 ICECASTHOST is the hostname or IP of the icecast server.
    191 ICECASTPORT is the port on which Icecast is listening. The default is 8000.
    192 ICECASTPASS is the password for the Icecast server.
    193 mountpoint.ogg is the mountpoint of your stream name.
    194 
    195 Here's an alternative that will save a raw dv file with the output ''and'' stream to an icecast server (beware - this will create a file that consumes a lot of disk space).
    196 
    197 {{{
    198 dvsink-command -h DVSWITCHHOST -p 2000 tee out.dv | ffmpeg2theora - -f dv -F 25:5 --speedlevel 0 -v 4 -a 1 -c 1 -H 9600 -o - | oggfwd ICECASTHOST ICECASTPORT ICECASTPASS /mountpoint.ogg
    199 }}}
    200 
    201 And here's an alternative that is useful if you are streaming using a limited bandwidth upstream connection, you can replace the part starting with ffmpeg2theora with the following. It reduces the size of output to 360x240 (from twice that size) and it limits from 25 frames per second to just 5 frames per second.
    202 
    203 {{{
    204 ffmpeg2theora - -f dv -F 5 --speedlevel 0 --width 360 --height 240 -v 4 -a 1 -c 1 -H 9600 -o -
    205 }}}
    206 
    207 == Testing the Stream ==
    208 You're now ready to test the stream. In a browser that supports ogg/theora, or a standalone player (like VLC), and open: {{{ http://ICECASTHOST/mountpoint.ogg }}}. If you see a video you have a working single camera stream.
    209 
    210 More source machines can be added. DVswitch allows you to switch sources, as well as use varied audio sources (alsa), and DV files.
    211 
    212 == Recording your stream ==
    213 
    214 You can record your stream on two different ways and qualities.
    215 
    216 === Higher stream quality ===
    217 
    218 The first way would get the highest quality avaliable from the video sources, and would save it as a .dv file. This might be awesome but it also might  consume a huge ammount of disk space. If you have enough room to store yout recording, you can run this command to start recording directly from dvsiwtch:
    219 
    220 {{{
    221 dvsink-files -h DVSWITCHHOST -p 2000 FILENAME-OF-THE-RECORDING
    222 }}}
    223 
    224 Now press the 'record' button at the dvswitch interface to start/stop recording, and the 'cut' one to create a new file with the same name but a highet number
    225 
    226 === Lower stream quality ===
    227 
    228 You can also record the stream locally at the same quality you are streaming through the ffmpg2theora command we used above to send the stream to the Icecast2 server. In this case you would only need to add {{{-o recording-file-name.ogv -}}} to the same command you used before. Like this:
    229 
    230  
    231 {{{
    232 dvsink-command -h DVSWITCHHOST -p 2000 tee out.dv | ffmpeg2theora - -f dv -F 25:5 --speedlevel 0 -v 4 -a 1 -c 1 -H 9600 -o recording-file-name.ogv  -o - | oggfwd ICECASTHOST ICECASTPORT ICECASTPASS /mountpoint.ogg
    233 }}}
    234 
    235 Please note that you would overwrite the first recording if you run that command twice, as you are using the same filename. You could is a $date variable to prevent this from happening. Like this:
    236 
    237 {{{
    238 dvsink-command -h DVSWITCHHOST -p 2000 tee out.dv | ffmpeg2theora - -f dv -F 25:5 --speedlevel 0 -v 4 -a 1 -c 1 -H 9600 -o recording-file-name-$(date +"%T_%d-%m-%Y").ogv  -o - | oggfwd ICECASTHOST ICECASTPORT ICECASTPASS /mountpoint.ogg
    239 }}}
    240 
     49When you are ready, simply click the "Start recording" button. Remember: since we are tweaking OBS to broadcast to our streaming service via the recording functionality, we click "Start Recording" when we want to stream and ''not'' the start streaming button.