2012년 6월 26일 화요일
안드로이드 개발환경 설정 (r18)
* 설치환경
JDK 1.7.0_04 (64)
Eclipse Classic 3.7.2 (64)
* 환경변수 JAVA_HOME
* Android SDK download (r18)
http://developer.android.com/sdk/index.html
* 설치 종료 후 SDK Manager 에서 플랫폼과 패키지를 추가
http://developer.android.com/sdk/installing/adding-packages.html
* Eclipse ADT Plugin 설치
이클립스 실행
Help > Install New Software....
Add 버튼 클릭
Name: ADT Plugin
Location: https://dl-ssl.google.com/android/eclipse/
Click OK
Developer Tools 체크하고 Next 클릭
Next 클릭
라이센스 동의하고 Finish 클릭
설치가 완료되면 Eclipse 재시작
재시작시 Use existing SDKs, Existing Location에 Android SDK 설치 디렉토리 선택 (기본으로 설치했다면 C:\Program Files(x86)\Android\android-sdk)
2012년 6월 15일 금요일
ffmpeg install on Ubuntu 10.04(lucid) LTS
reference
http://ubuntuforums.org/showthread.php?t=786095
http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuideLucid
$ mkdir /home/user0/ffmpeg_packages
$ cd /home/user0/ffmpeg_packages
$ sudo apt-get remove ffmpeg x264 libx264-dev yasm
$ sudo apt-get update
$ wget http://security.ubuntu.com/ubuntu/pool/multiverse/f/faac/libfaac0_1.26-0.1ubuntu2_amd64.deb
$ wget http://security.ubuntu.com/ubuntu/pool/multiverse/f/faac/libfaac-dev_1.26-0.1ubuntu2_amd64.deb
$ dpkg -i libfaac0_1.26-0.1ubuntu2_amd64.deb
$ sudo dpkg -i libfaac-dev_1.26-0.1ubuntu2_amd64.deb
$ sudo apt-get install -y build-essential git-core checkinstall texi2html \
libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev zlib1g-dev
* yasm
$ cd /home/user0/ffmpeg_packages
$ wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
$ tar xzvf yasm-1.2.0.tar.gz
$ cd yasm-1.2.0
$ ./configure
$ make
$ sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no --deldoc=yes --default
* x264
$ cd /home/user0/ffmpeg_packages
$ git clone --depth 1 git://git.videolan.org/x264
$ cd x264
$ ./configure --enable-static
$ make
$ sudo checkinstall --pkgname=x264 --default --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes
* LAME
$ cd /home/user0/ffmpeg_packages
$ sudo apt-get remove libmp3lame-dev
$ sudo apt-get install nasm
$ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
$ tar xzvf lame-3.99.5.tar.gz
$ cd lame-3.99.5
$ ./configure --enable-nasm --disable-shared
$ make
$ sudo checkinstall --pkgname=lame-ffmpeg --pkgversion="3.99.5" --backup=no --default \
--deldoc=yes
* libvpx
$ cd /home/user0/ffmpeg_packages
$ git clone --depth 1 http://git.chromium.org/webm/libvpx.git
$ cd libvpx
$ ./configure
$ make
$ sudo checkinstall --pkgname=libvpx --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--default --deldoc=yes
* ffmpeg
$ cd /home/user0/ffmpeg_packages
$ git clone --depth 1 git://source.ffmpeg.org/ffmpeg
$ cd ffmpeg
$ ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx \
--enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
$ make
$sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" --backup=no \
--deldoc=yes --default
$ hash x264 ffmpeg ffplay ffprobe
2012년 6월 14일 목요일
java로 ubuntu 환경에서 /proc/stat을 이용해 CPU 사용량 체크하기
package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class CpuRateByCore {
public static int INTERVAL = 1000;
public static String[] getCpuUsageByCore() {
String[] result = null;
String[] command = { "bash", "-c", "cat /proc/stat | grep 'cpu[0-9]'" };
Runtime runtime = Runtime.getRuntime();
BufferedReader reader = null;
List<CpuInfoVo> prevInfoList = new ArrayList<CpuInfoVo>();
List<CpuInfoVo> diffInfoList = new ArrayList<CpuInfoVo>();
try {
Process process = runtime.exec(command);
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
String[] columns = null;
long total = 0;
long idle = 0;
int x = 0;
while ( (line = reader.readLine()) != null ) {
// System.out.println(line);
line = line.replace(" ", " ");
columns = line.split(" ");
total = 0;
idle = 0;
for ( int i = 1 ; i < columns.length ; i++ ) {
total += Long.parseLong(columns[i]);
}
idle = Long.parseLong(columns[4]);
CpuInfoVo vo = new CpuInfoVo();
vo.setTotal(total);
vo.setIdle(idle);
prevInfoList.add(vo);
x++;
}
// sleep 1sec
//Thread.sleep(INTERVAL);
process = runtime.exec(command);
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
x = 0;
while ( (line = reader.readLine()) != null ) {
line = line.replace(" ", " ");
columns = line.split(" ");
total = 0;
idle = 0;
for ( int i = 1 ; i < columns.length ; i++ ) {
total += Long.parseLong(columns[i]);
}
idle = Long.parseLong(columns[4]);
long diffTotal = total - prevInfoList.get(x).getTotal();
long diffIdle = idle - prevInfoList.get(x).getIdle();
long cpuRate = 0;
if (diffTotal != 0)
cpuRate = 100 * ( diffTotal - diffIdle ) / diffTotal;
CpuInfoVo vo = new CpuInfoVo();
vo.setTotal(diffTotal);
vo.setIdle(diffIdle);
vo.setRate(cpuRate);
diffInfoList.add(vo);
x++;
}
result = new String[diffInfoList.size()];
for (int i=0; i<diffInfoList.size(); i++) {
CpuInfoVo cpuInfoVo = (CpuInfoVo)diffInfoList.get(i);
result[i] = Long.toString(cpuInfoVo.getRate());
}
}
catch ( Exception e ) {
e.printStackTrace();
}
return result;
}
public static void main(String[] args) throws Exception {
String[] cpuRates = getCpuUsageByCore();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String ymd = sdf.format(Calendar.getInstance().getTime().getTime());
StringBuilder message = new StringBuilder();
message.append(ymd);
int total = 0;
for ( int i = 0 ; i < cpuRates.length ; i++ ) {
message.append(" ").append(cpuRates[i]);
total += Integer.parseInt(cpuRates[i]);
}
int cpuRate = total / cpuRates.length;
message.append(" (avg)").append(cpuRate);
System.out.println(message);
}
}
피드 구독하기:
글 (Atom)