Posts Tagged ‘video’

The… Android Dance?!!!

Sunday, March 27th, 2011

Just a short post…

I just happened to watch a youtube video of the Android mascot dancing to a spiffy beat. I don’t know about you, but I found this awesome!

Enjoy the vid below:

Facebook: Hiphop for PHP Released As Open Source

Wednesday, February 3rd, 2010

After spending some weeks in rumor land, Facebook has now released a cross-compiling language converter for PHP as open source (php license), titled Hiphop for PHP.

What the application does is to programatically convert PHP source code into C++ and compile it with g++.

According to senior engineer Haiping Zhao, Hiphop has now been deployed to 90% of the Facebook traffic, six months after deployment.

For more information, please see the video below:

Heywatch and php

Monday, September 7th, 2009

Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.

One nice thing about this service is that it has a REST based API that is simple to implement in php. However, the documentation that comes with heywatch shows only how to access the API using PEAR – this becomes a disadvantage if your shared hosted webhost doesn’t have PEAR installed. I also personally think that using PEAR just to call this api is basically overkill.

Why not use curl instead? I basically changed the PEAR functions in the API documentation to that of php curl functions (which are basically native and available in practically all shared php webhosting)


<?
$video_url = "http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov";
$format_id = "1086"; // 1086 for flash h264, 31 for flash flv
$ftp = "ftp://username:password@ftphost.com";
$ping_after_encode = "http://host/heywatch/success.php?myvideoid=5&myuserid=1";
$ping_if_error = "http://host/heywatch/error.php";
$ch = curl_init();
$your_username = "";
$your_password = "";
$arr = array($video_url,"format_id"=>$format_id,"automatic_encode"=>"true","ftp_directive"=>$ftp,"title"=>"My Video Title","keep_video_size"=>"true");
curl_setopt($ch, CURLOPT_USERPWD, $your_username.':'.$your_password);
curl_setopt($ch, CURLOPT_POSTFIELDS,$arr);

$data = curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
exit;
} else {
curl_close($ch);
}

header(“Content-Type: text/xml;charset=UTF-8″);
header(“Pragma: no-cache”);
echo $data;
?>

What this code does is to download a video, convert it to h264 flash format, then upload it to a select ftp host in just one step (success.php and error.php are ping functions where the developer is notified if conversion was successful or not).

One thing to take note is that heywatch doesn’t like special characters in the ftp url, if you place such characters in the $ftp variable, heywatch upload fails.

Have fun!