Some useful ffmpeg commands

Extracting images from a video file using ffmpeg:

Extract single frame at 10th second (ffmpeg uses HH:MM:SS:sss format) of the video:
$ ffmpeg -i input.avi -r 1 -ss 00:00:10.000 -f image2 output_%05d.png
Extract a frame every 2 seconds of the video:
$ ffmepg -i input.avi -r 0.5 -f image2 output_%05d.png
Extract all frames from the input video:
$ ffmpeg -i input.avi -f image2 output_%05d.png
To combine images into a video file (avi container with HuffYUV encoding with 30 fps for this example).
One thing to not here is ffmpeg assumes the input frame rate is 25 by default and does not put all the frames inside the output … Continue Reading

WordPress Track post views without a plugin using post meta

Add this code into the functions.php of your wordpress theme then follow step 1. and step 2. to display the number of views for each post.
PHP – functions.php
function getPostViews($postID){
$count_key = ‘post_views_count’;
$count = get_post_meta($postID, $count_key, true);
if($count==”){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ’0′);
return “0 View”;
}
return $count.’ Views’;
}
function setPostViews($postID) {
$count_key = ‘post_views_count’;
$count = get_post_meta($postID, … Continue Reading

Parse error: syntax error, unexpected $end

If you have are using the short form (<? ?> ) for PHP instead of the long form (<?php ?>) you might be faced with this parse error when running your script on different systems:
Parse error: syntax error, unexpected $end in X on line Y
where X is the file path and Y the line number, usually the last line of the file.
To avoid this error, refrain yourself from using the short form and stick to (<?php ?>), despite the extra 3 characters. This will make your code universally accessible and it is essential if your developing for beyond your own … Continue Reading

MySql Interview Questions Part-II

How do you start and stop MySQL on Windows? - net start MySQL, net stop MySQL
How do you start MySQL on Linux? - /etc/init.d/mysql start
Explain the difference between mysql and mysqli interfaces in PHP? - mysqli is the object-oriented version of mysql library functions.
What’s the default port for MySQL Server? - 3306
What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee.
Can you save your connection settings to a conf file? - Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, … Continue Reading

CSS Interview Questions and Answers Part-III

Can CSS be used with other than HTML documents?
Yes. CSS can be used with any ny structured document format. e.g. XML, however, the method of linking CSS with other document types has not been decided yet.

Can Style Sheets and HTML stylistic elements be used in the same document?
Yes. Style Sheets will be ignored in browsers without CSS-support and HTML stylistic elements used.

What are pseudo-classes?
Pseudo-classes are fictional element types that do not exist in HTML. In CSS1 there is only one element type which can be classed this way, namely the A element (anchor). By creating three fictional … Continue Reading

MySql Interview Questions Part-I

Q:1 How can we take a backup of a MySQL table and how can we restore it. ?
A:1 To backup:
BACKUP TABLE tbl_name[,tbl_name…] TO ‘/path/to/backup/directory’
RESTORE TABLE tbl_name[,tbl_name…] FROM ‘/path/to/backup/directory’
mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server). The dump will contain SQL statements to create the table and/or populate the table.
-t, –no-create-info
Don’t write table creation information (the CREATE TABLE statement).
-d, –no-data
Don’t write any row information for the table. This is very useful if you just want to get a … Continue Reading

CSS Interview Questions and Answers Part-II

Why do style sheets exist?
SGML (of which HTML is a derivative) was meant to be a device-independent method for conveying a document’s structural and semantic content (its meaning.) It was never meant to convey physical formatting information. HTML has crossed this line and now contains many elements and attributes which specify visual style and formatting information. One of the main reasons for style sheets is to stop the creation of new HTML physical formatting constructs and once again separate style information from document content.

What are the advantages/disadvantages of the various style methods?
External Style Sheets
Advantages

Can control styles for multiple documents … Continue Reading

CSS Interview Questions and Answers Part-I

What is CSS?
1. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. Every element type as well as every occurrence of a specific element within that type can be declared an unique style, e.g. margins, positioning, color or size.
2. CSS is a web standard that describes style for XML/HTML documents.
3. CSS is a language that adds style (colors, images, borders, margins…) to your site. It’s really that simple. CSS is not used to put any content on your site, it’s just there to take the content you have and make … Continue Reading

Fatal error: Cannot redeclare function

This is for the PHP beginners, and possibly a refresher for those of you who are writing functions. Many developers ran across issues such as “Fatal error: Cannot redeclare function” in their coding history. Mostly because wrote the function in a template file that was called by a loop to theme content. Sometimes though, code is written on major projects where the file defining the function has to have the function in that file. Therefore, simply defining a function in your code such as:
<?php
function foo($arg1) {
return $arg1;
}
?>
Could get you into some trouble if that file is being looped through. … Continue Reading

JavaScript & AJAX interview questions

1. Why so JavaScript and Java have similar name?
A.  JavaScript is a stripped-down version of Java
B.  JavaScript’s syntax is loosely based on Java’s
C.  They both originated on the island of Java
D.  None of the above.

2.  When a user views a page containing a JavaScript program, which machine actually executes the script?
A.  The User’s machine running a Web browser
B.   The Web server
C.  A central machine deep within Netscape’s corporate offices
D.  None of the above

3.  ______ JavaScript is also called client-side JavaScript.
A.  Microsoft
B.  Navigator
C.  LiveWire
D.  Native

4.  __________ JavaScript is also called server-side JavaScript.
A.  Microsoft
B.   Navigator
C.  LiveWire
D.  Native

5.  What are variables used for … Continue Reading

Older Posts »»