简体   繁体   中英

How to serve video content from PHP server to iPhone and Android devices?

I'm writing an app for both Android and iPhone devices. The app uploads a base64 encoded string of a video to a PHP server and stores the encoded string in a MySQL database. Obviously, I would like the videos to have the ability to be played on both the Android and iPhone versions of the app simply by requesting the web URL along with the ID of the video to be retrieved. So far, I've verified that the base64 encoded string of the video is successfully being sent to the PHP server and stored in the database.

I'm just unsure of the proper way to serve up the decoded version of the video through PHP so that it can be viewed through the app on both Android and iPhone devices without compatibility issues. My assumption is that the approach would be similar to how I'm serving base64 encoded images that are stored in the database with a few differences such as the type of header specified in the PHP code and the specific PHP command that serves up the video after it has been selected from the database and decoded.

Can anyone tell me if I'm on the right track here? Are there any lessons learned that anyone can provide?

I'm able to successfully play the video on the following link in iPhone, but I haven't tried it on Android yet:

http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v

I've read through a lot of information, but some of it appears to be dated a while back and I'm concerned about the relevance of the information still being legit. Here's an article I found from 2008 http://mobiforge.com/design-development/content-delivery-mobile-devices

Any help or points in the right direction is very much appreciated.

First, start with the most compatible type of video: mp4 with h.264 encoding and aac audio.

The mp4's should be "optimized" which means some important control and information blocks are placed at the front of the file which will allow playback to start almost instantly. Otherwise you end up downloading the entire video before playback starts and viewers don't wait

Then in your php program just respond to the video request with the video file and it will play using progressive download.

If you want the viewer to have playback (shuttle) controls you will have to use mod_h264 or some similar add-on to respond to requests for forward or backward seeks. Apple devices may require this mod to play properly and handle the byte-range requests.

Without progressive download it gets more complicated (RTSP for Android and HLS for iOS).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM