<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://tmplab.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vincib</id>
		<title>Tmplab - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://tmplab.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vincib"/>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php/Special:Contributions/Vincib"/>
		<updated>2026-04-13T18:38:24Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.30.1</generator>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5727</id>
		<title>Streaming Video Raspberry Web Interface</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5727"/>
				<updated>2015-01-18T22:02:42Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Streaming Video with a Raspberry pi, Web Interface ==&lt;br /&gt;
&lt;br /&gt;
At the [[Streaming_Video_With_RaspberryPi]] page, we see how to drive a raspberry pi to save video files locally, stream them using ffmpeg &amp;amp; oggfwd on a secondary laptop.&lt;br /&gt;
&lt;br /&gt;
This page explains the web interface vincib developped to drive the raspberry pi camera from a local machine, triggering the camera recording and saving files with their metadata.&lt;br /&gt;
&lt;br /&gt;
Code at https://github.com/vincib/raspicamlive&lt;br /&gt;
&lt;br /&gt;
== principles ==&lt;br /&gt;
&lt;br /&gt;
* written in brutal php&lt;br /&gt;
* using bootstrap for beautiful interface :) &lt;br /&gt;
* no db, only local files&lt;br /&gt;
&lt;br /&gt;
== interface menu ==&lt;br /&gt;
&lt;br /&gt;
* '''harddrive management''' detect usb or hdd plugged to the PI and format / mount / umount them&lt;br /&gt;
* DONE '''capture management''' allow to start / stop the video with various parameters (width height framerate bitrate whitebalance), allow to save metadata in a json file in the project folder too. show a picture preview for each new .TS file.&lt;br /&gt;
* '''video management''' show previous projects and their capture date, their duration etc. Allow to download a .MTS of a specific sequence (project, starttime, endtime)&lt;br /&gt;
* DONE '''settings''' change rsync server password, poweroff the pi, restart the pi, restart the video service&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5724</id>
		<title>Streaming Video Raspberry Web Interface</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5724"/>
				<updated>2015-01-18T00:52:51Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* interface menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Streaming Video with a Raspberry pi, Web Interface ==&lt;br /&gt;
&lt;br /&gt;
At the [[Streaming_Video_With_RaspberryPi]] page, we see how to drive a raspberry pi to save video files locally, stream them using ffmpeg &amp;amp; oggfwd on a secondary laptop.&lt;br /&gt;
&lt;br /&gt;
This page explains the web interface vincib developped to drive the raspberry pi camera from a local machine, triggering the camera recording and saving files with their metadata.&lt;br /&gt;
&lt;br /&gt;
== principle ==&lt;br /&gt;
&lt;br /&gt;
* written in brutal php&lt;br /&gt;
* using bootstrap for beautiful interface :) &lt;br /&gt;
* no db, only local files&lt;br /&gt;
&lt;br /&gt;
== interface menu ==&lt;br /&gt;
&lt;br /&gt;
* '''harddrive management''' detect usb or hdd plugged to the PI and format / mount / umount them&lt;br /&gt;
* '''capture management''' allow to start / stop the video with various parameters (width height framerate bitrate whitebalance), allow to save metadata in a json file in the project folder too. show a picture preview for each new .TS file.&lt;br /&gt;
* '''video management''' show previous projects and their capture date, their duration etc. Allow to download a .MTS of a specific sequence (project, starttime, endtime)&lt;br /&gt;
* '''settings''' change rsync server password, poweroff the pi, restart the pi, restart the video service&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5723</id>
		<title>Streaming Video Raspberry Web Interface</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_Raspberry_Web_Interface&amp;diff=5723"/>
				<updated>2015-01-18T00:51:18Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: New page: == Streaming Video with a Raspberry pi, Web Interface ==  At the Streaming_Video_With_RaspberryPi page, we see how to drive a raspberry pi to save video files locally, stream them usin...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Streaming Video with a Raspberry pi, Web Interface ==&lt;br /&gt;
&lt;br /&gt;
At the [[Streaming_Video_With_RaspberryPi]] page, we see how to drive a raspberry pi to save video files locally, stream them using ffmpeg &amp;amp; oggfwd on a secondary laptop.&lt;br /&gt;
&lt;br /&gt;
This page explains the web interface vincib developped to drive the raspberry pi camera from a local machine, triggering the camera recording and saving files with their metadata.&lt;br /&gt;
&lt;br /&gt;
== principle ==&lt;br /&gt;
&lt;br /&gt;
* written in brutal php&lt;br /&gt;
* using bootstrap for beautiful interface :) &lt;br /&gt;
* no db, only local files&lt;br /&gt;
&lt;br /&gt;
== interface menu ==&lt;br /&gt;
&lt;br /&gt;
* '''harddrive management''' detect usb or hdd plugged to the PI and format / mount / umount them&lt;br /&gt;
* '''capture management''' allow to start / stop the video with various parameters (width height bitrate whitebalance), allow to save metadata in a json file in the project folder too. show a picture preview for each new .TS file.&lt;br /&gt;
* '''video management''' show previous projects and their capture date, their duration etc. Allow to download a .MTS of a specific sequence (project, starttime, endtime)&lt;br /&gt;
* '''settings''' change rsync server password, poweroff the pi, restart the pi, restart the video service&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5722</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5722"/>
				<updated>2015-01-18T00:29:13Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* D. Broadcast from server to icecast */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
Note: when using 1920x1080, the raspicam take those pixel at the center of the captor. When using smaller definitions, it's using all the 5mpixels and extrapoling down to your requested definition. As a result, a 1280x720 video looks &amp;quot;unzoomed&amp;quot; compared to a 1920x1080, the latter having more grain in the picture too. '''tl;dr: use 1280x720 maximum''' ;)&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix should be integrated here to ensure a good audio/video synchronization)&lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -r 12 -s 640x360 -vb 1000k -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -r 12&amp;lt;/code&amp;gt; number of images per second (recommended: low values for live streaming)&lt;br /&gt;
##&amp;lt;code&amp;gt; -s 640x360&amp;lt;/code&amp;gt; width and height of the video. You need to keep the same ratio but 640x360 is good for low-bandwidth live streaming&lt;br /&gt;
##&amp;lt;code&amp;gt; -vb 1000k &amp;lt;/code&amp;gt; video bitrate in bps. use 400 for ~512Kbps video streaming&lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution not needing any laptop.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentication not included as of now (only IP address), F4V means Flash, requires an USB disk for local backup. Also, the live stream will need to have the same bitrate as the recorded one.&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous (no need for a laptop to encode the live stream)&lt;br /&gt;
&lt;br /&gt;
First, authentication. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server. (we could use rsync server mode too).&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
* http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
* http://blog.cloudfrancois.fr/category/streaming-video.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5721</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5721"/>
				<updated>2015-01-18T00:20:08Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* Raspicam basics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
Note: when using 1920x1080, the raspicam take those pixel at the center of the captor. When using smaller definitions, it's using all the 5mpixels and extrapoling down to your requested definition. As a result, a 1280x720 video looks &amp;quot;unzoomed&amp;quot; compared to a 1920x1080, the latter having more grain in the picture too. '''tl;dr: use 1280x720 maximum''' ;)&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix should be integrated here to ensure a good audio/video synchronization)&lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution not needing any laptop.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentication not included as of now (only IP address), F4V means Flash, requires an USB disk for local backup. Also, the live stream will need to have the same bitrate as the recorded one.&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous (no need for a laptop to encode the live stream)&lt;br /&gt;
&lt;br /&gt;
First, authentication. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server. (we could use rsync server mode too).&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
* http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
* http://blog.cloudfrancois.fr/category/streaming-video.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5720</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5720"/>
				<updated>2015-01-17T23:42:27Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* Solution 2 : FLVSTR + PHP Streamer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix should be integrated here to ensure a good audio/video synchronization)&lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution not needing any laptop.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentication not included as of now (only IP address), F4V means Flash, requires an USB disk for local backup. Also, the live stream will need to have the same bitrate as the recorded one.&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous (no need for a laptop to encode the live stream)&lt;br /&gt;
&lt;br /&gt;
First, authentication. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server. (we could use rsync server mode too).&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
* http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
* http://blog.cloudfrancois.fr/category/streaming-video.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5719</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5719"/>
				<updated>2015-01-17T23:38:15Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* Solution 1 : OGG/VORBIS + Icecast */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix should be integrated here to ensure a good audio/video synchronization)&lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' the Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentification is hard, F4V means Flash, requires an USB disk for local backup&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous&lt;br /&gt;
&lt;br /&gt;
First, authentification. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
* http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
* http://blog.cloudfrancois.fr/category/streaming-video.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5718</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5718"/>
				<updated>2015-01-17T23:37:33Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix can be done on the laptop) &lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' the Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentification is hard, F4V means Flash, requires an USB disk for local backup&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous&lt;br /&gt;
&lt;br /&gt;
First, authentification. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
* http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
* http://blog.cloudfrancois.fr/category/streaming-video.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5716</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5716"/>
				<updated>2015-01-17T23:31:09Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* Solution 4 : HLS + RSYNC */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix can be done on the laptop) &lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' the Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentification is hard, F4V means Flash, requires an USB disk for local backup&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous&lt;br /&gt;
&lt;br /&gt;
First, authentification. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1280 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5715</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5715"/>
				<updated>2015-01-17T23:27:13Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix can be done on the laptop) &lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' the Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentification is hard, F4V means Flash, requires an USB disk for local backup&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous&lt;br /&gt;
&lt;br /&gt;
First, authentification. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1080 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
* http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
* https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
* http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
* https://github.com/phoboslab/jsmpeg&lt;br /&gt;
* https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;br /&gt;
&lt;br /&gt;
== Raspberry PI ==&lt;br /&gt;
&lt;br /&gt;
* Raspbian, debian on Raspberry pi http://www.raspbian.org/&lt;br /&gt;
* Chose your SD card for your PI : http://elinux.org/RPi_SD_cards&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5714</id>
		<title>Streaming Video With RaspberryPi</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=Streaming_Video_With_RaspberryPi&amp;diff=5714"/>
				<updated>2015-01-17T23:25:07Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: /* Solution 4 : HLS + RSYNC */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General =&lt;br /&gt;
&lt;br /&gt;
Caution: this is a Work in progress, things are being tested. The objective is to provide in the end one or more working solutions for everyone.&lt;br /&gt;
&lt;br /&gt;
== Video streaming is a problem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The RaspberryPi camera offers an interesting solution to this problem. It is a very well integrated module of the Pi with one huge advantage: h264 encoding can be performed directly by the CPU as the camera uses the Serial Camera Interface protocol.&lt;br /&gt;
&lt;br /&gt;
So theorically, solving the video problem with the Pi is easy but there are many subtle problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Audio''' As we use video webstreaming mostly for conferences broadcasting, good audio quality is necessary.&lt;br /&gt;
&lt;br /&gt;
'''Slides''' It would be interesting to include slides of conferences while filming.&lt;br /&gt;
&lt;br /&gt;
'''File''' It is important to have a file at the end of the filming.&lt;br /&gt;
&lt;br /&gt;
'''Web''' It is important to have a large viewer base, therefore a well supported format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Raspicam basics ==&lt;br /&gt;
&lt;br /&gt;
http://elinux.org/Rpi_Camera_Module&lt;br /&gt;
&lt;br /&gt;
raspivid is the basic command line used to capture video in h264.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;raspivid -t 3 -fps 25 -b 1000000 -w 1920 -h 1080 -o /tmp/video.h264&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very simple tutorial : http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
== Solution 1 : OGG/VORBIS + Icecast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' &lt;br /&gt;
&lt;br /&gt;
# Use the PI to capture video as h264, merge audio from usb and use ffmpeg to produce MPEGTS &amp;quot;chunks&amp;quot;&lt;br /&gt;
# Rsync the chunks to a laptop or a server (note : the audio mix can be done on the laptop) &lt;br /&gt;
# Assemble the chunks and pipe them in ffmpeg&lt;br /&gt;
# Ask ffmpeg to convert this into ogg&lt;br /&gt;
# Use oggfwd to push the ogg to your icecast server&lt;br /&gt;
# Serve m3u from the server&lt;br /&gt;
&lt;br /&gt;
'''CON''' ogg does not work for everyone. It is supposed to be HTML5 compatible but icecast doesn't offer that by default. &lt;br /&gt;
&lt;br /&gt;
'''PRO''' Icecast is simple, open, and handles authentification. Rsync using SSH is crypto friendly. The file is saved on the server. &lt;br /&gt;
&lt;br /&gt;
=== How to stream in OGG to Icecast ===&lt;br /&gt;
 &lt;br /&gt;
==== A. Compile FFMPEG on pi &amp;amp; server (see below) ====&lt;br /&gt;
&lt;br /&gt;
==== B. Start capture in a screen ====&lt;br /&gt;
&lt;br /&gt;
It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/ &amp;amp;&amp;amp; \&lt;br /&gt;
    raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/local/bin/ffmpeg  -f alsa -itsoffset 6.5 -ac 1 -i hw:1 -acodec aac -strict -2 \&lt;br /&gt;
    -i - -vcodec copy -f segment -segment_list out.list -segment_list_flags +live -segment_list_size 5 -segment_time 4 -segment_time_delta 3 %10d.ts&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt;[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* &amp;amp;&amp;amp; cd /tmp/capture/&amp;lt;/code&amp;gt; We create a /tmp/capture folder and make sure it's empty when starting capture in it&lt;br /&gt;
#&amp;lt;code&amp;gt; raspivid &amp;lt;/code&amp;gt; Use raspivid to capturing with following parameters:&lt;br /&gt;
##&amp;lt;code&amp;gt; -ih &amp;lt;/code&amp;gt;(inline headers) '''DONT CHANGE''' Necessary for technical reasons, as otherwise the &amp;quot;chunking&amp;quot; doesn't work&lt;br /&gt;
##&amp;lt;code&amp;gt; -t 0 &amp;lt;/code&amp;gt; (timeout) '''DONT CHANGE''' Necessary for technical reasons, as otherwise capture stops after 5s&lt;br /&gt;
##&amp;lt;code&amp;gt; -w 1080 -h 720 &amp;lt;/code&amp;gt; (height) and (width) Tweak according to your needs&lt;br /&gt;
##&amp;lt;code&amp;gt; -b 1000000 &amp;lt;/code&amp;gt; (bitrate) Tweak according to your needs (only integer numbers in bits are accepted, here &amp;lt;=&amp;gt; 1Mb)&lt;br /&gt;
##&amp;lt;code&amp;gt; -pf baseline &amp;lt;/code&amp;gt; (h264 profile) Tweak according to your needs ( only baseline, main, or high accepted) &lt;br /&gt;
##&amp;lt;code&amp;gt; -o - &amp;lt;/code&amp;gt; (output) '''DONT CHANGE''' Necessary in order to use the flux as Standard Output&lt;br /&gt;
# We pipe the content into ffmpeg with following parameters:&lt;br /&gt;
## ALSA Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -f alsa &amp;lt;/code&amp;gt; (format) We use &amp;lt;code&amp;gt;alsa&amp;lt;/code&amp;gt; for usb audio capture&lt;br /&gt;
###&amp;lt;code&amp;gt; -itsoffset 6.5 &amp;lt;/code&amp;gt; (time offset) '''This one is a trick''' We noticed our RPi B+ had a 6.5 seconds delay to start the audio, so this is used to resync audio. Tweak. &lt;br /&gt;
###&amp;lt;code&amp;gt; -ac 1 &amp;lt;/code&amp;gt; (number of audio channels) We used a mono input, so &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; was the right choice. Tweak&lt;br /&gt;
###&amp;lt;code&amp;gt; -i hw:1 &amp;lt;/code&amp;gt; (input)  '''Tweak''' as your audio card adress may vary. Find more with &amp;lt;code&amp;gt;arecord -l&amp;lt;/code&amp;gt;&lt;br /&gt;
###&amp;lt;code&amp;gt; -acodec aac &amp;lt;/code&amp;gt; (audio codec) AAC works well for TS live. &lt;br /&gt;
###&amp;lt;code&amp;gt; -strict -2 &amp;lt;/code&amp;gt; Argument mandatory for AAC format&lt;br /&gt;
## Video Input&lt;br /&gt;
###&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DONT CHANGE''' Use the Standard input&lt;br /&gt;
###&amp;lt;code&amp;gt; -vcodec copy&amp;lt;/code&amp;gt; (video codec) '''DONT CHANGE''' Use the video codec from the RPi. Not enough CPU to do anything else. &lt;br /&gt;
###&amp;lt;code&amp;gt; -f segment &amp;lt;/code&amp;gt; (output format) '''DONT CHANGE''' Use a &amp;quot;chunked&amp;quot; output&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list out.list &amp;lt;/code&amp;gt; (segment file) Defines a file containing the produced files names&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_flags +live &amp;lt;/code&amp;gt; (segment file flags) Defines the way the output file caches files names.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_list_size 5 &amp;lt;/code&amp;gt; (segment file size)&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time 4 &amp;lt;/code&amp;gt; (segment time) Defines the capture base duration in seconds. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; -segment_time_delta 3 &amp;lt;/code&amp;gt; (segment time delta) Defines a window to modulate chunks duration in seconds to include mandatory inline headers. Tweak.&lt;br /&gt;
###&amp;lt;code&amp;gt; %10d.ts &amp;lt;/code&amp;gt; The format for chunks files names. %10d will start at 0000000000.ts and ffmpeg understand we want MPEGTS format for chunks&lt;br /&gt;
# ffmpeg saves the files 0000.ts, 0001.ts, etc. and out.list in /tmp/capture&lt;br /&gt;
&lt;br /&gt;
==== C. Use rsync to infinitely synchronise chunks on server ====&lt;br /&gt;
&lt;br /&gt;
'''Some important points to mention here '''&lt;br /&gt;
&lt;br /&gt;
* The RaspberryPi '''MUST''' have access to a &amp;lt;server&amp;gt; using an SSH KEY for an &amp;lt;user&amp;gt;. Password access won't work for infinite rsync.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be your laptop. If so it MUST be on the same LAN as the RaspberryPi &lt;br /&gt;
* This &amp;lt;server&amp;gt; '''CAN''' be a datacenter machie. If so it MUST be accessible on Internet by the RaspberryPi.&lt;br /&gt;
* This &amp;lt;server&amp;gt; '''MUST''' have FFMPEG installed (see point D below)&lt;br /&gt;
* It is advised to run this one liner in a &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command on the RaspberryPi &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; ssh &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;amp;&amp;amp; \&lt;br /&gt;
    while true; do rsync -a --files-from=/tmp/capture/out.list /tmp/capture &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; sleep 1; done&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; ssh &amp;lt;/code&amp;gt; Use SSH ...&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt; &amp;lt;/code&amp;gt; ... to connect to server &amp;quot;server&amp;quot; as user &amp;quot;user&amp;quot;&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;quot;[ -d /tmp/capture ] || mkdir /tmp/capture&amp;quot; &amp;lt;/code&amp;gt; ... and create if not exists a folder &amp;quot;/tmp/capture&amp;quot;&lt;br /&gt;
#&amp;lt;code&amp;gt; while true; do &amp;lt;/code&amp;gt; Run an infinite loop&lt;br /&gt;
##&amp;lt;code&amp;gt; rsync &amp;lt;/code&amp;gt; Start rsync file synchronisation &lt;br /&gt;
###&amp;lt;code&amp;gt; -a &amp;lt;/code&amp;gt; (archive mode) Set the right parameters for transfer&lt;br /&gt;
###&amp;lt;code&amp;gt; --files-from=/tmp/capture/out.list &amp;lt;/code&amp;gt; Use the out.list as a list of file to transfer, which avoids scanning the whole folder&lt;br /&gt;
###&amp;lt;code&amp;gt; /tmp/capture &amp;lt;/code&amp;gt; (source) Transfer local folder content...&lt;br /&gt;
###&amp;lt;code&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;server&amp;gt;:/tmp/capture; &amp;lt;/code&amp;gt; (destination) To the server &amp;quot;server&amp;quot; &lt;br /&gt;
##&amp;lt;code&amp;gt; sleep 1; &amp;lt;/code&amp;gt; Sleep one second&lt;br /&gt;
#&amp;lt;code&amp;gt; done &amp;lt;/code&amp;gt; Loop end&lt;br /&gt;
&lt;br /&gt;
==== D. Broadcast from server to icecast ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* You '''MUST''' install some script on &amp;lt;server&amp;gt; to assemble / concatenate the MPEGTS chunks for you. &lt;br /&gt;
    This PHP streamer is made for that: &amp;lt;code&amp;gt;https://raw.githubusercontent.com/albancrommer/raspistream/master/stream.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' install ffmpeg on &amp;lt;server&amp;gt; with ogg support (see below)&lt;br /&gt;
* You '''MUST''' install the oggfwd command line tool with &amp;lt;code&amp;gt;aptitude install oggfwd&amp;lt;/code&amp;gt;&lt;br /&gt;
* You '''MUST''' have access to an icecast server. If you use a datacenter server, everything can run locally&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; php /usr/local/bin/stream.php | ffmpeg -i - -f ogg - | oggfwd -p -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;stream.server.com&amp;gt; 8000 mySecretIceCastStreamingPassword /test &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php /usr/local/bin/stream.php &amp;lt;/code&amp;gt; Start an infinite stream of assembled chunks received via rsync &lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' Use Standard In as input &lt;br /&gt;
##&amp;lt;code&amp;gt; -f ogg &amp;lt;/code&amp;gt; (format) '''DON'T CHANGE''' Use ogg as output format&lt;br /&gt;
##&amp;lt;code&amp;gt; - &amp;lt;/code&amp;gt; (output) '''DON'T CHANGE''' Output to Standard Out&lt;br /&gt;
#&amp;lt;code&amp;gt; | oggfwd  &amp;lt;/code&amp;gt; Pipe into oggfwd&lt;br /&gt;
##&amp;lt;code&amp;gt; -p  &amp;lt;/code&amp;gt; (public) Makes the stream public. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -n &amp;quot;My RaspberryPi Stream&amp;quot; &amp;lt;/code&amp;gt; (name) Your stream name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;stream.server.com&amp;gt; &amp;lt;/code&amp;gt; (address) Your icecast server name. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; 8000 &amp;lt;/code&amp;gt; (port) 8000 is default for icecast. Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;mySecretIceCastStreamingPassword&amp;gt; &amp;lt;/code&amp;gt; (password) The icecast input password Adapt&lt;br /&gt;
##&amp;lt;code&amp;gt; /rpi01 &amp;lt;/code&amp;gt; (mountpoint) The icecast &amp;quot;mountpoint&amp;quot; ie. the path for your stream&lt;br /&gt;
&lt;br /&gt;
==== E. Get the m3u from icecast ====&lt;br /&gt;
&lt;br /&gt;
With the default parameters provided the stream would be accessed on &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;http://&amp;lt;stream.server.com&amp;gt;:8000/rpi01.m3u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
http://sirlagz.net/2013/01/07/how-to-stream-a-webcam-from-the-raspberry-pi-part-3/&lt;br /&gt;
&lt;br /&gt;
=== How to get full video from the small chunks ===&lt;br /&gt;
&lt;br /&gt;
After the streaming you should have chunks both on the RaspberryPi and the server, and could perform the conversion on any of them.&lt;br /&gt;
&lt;br /&gt;
Except that the RaspberryPi is VERY slow and that depending on your budget / stability needs you might not have kept all the chunks on the RaspberryPi.&lt;br /&gt;
&lt;br /&gt;
In other words, make the conversion on the server, be it your laptop or a datacenter server.&lt;br /&gt;
&lt;br /&gt;
==== A. Clean the last file (optional) ====&lt;br /&gt;
&lt;br /&gt;
As our last chunk / fragment might be invalid, it's safer to remove it using :&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;ls /tmp/capture/*ts|tail -n 1|xargs rm &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
&lt;br /&gt;
This command retrieves a sorted list of all chunks in the capture folder, extracts the last one and deletes it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== B. Convert to single file (mp4, webm) ====&lt;br /&gt;
&lt;br /&gt;
It is assumed you have FFMPEG installed on the machine.&lt;br /&gt;
&lt;br /&gt;
It is assumed you want to make minimal changes to your original video input (size, bitrate, etc). Only essential options are provided but you can add more according to your needs, double pass conversion is not included either.&lt;br /&gt;
&lt;br /&gt;
It is recommanded to use a script for files merging, as ffmpeg syntax can be a bit of a mess for that, with little option if you want to use start or end file.&lt;br /&gt;
&lt;br /&gt;
    This PHP script is made for that : https://raw.githubusercontent.com/albancrommer/raspistream/master/concat.php&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
''' Converting to MP4 '''&lt;br /&gt;
&lt;br /&gt;
This operation can be fast as the MPEGTS chunks are ready for MP4&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -movflags +faststart -threads 0 -profile:v high -preset slow &amp;lt;myfile&amp;gt;.mp4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input)  '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -movflags +faststart &amp;lt;/code&amp;gt; '''DON'T CHANGE'''  Make the file ready for web viewing&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -profile:v high &amp;lt;/code&amp;gt; Set the output quality. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -preset slow &amp;lt;/code&amp;gt; Set the encoding speed.Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.mp4 &amp;lt;/code&amp;gt; Your output file name. Adapt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Converting to WEBM '''&lt;br /&gt;
&lt;br /&gt;
This operation will be slower as audio and video tracks needs to use new codecs&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;php concat.php &amp;lt;start&amp;gt; &amp;lt;end&amp;gt; | ffmpeg -i - -codec:a libvorbis -codec:v libvpx -threads 0 -quality good -cpu-used 0 -qmin 10 -qmax 42 &amp;lt;myfile&amp;gt;.webm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's happening here'''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#&amp;lt;code&amp;gt; php concat.php &amp;lt;/code&amp;gt; Start concatenation&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;start&amp;gt; &amp;lt;/code&amp;gt; (optional) an integer designing the first file to include&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;end&amp;gt; &amp;lt;/code&amp;gt;(optional) an integer designing the last file to include&lt;br /&gt;
#&amp;lt;code&amp;gt; | ffmpeg &amp;lt;/code&amp;gt; Pipe into FFMPEG with following parameters&lt;br /&gt;
##&amp;lt;code&amp;gt; -i - &amp;lt;/code&amp;gt; (input) '''DON'T CHANGE''' use stdin as input&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:a libvorbis &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the audio codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -codec:v libvpx &amp;lt;/code&amp;gt; (codec) '''DON'T CHANGE''' Define the video codec&lt;br /&gt;
##&amp;lt;code&amp;gt; -threads 0 &amp;lt;/code&amp;gt; Require all CPU to work on the conversion. Tweak.&lt;br /&gt;
##&amp;lt;code&amp;gt; -quality good &amp;lt;/code&amp;gt; Set the encoding speed. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; -cpu-used 1 &amp;lt;/code&amp;gt; Set the encoding speed. Tweak &lt;br /&gt;
##&amp;lt;code&amp;gt; -qmin 10 -qmax 42 &amp;lt;/code&amp;gt; Set the encoding quality. Tweak&lt;br /&gt;
##&amp;lt;code&amp;gt; &amp;lt;myfile&amp;gt;.webm &amp;lt;/code&amp;gt; Your output file name. Adapt&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/&lt;br /&gt;
&lt;br /&gt;
== Solution 2 : FLVSTR + PHP Streamer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' the Octopuce company has a solution to convert live MP4 to F4V. With an USB audio card, we could mux the MP4 and AAC audio and have a standalone solution.&lt;br /&gt;
&lt;br /&gt;
'''CON''' authentification is hard, F4V means Flash, requires an USB disk for local backup&lt;br /&gt;
&lt;br /&gt;
'''PRO''' the pi can be autonomous&lt;br /&gt;
&lt;br /&gt;
First, authentification. This problem is adressed by solving encryption as well: we use an SSL socket to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution 3 : RTSP ==&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use an RTSP stream with VLC and the V4L driver&lt;br /&gt;
&lt;br /&gt;
'''CON''' Non commercial RTSP server are not the norm, requires VLC or Flash player, Quality with v4l is low&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Easy to work out&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8&lt;br /&gt;
&lt;br /&gt;
http://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.gusari.org/viewtopic.php?f=16&amp;amp;t=1130&lt;br /&gt;
&lt;br /&gt;
http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/&lt;br /&gt;
&lt;br /&gt;
== Solution 4 : HLS + RSYNC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Basic idea''' Use HLS segmentation and rsync&lt;br /&gt;
&lt;br /&gt;
'''CON''' Not all web players can do HLS&lt;br /&gt;
 &lt;br /&gt;
'''PRO''' Almost out of the box, robust&lt;br /&gt;
&lt;br /&gt;
'''Howto'''&lt;br /&gt;
&lt;br /&gt;
1. Compile fresh ffmpeg on the pi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Run a capture : &amp;lt;code&amp;gt;raspivid  -ih -pf baseline -t 0 -b 1000000 -w 1080 -h 720 -v -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 6.5 -i hw:1 -acodec aac -strict -2 -vcodec copy out.m3u8 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Run a cron rsync to server (todo)&lt;br /&gt;
&lt;br /&gt;
4. Connect a client (todo)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sources''' &lt;br /&gt;
&lt;br /&gt;
http://www.ffmpeg.org/ffmpeg-formats.html#hls&lt;br /&gt;
&lt;br /&gt;
= FFMPEG compilation =&lt;br /&gt;
&lt;br /&gt;
This installation is debian based. Some packages are included by default :&lt;br /&gt;
&lt;br /&gt;
* ffmpeg : Provides a large number of the dependencies required at compilation tim&lt;br /&gt;
* yasm : modular assembler (good for compilation)&lt;br /&gt;
* pkg-config : info about installed libraries (good for compilation)&lt;br /&gt;
* screen : helpful for running compilation in background&lt;br /&gt;
&lt;br /&gt;
== For Raspberry ==&lt;br /&gt;
&lt;br /&gt;
For the Raspberry, we only need the support of h264, AAC and ALSA&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo -s&lt;br /&gt;
aptitude install screen yasl libx264-dev libasound2-dev libfdk-aac-dev ffmpeg&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libx264 --enable-libfdk-aac &lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== For laptop or server ==&lt;br /&gt;
&lt;br /&gt;
Your default debian might come with sufficent support but if you want total control, compiling is a good idea.&lt;br /&gt;
&lt;br /&gt;
Remove packages and ffmpeg support if you don't need everything. &lt;br /&gt;
&lt;br /&gt;
Ex: to produce ogg format, you only need &lt;br /&gt;
* aptitude packages libtheora-dev and libvorbis-dev &lt;br /&gt;
* configure options --enable-libtheora --enable-libvorbis&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sudo &lt;br /&gt;
aptitude update &amp;amp;&amp;amp; aptitude install screen pkg-config yasm ffmpeg libass-dev libavcodec-extra libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev&lt;br /&gt;
cd /usr/src &lt;br /&gt;
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git &lt;br /&gt;
cd ffmpeg&lt;br /&gt;
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab&lt;br /&gt;
make &lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Here are a number of unsorted links&lt;br /&gt;
&lt;br /&gt;
http://techzany.com/2013/09/live-streaming-video-using-avconv-and-a-raspberry-pi/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FFMPEG ==&lt;br /&gt;
&lt;br /&gt;
http://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment&lt;br /&gt;
&lt;br /&gt;
https://trac.ffmpeg.org/wiki/StreamingGuide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Node == &lt;br /&gt;
&lt;br /&gt;
http://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets&lt;br /&gt;
&lt;br /&gt;
https://github.com/phoboslab/jsmpeg&lt;br /&gt;
&lt;br /&gt;
https://github.com/fluent-ffmpeg/node-fluent-ffmpeg&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	<entry>
		<id>https://tmplab.org/wiki/index.php?title=User:Vincib&amp;diff=5713</id>
		<title>User:Vincib</title>
		<link rel="alternate" type="text/html" href="https://tmplab.org/wiki/index.php?title=User:Vincib&amp;diff=5713"/>
				<updated>2015-01-17T23:18:06Z</updated>
		
		<summary type="html">&lt;p&gt;Vincib: New page: Hi, I'm vincib, aka Benjamin Sonntag, cofounder of La Quadrature du Net, cto of Octopuce, hosting, linux, free software, hacktivist.  Here I try to document &amp;amp; do video streaming with cocoa...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I'm vincib, aka Benjamin Sonntag, cofounder of La Quadrature du Net, cto of Octopuce, hosting, linux, free software, hacktivist.&lt;br /&gt;
&lt;br /&gt;
Here I try to document &amp;amp; do video streaming with cocoadaemon.&lt;/div&gt;</summary>
		<author><name>Vincib</name></author>	</entry>

	</feed>