LinHES Forums
http://forum.linhes.org/

http Live streaming to iPhone
http://forum.linhes.org/viewtopic.php?f=24&t=20589
Page 1 of 1

Author:  Too Many Secrets [ Wed Nov 25, 2009 7:40 pm ]
Post subject:  http Live streaming to iPhone

It should be noted the the below adds little to the current way LinHES enables iPod/iPhone streaming. The below is more proof of concept rather then practical use for most. With the latest iPhone software, apple is pushing HTTP Live streaming. It makes it possible to jump to the highest quality streaming video possible under ever changing cellular network conditions. What it also enables is the possibility of live video streaming as .ts files are supported. Streaming LiveTV to a cell is quite a killer app.

Refrencing heavily:

http://www.ioncannon.net/programming/45 ... segmenter/

Step 1 - Update ffmpeg

Seems ffmpeg needs to be upgraded from what is currently in use with standard R6 installs. From another board - "You must have the ffmpeg-devel RPM (V0.5-2 or later) and the ffmpeg-libs RPM (V0.5-2 or later) installed."

Solution pacman -S ffmpeg which installs some svn updates and your good to go.

Step 2 - Segmenter Install - wget http://svn.assembla.com/svn/legen/segmenter/

This is the bread and butter to the process. It took me a bit to get it to MAKE correctly, but that was due to the older ffmpeg version. Just update
Makefile to install: in correct directory (I used /usr/bin/). If the all: settings don't work, you'll have to tweak according to the above discussion.

I've lost my Makefile that worked for me.

From the commandline
#make
#make install



Step 3 - Updating webserver settings for streaming.

Edit /etc/lighttpd/lighttpd.conf to add under "mimetype.assign"

Code:
  ".m3u8"         =>      "application/x-mpegURL",
  ".ts"           =>      "video/MP2T",


While your here, you might want to make sure you have:

Code:
".mp4"          =>      "video/quicktime",


This last bit will allow you to stream from mythweb Myth2iPod page. Pretty SWEET!


Step 4 - html setup

In /myth/ipodfeed create iphonestreams.html

paste the below

Code:
<html>
 <title>iPhone Streams</title>
  <head>
    <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
  </head>
  <body style="background-color:#FFFFFF; ">
    <center>
      <video width='150' height='150' src="test-384.m3u8" />
    </center>
  </body>
</html>


edit /myth/ipodfeed/m2iweb.php and below <a href="/mythweb/status">Backend Status</a> insert:

Code:
&nbsp; | &nbsp;
<a href="/ipodfeed/iphonestreams.html">iPhone Streams</a>


This will link from the Myth2iPod page to the new webpage just created.


Step 5 - Encode

These settings work for a vob for me. Change the -b settings for different bitrates. Apple recommends 96 256 and 800. I find 384 good instead of 800, but adjust as needed.

Code:
ffmpeg -y -i /directory/to/vob/test.vob -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320x240 -vcodec libx264 -b 384k -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 384k -bufsize 384k -ac 1 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 test.ts


Now you have the encoded .ts file. Just need to break them up.

Code:
segmenter test.ts 10 test-384 test.m3u8 /ipodfeed/


This will take your test.ts and chop it into little 10 second bits.

Give it a try in your iPhone! yourip/ipodfeed/m2iweb.php
You should have another link after Backend Status | iPhone Streams
iPhone Streams will take you to a page with a video link displayed. I can't get a preview myself, if you figure that out, post.

Click the arrow and you should have video!


Now you should create streams with lower bitrates. Lather, rinse, repeat.


Just change the -b settings in the above ffmpeg script, say 96 or 256 or so. Run your segmenter script and again change the bitrate lable. When your done and have either 2 or 3 different bitrates of your file, create 1 last m3u8 file that points to all different bitrate options.

Something like the following:

Code:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=128000
/ipodfeed/test-128.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=384000
/ipodfeed/test-384.m3u8



Lastly edit the iphonestreams.html file to point to test.m3u8 or whatever you called your last m3u8 file.

Enjoy!

NEEDS: This is far away from production quality. The html code should reflect the mythweb template and standards. A script should be created to automate the encodes and segmentations. But both that and any LiveTV streaming is beyond my skills.

Author:  wmcvetty [ Wed Mar 17, 2010 10:20 pm ]
Post subject: 

I had issues streaming mp4's for some reason so I started exploring this. I have cloned the myth2ipod script to myth2ipod-stream to make the 384 file and modified the m2iweb.php page to show both the mp4 and the m3u8 filed with a link to either allowing me to stream the new file type. Works great on wifi.

Next I will:
- edit the script to make the lower levels and link the new file instead.
- have the script put all the segmented files in subfolders in ipodfeed
- modify the m2iweb.php page to delete all the related files when delete is pushed.
- live tv maybe?

I'll post my code once it is cleaned up, if someone wants it.

Walter

Author:  Too Many Secrets [ Thu Mar 18, 2010 12:13 am ]
Post subject: 

Good to see others wanting to stream to iPhone. Keep us posted wmcvetty. Especially if you make any headway on the LIVE TV!

Author:  wmcvetty [ Fri Mar 19, 2010 6:48 am ]
Post subject: 

Well, streaming works great over wifi, but no matter what I do I am having issues with streaming over 3G. Did your test run do ok with 3G or did you try it? So far I have tried anywhere from 100-25 for the -b flags with no change beyond quality. Over wifi hitting my external ip address I can watch the access log of lighthttp serve up the files fairly nicely. But on 3G it takes forever to get past the index file (or whatever it's called) and even longer for each segment. This causes pauses every few seconds on the recordings.

I've played with my ffmpeg line to no avail as of yet.

So, did you have better results for 3G?

Walter

Author:  Too Many Secrets [ Fri Mar 19, 2010 11:35 am ]
Post subject: 

wmcvetty wrote:
Well, streaming works great over wifi, but no matter what I do I am having issues with streaming over 3G. Did your test run do ok with 3G or did you try it? So far I have tried anywhere from 100-25 for the -b flags with no change beyond quality. Over wifi hitting my external ip address I can watch the access log of lighthttp serve up the files fairly nicely. But on 3G it takes forever to get past the index file (or whatever it's called) and even longer for each segment. This causes pauses every few seconds on the recordings.

I've played with my ffmpeg line to no avail as of yet.

So, did you have better results for 3G?

Walter


I can stream over 3G, but it's not ideal. It takes about 10-15 seconds to start a stream. Afterwhich I experience pauses and sometimes it just plain hangs. I think my problem could be my upload throughput, but haven't tested this. I like that it starts rather quickly, just can't get it to play all the way through without pausing.

As a comparison, when I play a transcoded recording from the myth2ipod page it seems to take a few minutes to buffer enough to begin playing. It then pauses about the same as the above.

Also I could never get a 'preview' pic on the video pic area, but this is way down on my list.

Perhaps I can drop the audio down a few bits on the 96k encoding to go out over 3G a little quicker. I'd like to see what over wifi but out of my local lan would do as well, I've not tested this either.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/