Thursday, May 15, 2008

3GP streamming

http://www.torrentocracy.com/blog/archives/2006/05/streaming_mytht_1.shtml
http://www.mythtv.org/modules.php?name=MythFeatures

เอ้อ.. ก็มันเป็น web browser นี่นะ ก็เลยเปิด streamming ได้
บน Phone แต่ไม่รู้ว่า OS อะไร

เป็น 3GP



Streaming MythTV to your cell phone
Electrical tape wearing thin holding together my old cell phone (Samsung i500), I decided it was time to give in and upgrade to a new phone. I drank the kool-aid on a 2 year Sprint contract given the discounts both on the phone and in my monthly service, and in the end settled on the Samsung a920. It's an EVDO enabled phone with Sprint's $15 unlimited monthly data service. Playing around with the mobile TV functionality (that's an extra $10/month but I was enjoying the first month free), I had one of those lightning bolt moments.
Why not stream my own video to the phone? Better yet, why not just automate my MythTV to convert my recorded programs and automatically have them ready to be streamed whenever I care to watch them on the phone?
A bit of research later, I discovered SlingBox can stream your tv to your phone, but it needs to be a Windows mobile phone and then there's the monthly service fees and the box to buy. I also found random mythtv devotees with similar ideas at least as far back as January 2005, but couldn't otherwise find a concise guide or more information. Inspired by ZooVision, I knew it was possible for users to stream their own content to their phone, it was just a matter of putting the pieces all together. A couple hours of tinkering later, and I've got a working solution... my "tivo" on my cell phone wherever there's sprint evdo access. So here are the steps:
Get MythTV up and running. I won't go into that, but it's worth the hassle even if I couldn't stream it to my cell phone.
Follow these directions which will get you an updated version of ffmpeg (named ffmpeg3gp) and a myth3gp script which, in combination, allow you to take Myth recorded video and convert it to 3gp, a mobile video format standard that most multimedia phones support. However, instead of using the myth3gp script from there, you'll likely want to use this myth3gp script as I've included a couple of necessary changes. Save that txt file as /usr/local/bin/myth3gp on your Myth box.
Create a directory to hold your 3gp videos on your Myth system. Open up the myth3gp script from the previous step and change the line that says: out="/mnt/drive2/myth3gp"to: out="/directory/for/saving/your/3gp/videos"
Install gpac. Once you've compiled and installed gpac, it will provide you with an executable called MP4Box which is used to convert the 3gp file from step two into a 3gp file that is streaming enabled. The myth3gp script calls MP4Box to take care of this for us.
Find an internet connected server which can house your 3gp videos and be available to stream them at will to your phone. On said server you'll need to install Apple's Darwin Streaming Server. Installing it can be a bit of pain, but just be sure to have port 554 open so that it can handle the rtsp streaming protocol. For me, getting Darwin to work took the most effort. If your MythTV box has a static IP and is internet accessible, that should work fine, but in my case I'm uploading the videos to another server.
We're in the homestretch. We've got programs to convert Myth recorded video to a phone friendly format, and we've got a server that can stream them to our phone. We just now need an automated process to convert the video and upload it to the server running Darwin and we'll be in phone tv nirvana. Myth can do this automation for us. You'll need to exit out of Myth and run: mythtv-setupFrom there, choose the "General" menu item and hit enter until you get to the "Job Queue" screen. Put a checkmark in "Allow User Job #1 jobs and continue to the next screen until you get the page with label "User Job #1 description". Give it a description like "Myth 3GP" and for the command, use (note the quotes): /usr/local/bin/myth3gp %DIR%/%FILE%
"%STARTTIME%~~~%TITLE~~~%SUBTITLE%"Save your changes, exit, restart the mythbackend and restart Myth.
With Myth restarted, go into Utilities / Setup -> Setup -> TV Settings -> General and click through until you get the "General (Jobs)" page. On this page, put a check in the checkbox next "Run User Job #1 On New Recordings". This will ensure that our process gets run after each new recording. Important Note: For all existing recurring recordings that you had prior to setting up Myth3GP, you'll need to manually edit the recording options and in "Post Recording Processing", you'll need to switch its setting so that it says "Run 'Myth3GP'".
If your using your local Myth system for Darwin streaming, just be sure that Darwin knows where to find the 3gp files on your system. Otherwise, edit the myth3gp script from step number two and set the darwin_username, darwin_hostname and darwin_dir as appropriate for your external server. At the bottom of the script, it uses scp to transfer the file from your Myth system to your Darwin server. Though, for everything to be automated, you'll need to set up scp to not require a password. Directions for password free ssh/scp are short and sweet. Once you can transfer files between systems sans password, you are good to go.
The final step. On your Darwin machine, make sure you have a web server running (apache), php installed and place this php script somewhere in a web accessible folder. It's job is to scan your 3gp movie folder for movies and generate a webpage with rtsp:// links so that you can access your recordings from your phone. Edit the php script and change $directory to the directory path for your 3gp videos and set $hostname to your hostname. With that installed, you're done. You can manually convert your old recordings by starting the "Myth3GP" job on them and any new recording will automatically get the mobile treatment. Fire up the URL for the mythmobile php script and start streaming.
Triumph. Indeed some beautiful uses of fair use. Fair use to record the tv program to my hard drive... Fair use to convert the video format to one viewable by my cell phone... Fair use to stream it to my cell phone for my own personal enjoyment. Now imagine trying to do any of this with the broadcast flag in place.By Gary Lerhaupt, 03:51 AM in general Comments (0)

4 comments:

Anonymous said...

In my opinion you are mistaken. I can prove it. Write to me in PM, we will discuss.

Anonymous said...

It is remarkable, it is very valuable piece

Anonymous said...

It is remarkable, it is very valuable piece

Anonymous said...

The theme is interesting, I will take part in discussion. Together we can come to a right answer.