Spacer
Spacer

NGCODERS.COM

[ NEXT GENERATION CODERS ]

Spacer

Monthly Archive for June, 2010

MegaVideo Video downloader and streamer php script

Here is a small php script which will grab Mega Video download link and is able to stream it to JW Player. Streaming uses server bandwidth due to MV same IP restriction. The script supports paid accounts for bypassing Megavideo time limit and showing streams to your users ( Technique used by many Anim sites ).

Capturing Video on windows using C++

Using Webcam on windows should be easy, that is what i thought when i started out and wasted three days trying to get thing to work reliably. Most people used Video for Windows (VFW) in tutorials , but i found it very unreliable and crashing often, also when debugging it threw wired errors. Then I made up my mind to use the DirectX based DirectShow methods, Its needs DirectX SDK to build it and on downloading it and finally looking for the files i found that functionality have been moved to platform SDK. Anyhow i was not downloading another 4.5 GB of SDK to test if it worked. So after some Googling i found about the VideoInput library (uses DirectShow methods) which people sometimes use for OpenCV. I wished i had found it earlier , here is a small tutorial on hot to get started using it , since the original files which came with it did not work for me.There are a whole host of features supported so you can explore the documentation for more .

VideoInput Library homepage

How to use webcam/tv tuner/capture cards in VC++ to capture video and take pictures –

1. Create simple Dialog based MFC project.

2. In the dialog make a Picture control and a Button , Picture control will Display the Video stream and the button will be used to capture a snapshot.Change Picture control to type Bitmap and attach a CStatic variable to it.

3. Now we will use a simple timer ( WM_TIMER ) to update the image being captured there are better way but this should do for a tutorial. In OnInitDialog() set the timer to refresh at say 10 times a second,

SetTimer(NULL,100,NULL)

4. Include the video videoInput.h header file. Also add the videoinput.lib in the linker input and for ignore library atlthunk.lib ( if it causes errors ).

5. Initialize the device using VideoInput API .

// in header
int device,width,height,size;
videoInput VI;
unsigned char * captureBuffer;

// in InitDoalog
device = 0; // first webcam
VI.setupDevice(device,320,240); // 320 x 240 resolution

width = VI.getWidth(device);
height = VI.getHeight(device);
size = VI.getSize(device); // size to initialize buffer

captureBuffer = new unsigned char[size]; // our capturebuffer

6. Now lets capture video and display frame in the OnTimer

if(VI.isFrameNew(device))
{
VI.getPixels(device,captureBuffer, false, true);
DisplayImage(&m_webcam,height,width,captureBuffer);
}

7. There is also example of how to capture image using libjpeg, please download the source and check it out.

Simple PHP Google PageRank checker script

This is a simple google pagerank script which can be used to show a graphic pagerank on your website. Or use it in your traffic stats script. Calling is very simple –

pr.php?prurl=http://www.ngcoders.com

It will show the small famous pagerank graphic with a bar graph and numeric page rank.

Adding Javascript to WordPress without Plugin

Though it would seem pretty simple, but as soon as you try to add a JavaScript to your WordPress post which is more than few lines of code. WordPress somehow messes up the code and the script will not work due to wordpress formatting it. You can disable formatting but then other old posts also loose formatting. The other solution provided is to add them to template / make JS files and include them. Both require more work.

Here is my little solution , Basically pack the script and make it as a one line of code which can be added to the html editor –

Go to the following link paste your JavaScript code and embed the WordPress embed in your wordpress …

WordPress JavaScript Packer