Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:34:26+00:00 2026-06-10T12:34:26+00:00

I’m using a php script to serve files to JWPlayer in order to prevent

  • 0

I’m using a php script to serve files to JWPlayer in order to prevent leeches from getting the URL and using it in their iPhone and Roku apps. So I call videoplay.php?id=myfile . The output is a mp4 video stream. Files are typically 200-500MBytes.

The php script works correctly and with some tweaking it even performs much better than the initial version I had. But it is a resource hog. When I am streaming one file, I can’t open another window in my browser to any page on the same website…I can’t even display source of the current page. If I play exactly the same video files by giving the url directly to the player I have no resource hog problems and I can view source of the page while the video is playing, and play two videos from the same website simultaneously in the same browser (on two different pages).

Here is my code

// some code to query database and get the file url
//
$fh = fopen($filename, "rb") or die("Could not open movie\n");

while (!feof($fh) && connection_status() == 0)
{
  print(fread($fh, 1024*8));
  flush();
  ob_flush();
  usleep(10000);
}

fclose($fh);

I added the usleep to try to limit resource usage and it didn’t work, but videos seem to load faster. When I make usleep much longer (e.g. 1/10 sec) videos take much longer to load. If i vary the chunk size between 1024*4 and 1024*16 the 8kbyte seems to result in fastest load times for videos. 16kbyte uses even more resources and seems to max out my 25MBit connection. Videos won’t load at all from my local server (but remote videos on our cloud server do load). Reducing the chunk size to 1kbyte didn’t solve the resource problem.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:34:28+00:00Added an answer on June 10, 2026 at 12:34 pm

    It’s probably all because of you’re missing out the use of session_write_close(). Add the function call to the start of the streaming. Session lock may be the reason why your scripts because the scripts are waiting for each other to finish before they continue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.