Let's say i have this file-sharing website script but you see, all it
does is share files, like PutLocker.com , i want it so that if a file
with an extension like ".mp4 or .mpeg etc" is uploaded, it uses your
player to stream the file instead of just having shared...
For example:
Jim's wants to start a website, but he is weak at coding. So he gets a
file sharing script.
But the file-sharing script does just that, share files! Jim wants
people to be able to stream their video files aswell, and if happy
worm's player allows him, stream just audio too!
So a user uploads to his website a regular folder, the link is shared,
the script is working fine. But then a user uploads a .mpeg video and
Jim does not want his website to just share the file, he wants his
script to allow users to automatically stream the video file using
Happy Worm's jPlayer and give users an option to download.
I hope you're not lost, believe me i've read the documentation. Should
i just slap the player's source code in there or is there some lines
of code needed to tell it that it needs to stream using that player?
The script i am talking about is X Filesharing pro
I can link you to the php code i have if it would help better...
Thanks...
PHP runs server-side, it won't play media. (Just like physics, you simply can't.)
There are various solutions to deliver media, but the most widely used is Flash.
JWPlayer from LongTailVideo is perfect for what you need, both audio and video.
The documentation is comprehensive and the player itself has lots and lots of cool extras, such as:
buffering
a JS API (for HTML styling)
For thumbnails from video files you'll need third party tools (ffmpeg) installed on the server, some degree of technical knowledge and access to the exec() function in PHP so you can run command-line tools via PHP and output results.
Related
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.
I have a website that allows users to upload videos to it,
After they upload videos, I would like to be able to display them using a flash player.
One flash player i know is flowplayer, althrough if anyone knows a better one I will be happy to know.
In any case, as I understood from a brief google search, there are no players that can play .avi/.mpeg files, but they can only play .flv files.
I began searching for ways to convert my user's avi's/mpeg's and found that I can use ffmpeg to convert the video to .flv using system().
Is this the best solution for me? I feel like ffmpeg takes a lot of CPU and once I have enough users the server will crash..
Thanks!
Just an outline
(Note: i don't own nor wrote a PHP video sharing site, so treat these like tips)
Set up your web server and PHP to be capable of accepting large files via HTTP
Let users upload their videos via a web interface
Upon successful upload add uploaded video to a queue
Set up a fully server side script that handles video processing (No PHP)
Run a cron job on this queue when your server is able to crunch uploaded videos
Notify users when videos are done
Hope it helps in some way.
I'm searching the best way to do what I'm trying to do, so I ask here... I have a webpage in PHP who's requesting a song by TCP to another server. The song is loaded into a temporary file on the server. While it's loading, I want to play it into the webpage OR into the user's favorite player. Is it possible to simply refer the file to the player, even if it's not fully loaded ?
Thanks !
EDIT:
I found a great open-source player named JW Player, seems to be able to do what I want, but I'm not sure how ...
its a little hard to understand what your asking.
PHP Does not have threads which will limit you in multiple tasks, but it is possible to do so
the problem is that if your fetching the file in the same php file that loads the player as a webpage then your going to have issues.
you will have to resort to several php pages to complete the task
Firstly the suer requests to the server the song he wishes to play, you will have to use ajax to infrom the server of the id, so you would ping a script on your server saying LOAD VIDEO ID XXXX in which that script starts downloading the video, you would then active the player to call another file that would read segments of the partially downloaded file and output it to the player.
it will get very complex and possibly very error prone, your best bet is to stream directly from server2
Yes possible but you should indicate size of file truely
I have a flash .swf file that I embed on my webpage. On my server I have the .swf file and multiple image folders. I would like to load every file in one of those folders into the flash slideshow. How should I go about doing this? I tried used Air but it doesn't work on my system as an application so I doubt it will work online. Eventually I plan on making a menu where you can select different folders to display and since they are of different sizes, a foreach loop would be optimal. Keeping a txt file with the number of images is also possible if theres a way to read that in, but I would prefer the more dynamic approach. I am working towards using php for the website if that helps find a solution.
Thanks,
-Mike
Also my slideshow works great online currently but i have to hardcode in the number of files.
I would suggest to have a PHP script on your server that takes care of parsing those folders, and return the list of files to Flash (with a valid public URL).
Basically at your application startup, you would call the PHP script to retrieve the full list of file (XML is a good format to be returned, or AMF if you have a lot of folders/files).
After all you have to do is manipulate that data to load whatever folder/files the user is willing to see.
Just for your information, Flash doesn't have access to the Filesystem, so it's impossible to parse folders directly from Flash. (However It is possible with an Air Application)
I need to stream an flv file.
Streaming should look like live streaming,
and I there should be a way to change the target file.
Sorry for my poor English.
If by "streaming" you mean "showing a flash-video clip", flv-streaming isn't really streaming, but it's a normal file transfer, with the flash player starting playback even if the file isn't completely downloaded to the client. Time seeking is implemented in a standard HTTP way, with a file download offset - if you scroll the video halfway on the timeline and it hasn't downloaded yet, the current download is (most often) aborted, and restarted with an offset of filesize/2 bytes.
So, you could be fine with just using plain old readfile() and fixing the HTTP mime-type headers appropriately with header(). But, since you'd need seeking, you need to parse the HTTP request and instead of readfile(), use fpassthru(), seeking the right place, instead.
tl;dr: Avoid handling this on the PHP side, and let Apache (or the httpd of your choice) handle this instead.
I'm not quite sure what you're asking about, but if you have a bunch of media files and want to play them with a Youtube-esque media player on your website, I suggest checking out Flowplayer - It has an amazing Javascript API that lets you do all kinds of cool stuff to the player, including handling stuff like playlists and programmatically changing the current video.
I recently used it on a project with great results.