What should I do if the javascript-php video website server is very slow ??

Source: Internet
Author: User
Environment: php5.3.9Apache22mysql5.6. Several problems encountered when using xwindows for video websites (Local Environment Test): A. Dozens of videos. Uses canvas to capture the first frame of a video as the cover. {Code...} B. The first problem has been stuck ....

Environment:
Php5.3.9
Apache 22
Mysql5.6.x
Windows

Several problems encountered when using a video website (Local Environment Test ):

A. Dozens of videos. Uses canvas to capture the first frame of a video as the cover.

// Video source list var vSrcList = [src1, src2, src3...]; // The first frame of the video is captured in the queue mode (if the video is not captured in the queue mode, basically all the screenshots will fail ....) // even if the first frame of the video is obtained in queue mode, there is still a high probability that the first frame of the video will fail to be captured. // If you open the console network, a large number of requests will display pending... var dequeue = function () {var curItem = vSrcList. shift (); if (curItem) {// add it to the node on the page .. dequeue () ;}}; dequeue (); // gets the first video frame function getVShowPic (src, fn, opt) {var v = document. createElement ('video'); var cav = document. createElement ('canvas '); var ctx = cav. getContext ('2D '); v. currentTime = 1; v. addEventListener ('canplay', function () {if (opt = undefined) {opt = {w: v. videoWidth, h: v. videoHeight };} ctx. drawImage (this, 0, 0, opt ['w'], opt ['H']); var src = cav. toDataURL ('image/jpeg ', 1); fn (src) ;}, false); v. src = src ;}

B. The first problem has been choppy. The video is even more exaggerated during playback. Loading of the main video is always displayed, and all the covers of the video list fail to be captured.

Question 1: Is php not suitable for video websites ??
Question 2: Why is video websites like Youku and iQiyi running so smoothly?
Question 3: Are their video covers manually uploaded or automatically captured at the first frame of the video, similar to Youku ??, If a video is simply played, it won't be choppy. I just need to remove the code that automatically captures the first frame of the video, so there won't be any choppy videos...

Share the following URL:www.lysqdx.com

Reply content:

Environment:
Php5.3.9
Apache 22
Mysql5.6.x
Windows

Several problems encountered when using a video website (Local Environment Test ):

A. Dozens of videos. Uses canvas to capture the first frame of a video as the cover.

// Video source list var vSrcList = [src1, src2, src3...]; // The first frame of the video is captured in the queue mode (if the video is not captured in the queue mode, basically all the screenshots will fail ....) // even if the first frame of the video is obtained in queue mode, there is still a high probability that the first frame of the video will fail to be captured. // If you open the console network, a large number of requests will display pending... var dequeue = function () {var curItem = vSrcList. shift (); if (curItem) {// add it to the node on the page .. dequeue () ;}}; dequeue (); // gets the first video frame function getVShowPic (src, fn, opt) {var v = document. createElement ('video'); var cav = document. createElement ('canvas '); var ctx = cav. getContext ('2D '); v. currentTime = 1; v. addEventListener ('canplay', function () {if (opt = undefined) {opt = {w: v. videoWidth, h: v. videoHeight };} ctx. drawImage (this, 0, 0, opt ['w'], opt ['H']); var src = cav. toDataURL ('image/jpeg ', 1); fn (src) ;}, false); v. src = src ;}

B. The first problem has been choppy. The video is even more exaggerated during playback. Loading of the main video is always displayed, and all the covers of the video list fail to be captured.

Question 1: Is php not suitable for video websites ??
Question 2: Why is video websites like Youku and iQiyi running so smoothly?
Question 3: Are their video covers manually uploaded or automatically captured at the first frame of the video, similar to Youku ??, If a video is simply played, it won't be choppy. I just need to remove the code that automatically captures the first frame of the video, so there won't be any choppy videos...

Share the following URL:www.lysqdx.com

  1. The focus of video websites is on the CDN cache and bandwidth of videos. it has nothing to do with the language used.

  2. CDN is used by others. after reading it, you should be nothing more than an exercise. how can we compare it with others?

  3. After reading your description, I guess your so-called cover is read from the video every time. it's no surprise that it's not a card, A mature video website system processes offline videos after uploading videos, including not limited to the following operations (in an indefinite order ):

    • Standardized Video format (sometimes unstandard formats cannot buffer videos on the browser)

    • Compression into multiple quality video formats (such as low and medium, or 240 p, 360 p, 480 p, 720 p, etc)

    • Capture some frames as a preview image (n frames can be captured and then manually inserted in the background)

    • Watermarking (optional)

    • Upload to CDN

Video websites have high bandwidth requirements. It is not a server configuration. Live broadcasting has high requirements on servers!

Your operation
Is running in local js
No cards.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.