开发者

Convert Video to .flv?

Could someone please advise on what my options are when it comes to video type conversion in PHP. I have just discovered that our system uses something called ffmpeg. This isn't a problem but when a website is transferred it does create a problem as this absolute command breaks websites.

system ('/usr/bin/ffmpeg -i '.$video.' -y -f flv -qmin 5 -qmax 9 -ar 22050 '.DATA_DIR . $new_filename);

As you can see, a transferred website would require to have this path on their host and most don't.

So the question is this. I need to replace this. Is there some sort of PHP script or API that will make this 开发者_如何学Gowork?

Is there any option other than pinging our own servers with the video and our video sending back the video in the new format?

Thanks.


Is there some sort of PHP script or API that will make this work?

No. This is well beyond the scope of PHP. FFMPeg is indeed the household name for video conversion - the best thing is probably to stick with that.

One workaround would be to set up a conversion service script on a server that supports ffmpeg, and all the other web sites sending the material to that server (if file sizes and traffic rates allow.)


There is a php ffmpeg library, but you can just install linux version of ffmpeg in your application and change this directory


No, there are no native PHP alternatives to ffmpeg for transcoding videos, so you must work around that somehow.


As mentioned before, there is no PHP extension that does video conversion (the ffmpeg-php extension can not convert videos) - you will have to call something not in PHP to get the video conversion proper done.

I see two possible problems on the "transferred websites":

  1. If it is simply a path problem: look at this page for how to call ffmpeg - you should not have to include the "/usr/bin/" part in your command.
  2. If the problem is that you cannot install ffmpeg on the transferred websites, you can do two things, depending on which drawback is more acceptable:
    1. You may convert all videos to .flv beforehand, and serve them either from the transferred websites or from your own servers. Use that method for videos that will be watched often, or whose converted version will be watched often.
    2. The transferred websites will point to the video flux from your own servers, that will handle the on-the-fly conversion. Do that for videos that will not be watched as often.


Feel free to install ffmpeg into your home directory on your hosting provider; many, if not most, hosts allow you to install programs in addition to scripts.

However, please do not place this code on a production system. Or, any computer you care about. If some smartass uploads a video named

Puppy;/bin/rm -rf /;.avi

then you can kiss all your data goodbye. If it is named:

Puppy;`nc -l 11111`;.avi

then they have a shell they can use for whatever they please.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜