Innovative High Performance Web Hosting Solutions.
 Switching hosts?
Vexxhost makes switching hosts quick and easy. We'll even move your files and your databases from your old host to our servers for free.
Contact us web hosting
Happy Customers
First of all, we thank you for your best technical support, very easy to share our questions about technical issues with vexxhost.com & very fast to get the best solutions! With your great support, we are thinking to be your guest (client) as long as possible.

Aria R.
Neekou.com
web hosting
comodo

What FFMPEG-PHP can do and how to use the most out of it
Posted: December 20, 2006 at 8:49 pm | (12) Comments

Need help using specific FFMPEG-PHP functions or some programming help? Let our experienced technicians help you debug your problem for FREE. Sign up today and post at our online community: FFMPEG-PHP Help Forums

You’ve probably heard of ffmpeg-php and it’s wide usability mostly in sites that involve with videos such as YouTube or any other similar site. Here’s a bit of an introduction to it and how to use it.

First thing, you’ve got to check that your web hosting provider actually has ffmpeg & ffmpeg-php extension installed on your account and then you could get started with ffmpeg. You can check if it’s installed by creating a PHP script and executing the following code:

extension_loaded('ffmpeg') or die("ffmpeg extension not loaded");

If you get “ffmpeg extension not loaded” then your web hosting provider does not have ffmpeg installed, if you get nothing, then you’re one the good track!

ffmpeg-php is very simple to learn, what it is pretty much is an interface that works with the ffmpeg software to make it easier for PHP developers to access.

Like any object in PHP, you’ll have to start with creating a new instance of it. You can do that by using the following line:

$ffmpegInstance = new ffmpeg_movie(“/path/to/movie/”);

Now that you’ve had that, you can use that instance to use the many features of ffmpeg-php which are from knowing the duration of the movie/audio in seconds to retrieving the bitrate of the movie/audio file.

Once here, it’s pretty much like object oriented programming, ex:
$ffmpegInstance->getDuration(); // Gets the duration in secs.
$ffmpegInstance->getVideoCodec(); // What type of compression/codec used

This can be very helpful when coding anything that has to do with uploading videos because you can know a lot of information about it. I’ve made a small script that pretty much retrieves all the information that ffmpeg can get right here

Creating PDF’s on the fly using PHP & FPDF
Posted: December 3, 2006 at 12:27 pm | (15) Comments

Generating PDF’s is an easy method to make a very nice printable and/or savable version of an article. This could be helpful in a WordPress blog or any articles website. This method utilizes the popular FPDF class.

First of all, I suggest you get the latest FPDF version from here. I suggest creating a directory such as “pdf” on your web hosting space. You will need to place the fpdf.php into that directory, you will only need it.

Let’s make our first “Hello World” example. Place the following in a file called test.php:

<?php
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

Now let’s see that code line by line…

require('fpdf.php');
This line includes our FPDF class that we need to create the PDF file.

$pdf=new FPDF();
This line creates a new instance of the FPDF class which will be binded to $pdf

$pdf->AddPage();
This line tells FPDF to add a new page to the PDF file; obviously we need one page so we will call this function once.

$pdf->SetFont('Arial','B',16);
This line tells the FPDF class to change the font to Arial, bold, 16 pt.

$pdf->Cell(40,10,'Hello World!');
This line is just like the “echo” of PHP, the text fields in PDF files are just sort of rectangles with text in them, so we want the width of 40 pt. and a height of 10 pt., the third value is the text to be written in that rectangular box.

$pdf->Output();
Our final line, which pretty much means: “we’re done, show us our PDF!”

That’s a very simple FPDF usage, however, here is a bit of more advanced version of FPDF usage:

<?php
require('fpdf.php');
$pdf=new FPDF("L", "mm", "A4");
$pdf->AddPage();
$pdf->SetFont('Arial','BIU',30);
$pdf->SetTextColor(0,0,255);
$pdf->Cell(60,20,'PDF+PHP Test',1,1,C,0);
$pdf->Output();
?>

Now let’s do a quick review of that more advanced code:

$pdf=new FPDF("L", "mm", "A4");
This will create a new instance but instead will default to creating landscape pages because of the first L, P can be used instead to default to portrait pages. The second value is the default measurement unit, a choice of point (pt), millimeter (mm), centimeter (cm) and inch (in) is given. The last value is the size of the page, the choice of A3, A4, A5, Letter & Legal is given.

$pdf->AddPage();
Simple function, just add the page, you can tell the function to create either a portrait (P) or landscape (L) by giving it as a first value (ex: $pdf->AddPage("L"), $pdf->AddPage("P")).

$pdf->SetFont('Arial','BIU',38);
This required function again says that we want an Arial, 30 mm in size (because of the default size unit), the 'BIU' simply tells that we want it to be Bold, Italic & Underlined.

$pdf->SetTextColor(0,0,255);
This sets the default text color for the text we will be writing, I’ve chosen blue here, the first value is red (r), the second is green (g) & blue (b).

$pdf->Cell(60,20,'PDF+PHP Test',0,1,C,0);
This makes the so famous rectangle with 60 mm of width & 20 mm of height, we wrote ‘PDF+PHP Test’ and the first 0 means we do not want a border. The 1 next to it means that once it’s done the cell, it will go to the beginning of the next line, if 0 is provided, then it will be to the right of it, if 2 is provided then it will go below. The C is just the alignment which is center of the text inside the box, possible values are left (L), center (C), right (R).

$pdf->Output();
Output our brand new colorful PDF file!

Thanks for reading!

Copyright © 2005-2009 vexxhost web hosting.
All prices are in USD unless otherwise indicated.