1

I'm building a video converter for someone. All I need to know is, When someone pastes in a URL to a video, how can I download that video to the server? Anything here would be helpful.

TRiG
  • 10,148
  • 7
  • 57
  • 107
Jordan Schnur
  • 1,225
  • 3
  • 15
  • 30

2 Answers2

2

If you want to use it in php try curl:

function curl_download($Url){

    // is cURL installed yet?
    if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;
}

[Source]

rekire
  • 47,260
  • 30
  • 167
  • 264
  • After this, how would I upload the downloaded content to the sever? – Jordan Schnur Oct 26 '12 at 21:29
  • I was expecting that you download the video on the converting server. You may need to copy the video to the converting system... But this depends on your network configuration (including operating systems). – rekire Oct 26 '12 at 21:30
  • I like it, but I need to know more. How would I copy it to the server? – Jordan Schnur Oct 26 '12 at 22:03
  • Again you need to tell us your operation system... you may can do this with the php [`copy`](http://php.net/manual/en/function.copy.php) command or with a shell command. E.g. `copy source.avi \\target-server\share` or for linux `scp source.avi user@target-server:/target/path`. But if you have trouble to copy files I'm really not sure if you are able to convert videos. This is a quiet complex topic. I know it I'm converting videos in *realtime* for a website. – rekire Oct 26 '12 at 22:06
  • The user doesn't have there operation system yet. I assume Unix. – Jordan Schnur Oct 26 '12 at 22:30
  • Also, this does not seem like it's downloading it. It just seems to echo the files contents. – Jordan Schnur Oct 26 '12 at 22:48
0

What kind of video? If you have the actual video sources then this is your best bet: download-file-to-server-from-url

If you do not, then chances are you will have to write your own video ripper such as http://keepvid.com

Community
  • 1
  • 1
stackOverFlew
  • 1,479
  • 2
  • 31
  • 58