Tuesday, October 5, 2010

Flv to 3gp converter

First of all I was installed ffmpeg on my centos 5.1 using yum.
If you don't have then simply run "yum install ffmpeg*".
Now to convert flv into 3gp, ffmpeg should contain h263 vedio codes generally it has and amrnb audio codes. In my case i don't have this audio code which was downloaded. Compiled and installed without any problem.
Create a file /bin/fl23gp and write below code.
------------------------------------------------------------------------------------------------------------
#!/bin/bash
echo "flv 2 3gb Convertion"
echo ""
if (($# ==0))
then
echo "Usage: flvto3gp [flv files] ..."
exit
fi

while (($# !=0 ))
do
ffmpeg -i $1 -s 176x144 -vcodec h263 -r 25 -b 200 -ab 6.7k -sameq -acodec libopencore_amrnb -ac 1 -ar 8000 ${1//.flv/.3gp}
shift
done
echo "Finished flv-to-3gp convertion"
echo "\" Enjoy \""
echo ""
------------------------------------------------------------------------------------------------------------
Run "chmod 777 /bin/flv23gp" .

"ffmpeg -formats | grep amr" will return what are audio codes preset with amr. Which was mentioned in /bin/flv3mp3 file for -acodec as "libopencore_amrnb" .

Thursday, August 26, 2010

Including IP address of your pc in linux prompt

When working remote machine using teminals it some times make quite confusing which teminal is connected to which machine. One way is setting tittle to teminal makes confortable but we can make linux prompt to display IP dynamic by adding code in /etc/bashrc.

Code :-

#------ display ip in prompt -----
#Generally eth0 interface is used
ip=`ifconfig eth0 2>/dev/nul |grep "inet addr" | cut -d ':' -f2| cut -d ' ' -f1`
#echo "--$ip--"
if [ -z $ip ]
then
#If not eth0 check for eth1
ip=`ifconfig eth1 2>/dev/nul |grep "inet addr" | cut -d ':' -f2| cut -d ' ' -f1`
#echo "--$ip--"
if [ -z $ip ]
then
# Both interfaces are not available
ip="localhost"
fi
fi
#`PS1="[\u@\$ip \W]\$"`
#export PS1="[\u@\$ip \W]\$"
user_id=`id -u`
if [ $user_id -eq "0" ]
then
#for root users

export PS1="[\u@\$ip \W]# "
else
#For normal users
export PS1="[\u@\$ip \W]\$ "
fi



-------------------------
Add above code in /etc/bashrc. Open new terminal to see the change.

In above i have useded eth0 and eth1 interfaces only because most PCs uses it. we can chane it to ath0 or ath1 or wlan0 depending on ur requirement.

Wednesday, July 28, 2010

Code to display your pc ip in linux prompt

Usually i do ssh connections to 2 or more machines. While switching form one teminal to other i use ifconfig to find to which pc it connected or i use to set title for teminals manully. But I feel there should be something else i can do, thought of putting ip in prompt itslef.

i have add code mentioned below in /etc/bashrc to effect it for all users.

code
#------ display ip in prompt -----
#Generally eth0 interface is used
ip=`ifconfig eth0 2>/dev/null |grep "inet addr" | cut -d ':' -f2| cut -d ' ' -f1`
#echo "--$ip--"
if [ -z $ip ]
then
#If not eth0 check for eth1
ip=`ifconfig eth1 2>/dev/null |grep "inet addr" | cut -d ':' -f2| cut -d ' ' -f1`
#echo "--$ip--"
if [ -z $ip ]
then
# Both interfaces are not available
ip="localhost"
fi
fi
#`PS1="[\u@\$ip \W]\$"`
#export PS1="[\u@\$ip \W]\$"
user_id=`id -u`
if [ $user_id -eq "0" ]
then
#for root users
export PS1="[\u@\$ip \W]# "
else
#For normal users
export PS1="[\u@\$ip \W]\$ "
fi
#clear
#----- end ---