Stream a Recording or prebufferd Tv Channel with Mars
Ok before you read on I will say this was just something I did for fun and you might or might not find it useful but it works for me.
Why is this useful?
Maybe you have a handful of friends that are watching crappy iptv streams for a big fight or football match and you want to help them out.
Here is how it works.
Say something cool is on tv (Won't say any channels names ) and we book a recording from the epg on the Mars box that will save the file to our usb stick or usb storage.
Now because I set my Mars to save recordings to /mnt/sda/sda1 <--- [my usb storage connected to Mars box] a .ts file will start saving the live recording of the TV channel to this file.
Because we have an ftp server running on the Mars box FFmpeg can stream the .ts to file to FFserver.
FFmpeg sends streams to FFserver and encodes them on the fly if needed
FFserver then allows multiple users to access this stream via http.
How many clients FFserver can stream to is down to your upload speed and the bitrate the video is being streamed at.
Things needed
1. Mars Box
2. Android Ftp app
3. Something running ubuntu 14.04 (I'm using 14.04 64bit)
4. ffmpeg.zip setup.sh ffserver.conf
Lets begin
Start up ubuntu
sudo -i <--- Login as root to make things easier
copy ffmpeg.zip setup.sh ffserver.conf to /tmp
chmod 755 /tmp/setup.sh
cd /tmp
./setup.sh
This is going to take a long time to build and install so be prepared for long wait.
When it's finished you will have ffmpeg and ffserver installed.
Now we move to the Mars box and install the Ftp server apk
Goto settings -> Home directory -> Custom Folder
Now Click Custom Folder and find your usb device that you are recording too.
0e1e809990645e94ab82557f.jpg
40fde1da96b79602c351a7be.png
Press the big red button
Take note of your ip address and port.
Ok so far so good the ftp server is now sharing our usb storage from the mars box.
Next thing we do is make sure the Mars box is setup to record to our usb storage so go into:
Mars Tv
Press Menu on remote
Goto Settings on far right
Click PVR Settings and select your usb storage mine is /mnt/sda/sda1
DONT USE /mnt/sdcard because you will fill up your internal storage on Mars box.
Ok now everything is ready to go and you are ready to start streaming your recording.
If you want remote users to watch the stream you will need to open a DMZ on your router and point it at your ubuntu machine, my laptop is 192.168.1.75 on the local network so I go into my router settings and create the DMZ to point at this address.
So the big fight is starting and the box is recording to the .ts file on your storage and you let the file build up for about 10 mins so it is a nice size. if we don't allow the file to get to a certain size FFmpeg will stop sending data to server because it will have reached the end of the file so thats why it needs to be big. Yours friends stream will be 10-15 mins behind but hey better than nothing.
start your ffserver
ffserver /etc/ffserver.conf &
Ok your recording is now at a nice size so ffmpeg wont chew up quicky, open up firefox broswer on ubuntu and type:
ftp://192.168.1.142:2221 <-- change this to ip on the ftp app on your Mars box
This will show the list of files on the usb storage, now copy the name of the .ts recording.
Open another terminal and type this:
ffmpeg -i "ftp://192.168.1.142:2221/BBC NEWS-20160919_22-32-59.ts" http://localhost:8090/stream1.ffm
Congrats you are now streaming a delayed live channel to your friends.
Another useful thing you can do with FFmpeg is restream a stream
Say you are paying for IPTV and you have a direct link that only allows a single user to watch at one time well now you can use FFmpeg & FFserver to stream this to your friends and the IPTV provider knows not different plus its not using the IPTV providers bandwidth.
Here is how to do it
ffmpeg -i "http://mycooliptv.media.com:8080/flysports.ts" http://localhost:8090/stream1.ffm
How can my friends watch the stream
First get your remote ip > goto google type whats my ip and it will show it.
so say my remote ip is 123.222.333.444
I will give my friends this link http://123.222.333.444:8090/test.ts
They can then enter this in the MxPlayer, Vlc player or the software of their choice
Cheers