Re-streaming sopcast with linux to ipad / iphone using ffserver ffmpeg and segmenter.

I wanted to find a way to watch sopcast streams on my ipad, however there currently is no native ipad app for this.

Available for linux is the sopcast command line player – sp-sc-auth which works just fine, so all I needed to go was get this to my ipad. Fairly straight forward I thought as sopcast listens on a chosen port for you to connect a media application to – I tried it on my ipad with xyzplayer which worked fine for a standard def video stream, but with HD streams the picture would be in slow motion.

I tried a number of other players, but they all had the same problem. So I figured if I could re-stream the stream as h264 I could get quicktime to play it on my ipad, and that would sort the issue.

However – easier said than done!

I was able to get ffserver and ffmpeg to take the stream from sopcast and re-stream but again slow motion issues.

So I definitely needed to re-stream into a quicktime compatable stream.

So I started looking at the use of the open source conversion of apples segmenter. Looked great but had a nightmare trying to get live_segmenter.c to compile on my fedora system.

However after some digging it seemed the majority of my issues were with my version of ffmpeg.

Using these instructions I managed to get it to compile correctly:

wget http://epirat.de/wp-content/uploads/ffmpeg-export-snapshot-2009-12-02.tar.bz2
tar -xvjf ffmpeg-export-snapshot-2009-12-02.tar.bz2
cd ffmpeg-export-2009-12-01/
./configure --enable-gpl --enable-nonfree  --enable-libfaac\
 --enable-libmp3lame --prefix=/tmp/old_ffmpeg
make
make install
cd
git clone git://github.com/ePirat/HTTP-Live-Video-Stream-Segmenter-and-Distributor.git
gcc -v -Wall -g live_segmenter.c -o live_segmenter \
    -lavformat -lavcodec -lavutil -lvorbis -ltheora\
    -lbz2 -lm -lz -lfaac -lmp3lame \
    -I/tmp/old_ffmpeg/include \
    -L/tmp/old_ffmpeg/lib
rm -rf /tmp/old_ffmpeg
rm -rf ffmpeg-export-2009-12-01
rm ffmpeg-export-snapshot-2009-12-02.tar.bz2

I would love to credit the author but im unable to find a way too! So if you read this thanks, and drop me a mail for credit :-)

 

After getting this to compile, I followed the instructions http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/

 

Well couldnt get the script to work so stripped it out to manually run ffmpeg and pipe it into live_httpstreamer – however turns out my m3u8 index wasnt being created and my files were not able to be encoded as I didnt have x264 installed correctly.

So took this https://sites.google.com/site/linuxencoding/install-script to get the x264 support installed.

Manually created my own m3u8 index just to test that it would actually work.

Ended up with it all working, although the audio is going out of sync, but i’ll look at that at some point..

My final command, assuming I have created the m3u8 file with just 2 hours worth of segments, is…

/home/user/Linux.Encoding.install/bin/ffmpeg -i http://127.0.0.1:7070 -f mpegts -acodec libmp3lame -ar 32000 -ab 48k -async 1 -s 600×480 -vcodec libx264 -b 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 110k -rc_eq ‘blurCplx^(1-qComp)’ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 4:3 -r 30 -g 90 -async 2 – | /home/user/segmenter/live_segmenter 10 /var/www/html/video/ stream ipad

Any questions please feel free to post comments, I have pulled this together quickly so might well have missed something…

 

iPhone what is calaccessd?!

On the new iOS5 while debugging my poor battery life I came across a process on my iPhone called calaccessd which was hogging lots of CPU time and I felt it was responsible for my poor battery life – although no hard evidence yet.

Much googling turned up nothing however playing around I found that the daemon died immediately when I turned calendar off of notification centre and back to alerts rather than banner alert. I am hopeful that this will help the massive battery drain I have been experiencing and I will report back on this post.

Whilst it is nice to have my calendar stuff in the notification centre with the imminent release of intelliscreenX I can live without it for the moment if it gives me better battery life.

Cheers

iPhone iOS5 poor battery life

I recently updated my iPhone 4 to iOS5 but suffered from very poor battery life around 50% worse than previous on 4.3.3.

I put it down to spotlight re-indexing etc and ignored it for a few days, but after a week of still being rubbish I did some digging.

Although not conclusive, I noticed a process – calaccessd which was using about 40% of the cpu time all the time – obviously cpu time equates to battery drain.

After some more digging I discovered its related to the calendaring functions (yes slightly obviously given the name). Doing some debugging, I went into my calendars and unticked the iCloud calendar from my views – this immediately made the calaccessd drop cpu use to next to nothing.

So im hopeful this might have a significant effect on my battery life and put it somewhere back to where I expect it to be..

Any comments on this i’d be interested to hear.

Cheers!

 

update1 – checked my running processes a few hours later and irritatingly calaccessd was back using lots of cpu, so this time I have switched calendar off completely from my iCloud mail settings – this so far has stopped any resurgence of calaccessd using lots of cpu.

update2 – this has fixed the cpu runaways, but still experiencing very poor battery life, and very jerky and slow performance from the phone as a whole. Going for a full restore to see how it fairs after that..

update3 – did the full restore, again had fun and games with stupid itunes not recognizing my backup, but battery life is now back to normal, if not better! I had never noticed but each time i pick up the phone now it actually feels cold, which must be a good thing as if its warm its obviously using battery up!

I did choose to not install a couple of items I had previously installed, and have removed a couple of calendars also so not conclusive but its got to be one of the following :

poweralerter, sbsettings, iCloud syncing calendars etc, multiple exchange calendars from the same account (I had 4 calendars on my 1 exchange account, which I have trimmed down to 1 now)

So its either 1 of the above or just the restore, but either way im considering this case closed. Its also worth noting that its performing lovely too, the jerkyness has gone and its nice and nippy. All in all im happy :-)

update4 not happy again :-( as per the above update I thought it was sorted, however it seems not. See post what is calaccessd for a further update.

update5 – post on calaccessd gives full info on the bug on ios 5, however updating to ios 5.0.1 fixes this issue.