How to upload youtube video on Kaltura using Kaltura Client Library - PHP 5

5 replies [Last post]
Joined: 07/28/2010
Points: 3

hi

I am developing one application where user can upload video and images from his own machine or from other site
like youtube and flickr . I am using kaltura php 5 library for this and my apllication is working fine for user own videos
and images as well as for flickr images.

But my problem is that youtube video upload is not working.
I used following code to upload local images

$kconf = new KalturaConfiguration(PARTNER_ID);
$kclient = new KalturaClient($kconf);
$ksession = $kclient->session->start(ADMIN_SECRET, $user, KalturaSessionType::ADMIN);
if (!isset($ksession)) {
        die("Could not establish Kaltura session. Please verify that you are using valid Kaltura partner credentials.");
}

//print_r($ksession);
$kclient->setKs($ksession);

$entry = new KalturaMediaEntry();

$fileData = $_FILES['fileData']['tmp_name'];
//print $fileData;
if(move_uploaded_file($_FILES['fileData']['tmp_name'],"uploads/kal_".$_FILES['fileData']['name']))
{
$rs = $kclient->media->upload("uploads/kal_".$_FILES['fileData']['name']);
unlink("uploads/kal_".$_FILES['fileData']['name']);
}

//print_r($rs);
$entry->mediaType = 2;
$entry->name = "Test by bhushan";
$rsobj = $kclient->media->addFromUploadedFile($entry,$rs);

and i used uploadFromUrl() method to upload flickr image and its working but when i used same for youtube video it is not working .

Can any one tell me why it is not working for youtube ??
Can any one help me ..
Do u have any example of uploading video from youtube and other site to kaltura??

Joined: 06/01/2010
Points: 72

Try this sample and see if it works:

http://www.kaltura.org/kalorg/kaltura-api-clients-sample-code/php/Sample...

Here's the movie file used in the upload. You should save it to your disk before using it:

http://www.kaltura.org/kalorg/kaltura-api-clients-sample-code/php/piano....

Jason

Joined: 07/28/2010
Points: 3

Hi Jason ,

Thanks for your help.

My local video functionality is working fine. I don't have problem with that.

But my problem is to upload file from youtube link. Say my video link is http://www.youtube.com/watch?v=zL9xAlVLseQ and i want to upload this video as it from youtube to kaltura without downloading to my disk.

I have read somewhere that the youtube api is blocked by Kaltura but I am not sure about this.

So can you confirm it .
On kaltura's site they say that user can upload video from social sites like youtube, flickrs etc.

Can you help me for that.

Thanks
Regards Bhushan

Joined: 06/01/2010
Points: 72

Hi Bhushan,

A URL like http://www.youtube.com/watch?v=zL9xAlVLseQ won't work because it does not
point to a video file -- it loads an entire HTML page. If you want to use the Kaltura API for
uploading from a URL, you need a URL that references the video file directly.

J

Joined: 07/28/2010
Points: 3

Hi Jason,

I got you. But how can I get direct link to flv from Youtube. I think they don't provide such feature.
So is there any way to get the exact link of Youtube video file so I can upload ti to Kaltura.

Thanks,
Bhushan

Joined: 06/01/2010
Points: 72

There is a way to do it. Try looking at open source software that downloads Youtube files -- like this one: http://sourceforge.net/projects/ytd/files/

J