Apple Streaming: Difference between revisions

Fixed the command
(Wrote up how HLS should work)
 
(Fixed the command)
Line 1: Line 1:
HTTP Live Streaming (HLS) is a technology for Apple devices such as iPhones, iPads, iPod Touches and Safari to receive live video streams, given Apples disapproval of Flash RTMP streaming.  
HTTP Live Streaming (HLS) is a technology for Apple devices such as iPhones, iPads, iPod Touches and Safari to receive live video streams, given Apples disapproval of Flash RTMP streaming.  


Please note, at time of writing (04/10/12) this is how it will work, but hasn't been implemented just yet. Should be this weekend, and this notice will be removed when implementation is complete.
Please note, at time of writing (05/10/12) this is how it will work, but hasn't been implemented just yet. Will be implemented as soon as the stream's back up, and this notice will be removed when implementation is complete.


=Functional Overview=
=Functional Overview=
Line 12: Line 12:
Instead, [[ystvencode]] which acts as the encode server for HLS (given its spare cycles most of the time), reads the high-quality internal  stream (stream2) using rtmpdump, and transcodes it with FFMPEG as in the following command. This generates 480x320 H.264 encoded video, using the -re switch to have FFMPEG run as close to realtime as possible, and pipes it out to STDOUT. The segmenter, from https://github.com/johnf/m3u8-segmenter receives the video stream via a pipe and segments it into 3 second long chunks, with 3 active at a time. The complete command is:  
Instead, [[ystvencode]] which acts as the encode server for HLS (given its spare cycles most of the time), reads the high-quality internal  stream (stream2) using rtmpdump, and transcodes it with FFMPEG as in the following command. This generates 480x320 H.264 encoded video, using the -re switch to have FFMPEG run as close to realtime as possible, and pipes it out to STDOUT. The segmenter, from https://github.com/johnf/m3u8-segmenter receives the video stream via a pipe and segments it into 3 second long chunks, with 3 active at a time. The complete command is:  


<code>rtmpdump -r "rtmp://ystvstrm1.york.ac.uk/live/stream2" -v | ffmpeg -re -i - -f mpegts -acodec libmp3lame -ab 64000 -s 480x320 -vcodec libx264 -b:v 480000 -level 30 -aspect 480:320 -g 30 -async 2 - | ./m3u8-segmenter -i - -d 3 -p iphone/stream1 -m iphone/stream1.m3u8 -u http://ystv.co.uk/static/ -n 3</code>
<code>rtmpdump -r "rtmp://ystvstrm1.york.ac.uk/live/stream2" -v | ffmpeg -re -i - -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 512x288 -vcodec libx264 -b:v 200k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 400k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -g 30 -async 2 - | ./m3u8-segmenter -i - -d 15 -p iphone/stream1 -m iphone/stream1.m3u8 -u http://ystv.co.uk/static/</code>


This runs in /usr/local/m3u8-segmenter, and the iphone directory is a mount to the /data/webs/ystv/static/iphone folder on the webserver (served over NFS).  
This runs in /usr/local/m3u8-segmenter, and the iphone directory is a mount to the /data/webs/ystv/static/iphone folder on the webserver (served over NFS).  


=Clientside=
=Clientside=
For the clients, a simple browser detection script scans to see if the user is on an iPhone or similar, and if they are queries the database for an HLS stream name for that stream. If one is found, it is prepended with the site address (http://ystv.co.uk/ unless on a development server) and presented as an image of the YSTV logo in place of the usual live stream box, linked to the M3U8 playlist. Normally the user's device will then render a play symbol over the top, tapping this will open the phone's native HLS player.
For the clients, a simple browser detection script scans to see if the user is on an iPhone or similar, and if they are queries the database for an HLS stream name for that stream. If one is found, it is prepended with the site address (http://ystv.co.uk/ unless on a development server) and presented as a video tag containing an image of the YSTV logo in place of the usual live stream box, linked to the M3U8 playlist. Normally the user's device will then render a play symbol over the top, tapping this will open the phone's native HLS player.


[[Category:Computing]]
[[Category:Computing]]
camera trained, computing team, confluence-administrators, confluence-users, crowd-administrators, directors, domain admins, domain users, jira-administrators, jira-developers, jira-users, ladder trained, lighting trained, stash-administrators, stash-users, technical assistants, webdev
163

edits