I need to make a live streaming webcam application from my php server to a php page. I could either take frame by frame pictures using flash and somehow convert them to video files and stream it through or bundle the images together, compress them, and outputting it on a web page. any help with php methods to convert images to videos and outputting them on a web page?
I could either take frame by frame pictures using flash
I did this once. Result? An awful, CPU hogging mess. It worked, no doubt about that. But it was terrible. Because the images had to be encoded every 500ms (half a second), my CPU (Intel i7 4 cores) went up to 70% in usage. So I suggest you stay away from that method unless of course, you want your users to kill you?
I would suggest taking a look at the Flash Media Server. It's not free but there is a free trial for you to try. Here, take a look at this.
Related
I've been looking around and it does not seem like it is possible with Flash, but is there any way to compress a video file from a mobile device then upload it to a server? Right now some of my videos are too large (30 mb for 15 seconds) resulting in long upload times. Everything seems to point to ffmpeg but to implement ffmpeg you have to use the NativeProcess which isn't allowed on mobile devices. Is such a thing possible on the server side via PHP or only client side? or should I switch to something like Xamarin instead of AS3.
Thanks!
I basically need to record a video of the flash stage, and save it as a video file on the webserver. I don't have FMS or the luxury of Java based servers like Red5 to stream to, so I am pretty much stuck with HTTP post to a php script. Now I can grab invidual snapshots (bitmapDatas) Just fine, but how can I convert them to a video file? Any help is appreciated.
PS: This is not an AIR app, so I am using flash runtime. And the video would be couple seconds long so there shouldn't be much of a performance concern at this point.
Flex provide a JPEG encoder. You can use that to compress the bitmap images and send them to the server, where you can that stitch them together using ffmpeg.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/graphics/codec/JPEGEncoder.html
I was thinking of using imagemagick to process images uploaded by a user in various ways (creating new images that are scaled, have drop shadows, etc.) but I've been worried about the speed. I don't want the user staring at a loading gif forever.
So I started looking around to see how other sites do it and I found http://www.redbubble.com. Users upload artwork and almost instantly there are tons of variations of the image in the shop processed in various ways. What does it use to process and generate images so fast?
it's relatively hard and inconvenient to maintain client-side image processing (it would be some kind of flash app similar to www.picnik.com with limited functionality)
I see use of ruby, nginx, remote xhr calls, json etc. that means that delayed_jobs/resque might be used to schedule asynchronous image processing using imagemagick, json/xhr to check the status. processed images are requested from ih*.redbubble.net (point to edgecastcdn.net) and seems like they produce them on the fly and let CDN cache them until user changes that image or it expires in the cache.
they have ~800k monthly visitors, you don't want to put load on app/web servers to process images, there is either delayed_jobs or resque behind the scene or ih* (image host?) servers that produce images on the fly (there are 4 of them, but who knows how many behind virtual host/proxy configuration)
all upload requests go to amazon (ec2, that might be a load balanced IP), originals are stored on amazon s3. they can scale by requesting more ec2 instances on demand.
hope you get an idea what's behind... back to your question: no client-side images processing, imagemagick is used, and there is a chance they do it on the fly.
We've currently developed an ExpressionEngine site (php), and are using a paid JWPlayer to display video uploaded by the client.
At present we're running into a number of issues, as the client is:
Uploading video at the wrong size
Uploading video randomly in both flv or mp4 format
And the player is chugging along terribly with multiple pauses throughout the video - sometimes buffering the entire clip before it is played.
I know FFMPEG can be installed serverside, but I'm not sure of the way in which to go about this, and how it might interact between ExpressionEngine and JWPlayer. I'm also not sure about the formatting - the ability for this automated encoding process to also crop/resize the video to suit the player dimensions on the site.
We would really like to have the videos playable on all browsers & iOS devices.
A HQ option would also be great where applicable, but it's just a nice to have - as we're struggling with the formatting / encoding issues first and foremost.
Any help figuring out the best process, and what tools I might need would be greatly appreciated.
I'd reccomend using a service like zencoder
I've used them in the past and no matter what video format I've thrown at them it works great. (PS. I'm not affiliated with them at all)
There is a PHP API with a whole lot of resizing, quality and format options. After you've uploaded your video you can send it to zencoder and they'll send you a response some time later with success or fail.
They can put the processed video on Amazon S3 or FTP it to a server.
You'll need a HTML5 player for iOS devices though, unless JWPlayer has come a long way since I used it last.
You could get zencoder to output in mp4. and then you still only need mp4 for JWPlayer/flash and the HTML5 version for iOS, as long as your happy to use flash for all desktop browsers there's no problem.
As far as the buffering issues you are having - I have found that using a CDN version of the swf for JWPlayer (or whatever player you are using) has caused it to load the entire video file before playing. Easily fixed by hosting it yourself.
I have found many times the video conversion capabilities of different CMS to be limited, and often restricting video formats to what the developers thought was appropriate, such as FLV, which nowadays is turning obsolete for video delivery.
One of the ways you can approach it is by creating a custom script to process the videos uploaded by your client using FFmpeg, which in fact can accept almost any video format, and generate the correct output formats and dimensions, ensuring that the resulting videos will be suitable for web playback using your player.
The problem with the video buffering you are facing is because the video file is not prepared for progressive download or pseudo-streaming, so your browser needs to download the whole video before starting to play. This can be solved with programs like qt-faststart for MP4 and MOV video files, and flvtool2 for FLV files. So your script would need to also optimize the encoded videos using these tools.
Also note that if you use an HTML5 video player (browser native or recent JWPlayer), then you can enjoy from random seeking the video files without buffering them.
If starting from scratch is not an option, you can look into a commercial solution like tremendum transcoder which also uses FFmpeg and is quite simple to use, yet it does all you need in regards to dealing with different input formats and aspect ratios automatically.
I have done a few setups this way, separating the CMS part from the video processing part, and it saved me some headaches.
We have developed flash video player which needs to playe large videos (at least 500 MB videos).
We have some issues in the player right now.
I am playing a 100 MB + video, it start playing and say it is buffering upto 50% of that video. Then I am closing that page. If I take that video again, it starts downloading from beginning. It never resume downloading from where it buffered previous time. But for small video files, this is looking ok. Is there any size limit a video player can buffer? or any other issues. Please share your thoughts
Is there any better way to play large videos (more than 500 MB). Any other protocol or any other settings in flash player? Please give your valid suggestions here also...
If streaming video is out of the question (eg servers are expensive) you may also try a modified-progressive download. The server basically takes the browser request and cuts a specific version of the video which it then sends to the user's browser. I know there are extensions of this for various popular servers. Infact, this is very similar (if not , the same) as what youtube uses.
Some references to gawk at:
Mod H264 Streaming for Apache
FlowPlayer Pseudostreaming
Serving up a video file using php