Powered By
Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

Load Youtube toprated videos using simplexml_load_file PHP

View Comments
add to del.icio.us
saved by 0 users
  In this post I will show you how to fetch the you tube top rated videos just with built in PHP functions instead of using zend data api libraries.  Zend data api is the best and optimized way to do this task but rather than including and working with zend and zend data api you can just do this with php built-in functions by reading the you tube feeds for the top rated videos.

 So here we go.
General feed url of youtube is

http://gdata.youtube.com/feeds/api/standardfeeds/FEED_IDENTIFIER 
 
Youtube feeds URL for the top rated videos is
http://gdata.youtube.com/feeds/api/standardfeeds/top_rated

Here you can replace top_rated with




Fore more info regarding this

http://code.google.com/apis/youtube/2.0/developers_guide_php.html

So we have to read the feeds from the above url, then you can display it where ever you want.

We have the top rated videos as xml so we need to parse it using php function "simplexml_load_file() " .
To do this in php.ini we need to enable the url include option to On if it is not already turned on.

Get the feeds in a variable

                     $url="http://gdata.youtube.com/feeds/api/standardfeeds/top_rated";
                     $comments =simplexml_load_file($url); // Php built in function


So we have  top rated videos in $comments  , we need to parse it using foreach and display it in the following way.

 Here the feed is in yahoo feed format so you to mention the feed as yahoo and then you can parse the media group under entry tag.

      $media = $video->children('http://search.yahoo.com/mrss/');
So from this we can easily parse all the data from the youtube feeds.

Download the source for your reference.





You can also do all other functionality like searching a video or displaying particular video comments, recent videos and more using the above method. Its very easier than the zend data api. Try it out. Leave the comments if you have any problem
Read More

FFMPEG Installation Step by step guide in centos

View Comments
add to del.icio.us
saved by 0 users
                               FFMPEG Installation Guide

            FFMPEG is an open source application and developed under Linux  that allows you to convert video and audio files easily between a variety of different formats. It supports most industry-standard codec and can convert from one file format to another quickly and easily.It includes libavcodec, a leading audio/video codec  library.  FFmpeg  can compile under most Operating Systems, including Windows.  
     You can use this powerfull tool using any scripting language server side execute functions once you installed in your server.
   In php
      shell_exec(“command, parameters”);
the following flow chart explain you how it works with php




This article will guide you to installing FFMPEG and other codec on Linux(centos 5).

FFMPEG Installation Requirements
·      LAME Mp3 Audio Codec (Requred for mpg, flv, avi, wmv etc files)
·      FFMPEG ,mplayer,mencoder, flvtool2
·      FFMPEG-PHP
More Advantage When you installed these components
·      AMR Audio Codec (Required for 3gp video files)
·      XVID Audio Codec

Note :
 You need to know how to use yum,rpm,wget commands well and these commands should be configured in the server in which you are going to install ffmpeg.
·         Make a note of what you are doing for future reference when ever you are facing problems
·         These steps are worked well for me and and am not sure how about for you, so please make some backup when ever you modifying your system files.
Go ahead.....

Installation Steps

    It is a good practice to install all the external audio codec libraries first and then install the FFMPEG.   
   So now you need to connect to your server using any ssh tool like putty by giving server name , username, password.



    cd /usr/
    Create a directory for all the further steps
    mkdir downloads
    Move into downloads directory
    cd downloads    


 

  
Installing LAME MP3 Encoder

          Download LAME Mp3 Codec download URL : Lame Mp3 Codec
·      Untar the lame file by using tar zxvf lametarfile
·      Assign 777 permission rights to the lame folder by typing chmod 777 lamefolder -R
·      Traverse to the root of lame folder and type
          wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
Extract the archive:
tar -xjf lame-3.97.tar.gz
 cd  lame-3.97
./configure
make
make install



Installing – Ffmpeg


Adding the DAG repository is simple. I’m using yum, so I did the following to add the repository:

1.    Create and open a new file called /etc/yum.repos.d/dag.repo.
vi /etc/yum.repos.d/dag.repo
   2. Add the following text to the file:
      [dag]
      name=DAG RPM Repository
      baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
      gpgcheck=1
      enabled=1
   3. Finally, save and close the file.
            In order to successfully use the DAG repository with tools such as yum, you need to add DAG’s GPG key. Failure to do so will result in an error like the following:
            warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
            Public key for faac.x86_64.1.26-1.el5.rf.rpm is not installed



            In order to add the GPG key for DAG, run the following:
            rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

            Or if you dont need key validation just make gpgcheck=0 in the above dag.repo file     
            So Now that DAG is setup, it’s a good idea to update all your packages.
           
            # yum update
Now you are ready to install FFmpeg with yum. I wanted to install all the available FFmpeg packages, so I first asked yum what was available.
# yum search ffmpeg

Searching through the results, I found that three packages need to be installed: ffmpeg, ffmpeg-devel, and ffmpeg-libpostproc.

# yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc
install supporting packages – mplayer,mencoder, flvtool2
yum -y install mplayer mencoder flvtool2

  Preparing for ffmpeg-php

I often work with programs through command line calls in code, but I wanted something more robust this time, so I looked around and found ffmpeg-php. Based on the API, it looks to be a great tool to interface PHP and FFmpeg.
There are four things that are required to successfully install and run ffmpeg-php; they are:
·                                          ffmpeg-0.4.9_pre1 or higher
·                                          php-4.3.0 or higher
·                                          gd-2.0 or higher
·                                          php-devel
 Run the following

yum install php-gd
In case you are wondering what php-devel is for, it installs the phpize program which is used to install ffmpeg-php.

    Installing ffmpeg-php

Now we are ready to install ffmpeg-php.
This can be done in six easy steps:
1.                                      Download the  latestet ffmpeg-php from http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/
        wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download

2.                   Extract the archive:
             tar -xjf ffmpeg-php-X.x.x.tbz2
3.                   cd ffmpeg-php-X.x.x/
4.                   phpize
5.                   ./configure && make
6.                   sudo make install

It will copy the ffmpeg.so module in php default module location. Now you have to edit php.ini file to enable ffmpeg-php support in it by using ffmpeg.so module.
vi /etc/php.ini
and append following line
extension=ffmpeg.so

Restart apache service to take effect of php.ini
/etc/init.d/httpd restart
Run following command to ffmpeg module listing in php.
php -m | grep ffmpeg
For more about ffmpeg-php functions –  documentation

Now you should be ready to convert any video to any video format and still more, Have a nice streaming. 

Test it out using
ffmpeg -i videofilename.extension
          You will be getting some message and info about the input file


Installing advanced ffmpeg supporting components
AMR Audio Download URL   AMR Audio Codec
To install the AMR codec you will require both AMR-WB and AMR-NB files.
XVID Audio Download URL: XVID Audio Codec

Installing AMR Codec
For installing the AMR codec there are two separate files that needs to be installed are AMR-WB and AMR-NB.
·  Untar the AMR file by using tar zxvf tarfile
·  Assign 777 permission rights to the amr folder by typing chmod 777 amrfolder -R
·  Traverse to the root of amr folder and type
./configure
make
make install
Note on Installing AMR:
You might get errors installing AMR codec on Autoconf utility of linux. To resolve this problem will have to install the latest version of Autoconf utility
Dwonload  AutoConf  from  Here
Installing Xvid Codec
·  Untar the xvid file bu using tar zxvf tarfilename
·  Assign 777 permission rights to the lame folder by typing chmod 777 xvidfolder -R
·  Traverse to the root of xvid folder
·  Goto Build/generic folder and type
./configure
make
make install 


Leave A comment If you are facing any problem.  Have a happy encoding and streaming, we will see set of streaming tutorials in next tutors.



Read More

Signup Form with Jquery Validation - Email,username validations

View Comments
add to del.icio.us
saved by 0 users


Description

Signup form is used to give user to create account in our site. So it needs to be very clear in design and should be val;idated from client side itself.

Here is the full example of making such a form with full js validation using jquery.




How to use:

You need to change some of the fields and messages as per your specifications and design.

Edit stylesheet and,html,js files in the Signup folder and use it for your signup form.



Output


Here is the two scrrenshots shows the output.

Before validating


After validating
And here You can Download the Source.

Read More

More ways to open composer in a new window

View Comments
add to del.icio.us
saved by 0 users
shift + 'c' or shift + click on 'Compose Mail'
shift + 'r' or shift + 'reply'
shift + 'a' or shift + 'reply all'
shift + 'f' or shift + 'forward'
Shift key is needed for keyboard shortcuts to work (caps lock is ignored).


If you're replying to a mail and want to change to reply all from your keyboard, hit Esc then 'a'. This is a keyboard shortcut. Saves a mouse click.


Because Esc moves the focus out of the text box when you are composing a reply, it allows you to then type the normal keyboard shortcuts 'r' for reply-to-sender, 'a' for reply-to-all, or 'f' forward to change the recipients of your message. So if you're replying to a message, the combination Esc then 'a' will change it to "reply to all"
Read More

Jquery SLideshow Example

View Comments
add to del.icio.us
saved by 0 users
Today we are going to create a photoslider with commenting system,














Like orkut we can also create a photoviewer with commenting system with animation effects.




So try this and you can also use this example.





Enjoy.
Read More

Accordion Panel in HTML

View Comments
add to del.icio.us
saved by 0 users
In Adobe Flex we have got a component called Accordion panel, most of us will be familiar with that component. The advantage of that panel is that we can place more contents in less space. It is a container which acts just like a tab navigator but with some animation effects. You can get lots more information about Flex accordion panel from Adobe labs.


I tried to develop the same thing using DHTML and CSS. I have used DIV and style property DISPLAY to obtain the working of the panel.


You can download the code and see its live demo. But don't forget to comment on the post
Read More