I had lot of flv video files and wanted to convert it to mp4 for my itouch. Here is the quick way. -f is to force the format to mp4.
$ ffmpeg -i file.flv -f mp4 file.mp4
If you have to convert all files in a folder. Here is the small script. It will convert all flv files to mp4 with the same name with extenstion to mp4.
for file in *.flv
do
ffmpeg -i "$file" -f mp4 "${file%.flv}.mp4
done
Monday, 23 May 2011
QuickBits-1: !$
some times u want to take argument from the previous command you gave
say for example
$ ls /user/ramz/dir1/dir2/dir3/
Now you want to cd to the directory you used in ls command. The quick way is
$ cd !$
- This is equivalent to cd /user/ramz/dir1/dir2/dir3
- !$ - Takes the last argument of previous command.
say for example
$ ls /user/ramz/dir1/dir2/dir3/
Now you want to cd to the directory you used in ls command. The quick way is
$ cd !$
- This is equivalent to cd /user/ramz/dir1/dir2/dir3
- !$ - Takes the last argument of previous command.
Wednesday, 18 May 2011
Segregate even and odd nodes in a Linked List
Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list. Also, keep the order of even and odd numbers same.
Examples:
Input: 17->15->8->12->10->5->4->1->7->6->NULL
Output: 8->12->10->4->6->17->15->5->1->7->NULL
Input: 8->12->10->5->4->1->6->NULL
Output: 8->12->10->4->6->5->1->NULL
// If all numbers are even then do not change the list
Input: 8->12->10->NULL
Output: 8->12->10->NULL
// If all numbers are odd then do not change the list
Input: 1->3->5->7->NULL
Output: 1->3->5->7->NULL
Examples:
Input: 17->15->8->12->10->5->4->1->7->6->NULL
Output: 8->12->10->4->6->17->15->5->1->7->NULL
Input: 8->12->10->5->4->1->6->NULL
Output: 8->12->10->4->6->5->1->NULL
// If all numbers are even then do not change the list
Input: 8->12->10->NULL
Output: 8->12->10->NULL
// If all numbers are odd then do not change the list
Input: 1->3->5->7->NULL
Output: 1->3->5->7->NULL
Tuesday, 17 May 2011
Write a C program to remove duplicates from a sorted linked list.
Find Middle of Linked List
Monday, 16 May 2011
Find the Loop in the linked list and remove the loop from it
int detectLoop(NODE* headNode)
{
NODE* oneStepPtr = headNode;
NODE* twoStepPtr = headNode;
int isLoop = 0;
while(twoStepPtr != NULL
&& twoStepPtr->next != NULL
)
{
oneStepPtr = oneStepPtr->next;
twoStepPtr = twoStepPtr->next->next;
if (twoStepPtr == oneStepPtr)
{
isLoop = 1;
break;
}
}
return isLoop;
}
/* Call only when loop exists */
void removeLoop(NODE* headNode)
{
/* find Loop Node */
NODE* oneStepPtr = headNode;
NODE* twoStepPtr = headNode;
NODE* loopNode = headNode;
while(twoStepPtr != NULL
&& twoStepPtr->next != NULL
)
{
oneStepPtr = oneStepPtr->next;
twoStepPtr = twoStepPtr->next->next;
if (twoStepPtr == oneStepPtr)
{
loopNode = oneStepPtr;
break;
}
}
/* Find loopLength */
NODE* currentNode = loopNode;
int loopLength = 0;
while (currentNode != loopNode
|| loopLength == 0)
{
loopLength++;
currentNode = currentNode->next;
}
/* Offset headNode by loopLength */
currentNode = headNode;
NODE* offSetNode = NULL;
NODE* tailNode = NULL;
int offSetLength = 0;
while(offSetLength < loopLength) { tailNode = currentNode; currentNode = currentNode->next;
offSetLength++;
}
offSetNode = currentNode;
/* find tailNode, when currentNode and offSetNode meets, but one */
currentNode = headNode;
while(offSetNode != currentNode)
{
tailNode = offSetNode;
offSetNode = offSetNode->next;
currentNode = currentNode->next;
}
tailNode->next = NULL;
}
Write a recursive approach to reverse a link list.
Saturday, 14 May 2011
Write a program to return the nth node from the end of a linked list.
Thursday, 12 May 2011
Write a C program to remove duplicates from a sorted linked list.
Find Middle of Linked List
Thursday, 5 May 2011
Stack using One Queue
Implement a stack using a queue. The operations need not be neccesarily O(1).
Stack using two queues
Implement a stack using two queues. The operations need not be neccesarily O(1).
Tuesday, 3 May 2011
Queue with two stacks
Implement a queue using two stacks. The operations need not be neccesarily O(1).
Subscribe to:
Posts (Atom)