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…

 

You can follow any responses to this entry through the RSS 2.0 feed.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This blog is kept spam free by WP-SpamFree.