Author Topic: Downloading large video files  (Read 18115 times)

0 Members and 1 Guest are viewing this topic.

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Downloading large video files
« on: April 14, 2007, 01:24:16 PM »
Hello all,

i am building a huge video download page using 4images. The size of those videos ranges from a few KB to 1GB.
Downloading the smaller videos is not a problem but as soon as i want to download a 600MB file for example it takes a long wating time until the save as window appears. also my serverload goes vers high (100%cpu) and blocks the all the site for that time (3Mhz pentium, 1GB ram). sometimes that window appears at the end, sometimes i receive a 500 error

i have now spent a few hours in this forum searching for a solution. it seems that this is a know problem with 4images but the fixes i found don't work my the new 1.7.4.
some people told me by modifying the download.php they can download now 10gb files without problems.

i already changed the php.ini file to allow big scripts and i am now looking for a fix to :
-allow download of any file size
-reduce serverload after download button is clicked.

any help would be greatly appreciated.

Offline Acidgod

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.420
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: Downloading large video files
« Reply #1 on: April 14, 2007, 01:31:38 PM »
try the search... you are not the first one with this issues...

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Downloading large video files
« Reply #2 on: April 14, 2007, 01:42:04 PM »
that's what i actually did for several hours this morning.
unfortunately the fixes were only for 1.7.1 or didn't work or were only for remote hosted files...
there are some people who said that they found a solution but they didn't post them in this forum. maybe those people can give me a clue?

Offline Acidgod

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.420
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: Downloading large video files
« Reply #3 on: April 14, 2007, 01:54:23 PM »
try to ask them (PM)... (o:

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Downloading large video files
« Reply #4 on: April 14, 2007, 07:52:12 PM »
try to ask them (PM)... (o:

ja das hab ich gemacht, die waren aber seit mehr als 6 monaten nicht mehr online, da hab ich also wenig hoffnung.
ich kann also nur beten, dass jemand anders hier das problem gelöst hat...

Offline Acidgod

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.420
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: Downloading large video files
« Reply #5 on: April 14, 2007, 07:54:14 PM »
ivan hatte das selbe problem, hat er noch keine lösung?

Offline ivan

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.279
    • View Profile
    • Bilder Gallery
Re: Downloading large video files
« Reply #6 on: April 14, 2007, 11:04:41 PM »
hallo rescue...
seit 1.7.1 funktioniert der download bei grossen dateien nicht so gut.
ich habe das ganze mal jan gesendet und es sollte bei der neuen version
dann behoben sein.

die neue version sollte in ein paar wochen da sein (1.7.5)

jetzt hoffen wir, dass jan gut arbeit leistet ;) und das download script anpasst

p.s @ acidgod

wünsche dir gute besserung, hoffe es kommt mit deinem rücken wieder gut
greetings / grüsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery

Offline J.Lond

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Downloading large video files
« Reply #7 on: April 15, 2007, 05:26:30 AM »
I have similar problems as rescue911 and can't wait to here the outcome.  By the way, what changes in php.ini have you made (rescue911)?  My users are unable to  download files larger that 30 mb.  Thanks.

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Downloading large video files
« Reply #8 on: April 15, 2007, 11:35:45 AM »
made some works since yesterday :

the changes in php.ini are mostly for uploads but also to allow a big script to be executed :
max_execution_time = 60
max_input_time = 60
memory_limit = 51M
post_max_size = 51M
upload_max_filesize = 50M
so now people can upload files until 50MB

also i changed all "getimagesize" in functions.php by "filesize". before i did that when i went into categories with large files it took a long time until the page was showed but with the change it is much faster, sometimes instantly now.

another change that i made was replacing the complete download.php by a script that i found here in the forum which is http://www.4homepages.de/forum/index.php?action=dlattach;topic=10755.0;attach=334
so what happens now when clicking the download button : cpu goes to 100% again and it still needs time until the download window appears, just like if the file needs to be prepared first for download. BUT the download works (even if you have to wait) AND the server is not blocked anymore so that other visitors can still visit the website.

so maybe some one has an issue on resolving the wait and cpu problems?
also is it sure that Jan will make the appropriate changes?

edit : unfortunately while downloading a big file you cannot do anything else as the script doesn't answer anymore for a while.
« Last Edit: April 15, 2007, 06:14:32 PM by rescue911 »

Offline J.Lond

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Downloading large video files
« Reply #9 on: April 16, 2007, 04:00:17 AM »
Thanks for the post rescue911.  Hopefully in version 1.7.5 changes will be made to help support video files more.

Best Regards,

Jason

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Downloading large video files
« Reply #10 on: April 16, 2007, 05:38:56 PM »
just tried to activate the cache but apparently with all those changes i only get a blank page...frustrating... :evil:

Offline rescue911

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Downloading large video files
« Reply #11 on: April 17, 2007, 11:27:29 AM »
ok it's me again ;-)

the cache problem was just because of a htaccess error....

i could solve another problem related to the page blocked while downloading big files.
i found the solution here : http://www.4homepages.de/forum/index.php?topic=12013.30
just add session_write_close(); to the code as explained on page 3 in that topic

still looking for a way to reduce the serverload and cpu. any idea how to prevent the files to be loaded in cache/memory before being downloaded?

Offline dave

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Downloading large video files
« Reply #12 on: June 30, 2007, 09:28:17 AM »
Hi rescue911,

I had the same problem with version 1.7.3 and came across your thread yesterday. I fixed it by using PHP's native readfile() in download.php's send_file(). But I have to admit, that my knowledge of PHP is quite limited, so I don't know the pros and cons of the original code compared to readfile(). Therefore I'm just using this function just in case the filesize exceeds MAX_SHOWVIDEO_FILESIZE (defined in global.php).

Anyway ... it seems to work for me. If you want to give it a try ...  :wink:

Ciao
Dave

download.php:
Code: [Select]
function send_file($file_name, $file_path) {
  # [DAVE_START]
  $file_size = @filesize($file_path);
  $big_file = $file_size >= MAX_SHOWVIDEO_FILESIZE; 
 
  if(!$big_file) {
    $data = get_file_data($file_path);
  }
  # [DAVE_END]

  @session_write_close();

header("Cache-Control: no-cache, must-revalidate");
  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

  if (get_user_os() == "MAC") {
    header("Content-Type: application/x-unknown\n");
    header("Content-Disposition: attachment; filename=\"".$file_name."\"\n");
  }
  elseif (get_browser_info() == "MSIE") {
    $disposition = (!eregi("\.zip$", $file_name)) ? 'attachment' : 'inline';
    header("Content-Disposition: $disposition; filename=\"".$file_name."\"\n");
    header("Content-Type: application/x-ms-download\n");
  }
  elseif (get_browser_info() == "OPERA") {       
    header("Content-Disposition: attachment; filename=\"".$file_name."\"\n");
# [DAVE_START]   
    //header("Content-Type: application/octetstream\n");
    header("Content-Type: application/octet-stream\n");
# [DAVE_END]   
  }
  else {
    header("Content-Disposition: attachment; filename=\"".$file_name."\"\n");
    header("Content-Type: application/octet-stream\n");
  }
  # [DAVE_START]  
  if(!$big_file) {
    header("Content-Length: ".strlen($data)."\n\n");   
    echo $data;
  } else {
    header("Content-Length: ".$file_size."\n\n");
    readfile($file_path);
  }
  # [DAVE_END]
}


Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.408
    • View Profile
    • 4images - Image Gallery Management System
Re: Downloading large video files
« Reply #13 on: February 08, 2008, 09:32:53 AM »
The issue has been solved in 4images 1.7.6:
http://www.4homepages.de/4images/download.php
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search