The company project needs to add a video upload to the project, and then generate a QR code to scan and play the function. I thought about a few questions:
1. How to control the duration and size of the uploaded video
2 , How to convert some common formats into MP4 control format
3. What should we pay attention to in terms of bandwidth and server?
高洛峰2017-05-16 13:16:41
First of all, pure PHP cannot complete this, you need to use video conversion tools, such as ffmpeg;
Secondly, video conversion takes a long time, and the traditional PHP running mode is not capable because it generally limits the script execution time.
Can be run in cli mode for video conversion (via ffmpeg).
Back to the question below.
1 The video size can be set through the maximum upload file size configuration item in php.ini.
2. To convert the format, use the ffmpeg tool and PHP to call it through the system command
3. Bandwidth corresponds to server and traffic volume one-to-one. It is impossible to tell the specific configuration directly. The bigger the better.
Finally, it is not a wise choice to put videos on the server now, because video processing is complex and consumes a lot of bandwidth. If the service and video are on the same server, it will affect the normal service. Therefore, third-party video services can be used, such as Alibaba Cloud and Tencent Cloud, which have corresponding services. And the cost and effect are much better than doing it yourself
迷茫2017-05-16 13:16:41
What you said above is more comprehensive. I also wanted to make videos before, but there seems to be no open source ones.
The biggest problem encountered in uploading is the problem of slicing upload. Kindeditor cannot handle it. I heard that Web Uploader can do slicing, but Baidu has been unable to find it for a long time.
I encountered a problem with the playback plug-in, so I found ckplayer, which is a good plug-in. However, it has many requirements, such as format support issues, and then the file size that can be played. And it’s hard to be as awesome as Youku Tudou
高洛峰2017-05-16 13:16:41
Use Tencent Cloud. Our company uses Tencent Cloud to do this function, and I am responsible for it. The video is directly uploaded to the Tencent Cloud server, then transcoded, and called back when the transcoding is completed. Personally, I feel it is less troublesome and labor-intensive than implementing it myself.
我想大声告诉你2017-05-16 13:16:41
For small videos, you can use the php-ffmpeg extension to handle video transcoding and obtain video information. If the file is larger, it is recommended to use a third-party cloud service. PHP transcoding takes a long time and takes up more resources