System.out.println(...)

UILabel 자동 줄바꿈 (Line-break)

iOS

검색에 자주 걸리는 UILineBreakModeWordWrap 는 더이상 사용되지 않는다.

lbLabel.lineBreakMode = NSLineBreakMode.byWordWrapping

 

 

 

micom 에서 SHA-1 으로 otp 생성하기

micom

우선 Hash, Mac, Signature 에 대해 알아 둘 필요가 있다.

https://rookiecj.tistory.com/368

 

hash, MAC vs Signature 차이점

hash나 MAC, Signature모두 hash를 기본으로 사용하지만 어떤부분이 다른지 살펴본다. 먼저 기본이 되는 hash는 메세지를 요약하는데 사용된다. byte[] data = "plain text".getBytes("UTF-8"); MessageDigest mes..

rookiecj.tistory.com

otp 생성을 위해 시간값과 특정 기기 아이디로 Mac (Message Authentication Code) 를 생성해 보자.

java code example..

https://jar-download.com/artifacts/com.j256.two-factor-auth/two-factor-auth/0.2/source-code/com/j256/twofactorauth/TimeBasedOneTimePasswordUtil.java

 

com.j256.twofactorauth.TimeBasedOneTimePasswordUtil Maven / Gradle / Ivy

com.j256.two-factor-auth two-factor-auth 0.2 compile group: 'com.j256.two-factor-auth', name: 'two-factor-auth', version: '0.2' //Thanks for using https://jar-download.com libraryDependencies += "com.j256.two-factor-auth" % "two-factor-auth" % "0.2" //Than

jar-download.com

c code example..

https://github.com/cantora/avr-crypto-lib

 

cantora/avr-crypto-lib

mirror of avr-crypto-lib (http://code.nerilex.org/bg/avr-crypto-lib.git) - cantora/avr-crypto-lib

github.com

https://github.com/mkj/pihelp

 

mkj/pihelp

A hardware watchdog for a Raspberry Pi using an AVR - mkj/pihelp

github.com

8비트 마이컴에서는 uint64_t 자료형을 사용할 수 없어 문제가 발생한다. 참고할 만한 문서.

https://stackoverflow.com/questions/33498371/wrong-sha-1-hash

 

Wrong SHA-1 hash

I'm planning to use AVR-Crypto's SHA-1 implementation for HMAC. However, I can't seem to generate the correct SHA-1 sum. For instance, if I call the function with the following unsigned char sh...

stackoverflow.com

c code example 에서 micom 을 위해 고쳐져야 하는 부분은

sha1_ctx_t 구조체 선언 부분을 아래와 같이 uint64_t -> uint32_t 로 수정해준다.

/*
typedef struct
{
	uint32_t h[5];
	uint64_t length;
} sha1_ctx_t;
*/

typedef struct
{
	uint32_t h[5];
	uint32_t length;
} sha1_ctx_t;

sha1_lastBlock 함수에서 주석 부분을 아래와 같이 수정해 준다.

uint8_t i;
/*
for (i=0; i<8; ++i)
{
	lb[56+i] = ((uint8_t*)&(state->length))[7-i];
}
*/
for (i = SHA1_BLOCK_BYTES; state->length != 0; state->length >>= 8)
	lb[--i] = (uint8_t)(state->length);

리눅스에서 컴파일 한 것과 다르게 뒤집어진(?) 결과가 나온다.

예를들어 리눅스에서 b696eeac 라면 8비트 마이컴(8051)에서는 acee96b6

함수를 아래와 같이 값을 그냥 리턴하도록 수정해준다.

uint32_t change_endian32(uint32_t x)
{
	//return (((x)<<24) | ((x)>>24) | (((x)& 0x0000ff00)<<8) | (((x)& 0x00ff0000)>>8));
    return x;
}

 

tensorflow 설치시 주의사항

machine-learning

tensorflow 의 설치를 따라가다 보면 몇가지 문제에 부딛힐 수 있다.

 

https://www.tensorflow.org/install/pip?hl=ko

 

pip를 사용하여 TensorFlow 설치  |  TensorFlow

TensorFlow 2.0 베타 사용 가능 tensorflow==2.0.0-rc1 - CPU만 포함하는 미리보기 TF 2.0 베타 빌드(불안정) tensorflow-gpu==2.0.0-rc1 - GPU를 지원하는 미리보기 TF 2.0 베타 빌드(불안정, Ubuntu 및 Windows) 사용 가능한 패키지 tensorflow - CPU만 포함하는 안정적인 최신 출시(Ubuntu 및 Windows) tensorflow-gpu - GPU를 지원하는 안정적인 최

www.tensorflow.org

 

1. 시스템에 Python 개발 환경 설치

64비트 Windows용 Python 3 출시를 설치합니다(선택적 기능으로 pip 선택).

=> 반드시 64비트용을 설치하여야 합니다. 

 

(인터넷에 돌아다니는 설치가이드를 보면 다양한 라이브러리를 사용하기 위해서는 64비트 컴퓨터에서도 32비트용 파이썬을 설치하라는 이야기가 있습니다만... 32비트용을 설치하면 tensorflow 가 설치되지 않습니다.)

=> tensorflow 설치시 에러가 발생하는 경우 (파이썬 버전 문제)

https://devlog.jwgo.kr/2017/12/13/tensorflow-install-error/

=> pip3 install -U pip virtualenv 를 실행하지 말것. 

아래를 먼저 실행하면.. virtualenv 가 설치됨. (위코드를 실행하면 pip.exe 가 사라질 수 있습니다.)

python -m pip install --upgrade pip

2. 가상 환경 만들기(권장)

=> 아래와 같이 변경하여 실행해주세요.

virtualenv --system-site-packages -p python3 ./venv 

 

-> virtualenv --system-site-packages -p python ./venv

=> tensorflow 는 안정 버전을 설치해 주세요. rc 버전을 설치하면 예제들이 실행되지 않습니다.

pip install --upgrade tensorflow

 

tensorflow 안정 버전을 설치해야 구글의 프로그래밍실습에 있는 예제를 따라가기 쉽습니다.

 

https://developers.google.com/machine-learning/crash-course/first-steps-with-tensorflow/programming-exercises?hl=ko

AttributeError: module 'tensorflow' has no attribute 'logging'

machine-learning

구글의 tensorflow 예제를 실행하다 보면

 

AttributeError: module 'tensorflow' has no attribute 'logging'

 

와 같은 에러를 만날 수 있다.

 

tf.logging.set_verbosity(tf.logging.ERROR)

 

부분에서 발생하는 에러인데, tensorflow 를 2.0.0-rc1 버전을 설치한 경우 발생한다.

 

tf.logging 대신 tf.compat.v1.logging 을 사용해 주면 된다.

 

=> tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

'machine-learning' 카테고리의 다른 글

tensorflow 설치시 주의사항  (1) 2019.09.26

android studio 에서 arr 생성하기

android

프로젝트에서 우측 마우스 버튼 클릭하여 New > Module 선택


Module 종류 선택에서 Android Library 선택


스튜디오 우측의 Gradle 탭에서 생성한 라이브러리 모듈을 선택 한 후 


Execute Gradle Task (동그란 초록 버튼) 을 눌러주시면 


Run Gradle Task라는 다이얼로그가 뜨는데 거기에 커맨드 라인에 assembleRelease를 입력하고 오케이를 눌러주면


build/ouputs/aar/ 하위에 모듈명-realease.arr 파일이 생성됩니다.



'android' 카테고리의 다른 글

android studio svn share (프로젝트 공유하기)  (0) 2017.06.29

android studio svn share (프로젝트 공유하기)

android

프로젝트를 생성하여 작업 후 공유하기 전


File > Settings > Version Control > Ignore Files


에서


Directory : .gradle

Directory  .idea

Directory : build/

Directory : app/build/

Mask : *.iml

File : local.properties


위 파일들을  ignore 등록해준다.

이후 VCS > Import into version control > Share Project


'android' 카테고리의 다른 글

android studio 에서 arr 생성하기  (0) 2017.06.29

google map api travel mode 사용시 zoom 조정하기

script

Google map api 를 이용하여 길찾기 개발시...

자동으로 지도가 길의 시작점과 끝점이 전부 보이는 영역으로 확대되며 이동하게 되는데요,


DirectionsRenderer 생성시 preserveViewport 프로퍼티 값을 true 로 주면 

자동으로 zoom in, out, move 하지 않고 현재의 지도 위치에 이동경로를 표시해 주게 됩니다.


function initMap() {

var directionsDisplay = new google.maps.DirectionsRenderer({

preserveViewport : true

});

var directionsService = new google.maps.DirectionsService;



android ndk ffmpeg 컴파일하기 #1 20161028 수정판

ffmpeg

- 컴파일 환경 셋팅

 

Cygwin 등을 설치하여 윈도우에서 컴파일 할 수 있지만 가장 확실한 방법은 리눅스에서 컴파일 하는 것입니다.

접속할 수 있는 리눅스 서버가 있다면 좋고, 아니면 VM 을 이용해서 CentOS 7 버전을 설치해 줍니다.

CentOS 라면 7 버전이 편리합니다. (컴파일시 등)

 

컴파일에 사용할 계정을 하나 만들고 ndk 를 다운 받습니다.

 

useradd mistyi

su - mistyi

 

mkdir android

cd android

 

- ndk 설치

 

http://developer.android.com/ndk/downloads/index.html

 

에서 상황에 맞는 ndk 를 다운 받습니다.

 

혹시 wget 이 없다면 설치해줍니다. root 권한으로

yum -y install wget

 

wget https://dl.google.com/android/repository/android-ndk-r13-linux-x86_64.zip


unzip android-ndk-r13-linux-x86_64.zip

 

android-ndk-r13 라는 폴더로 설치가 됩니다.

ndk 폴더를 만들고 이동해주었습니다. 그냥...

 

mkdir ndk
mv android-ndk-r13 ./ndk/

 

- ffmpeg 소스 다운로드

 

ffmpeg 을 아래 주소에서 다운로드 받습니다.

 

http://ffmpeg.org/download.html

 

wget http://ffmpeg.org/releases/ffmpeg-3.2.tar.bz2

 

bz2 압축을 풀 수 없을 경우 root 권한으로

yum install bzip2

 

tar xvf ffmpeg-3.2.tar.bz2

 

압축이 풀린 소스를 ndk 의 sources 폴더로 옮겨줍니다.

 

mv ffmpeg-3.2 ./android-ndk-r13/sources/

 

- 툴채인을 이용한 ffmpeg 의 빌드

 

cd ndk/android-ndk-r13/sources/ffmpeg-3.2/

vi build_android.sh

 

#!/bin/bash
NDK=/home/mistyi/android/ndk/android-ndk-r13
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one

 

chmod 755 build_android.sh

./build_android.sh

 

위의 스크립트를 수행하면 없던 android 라는 폴더가 생성됩니다.

 

cd android/arm

ls -al

 

합계 8
drwxrwxr-x. 8 mistyi mistyi 4096  9월 24 02:24 include
drwxrwxr-x. 3 mistyi mistyi 4096  9월 24 02:24 lib

 

- ndk-build 를 수행하기 위한 준비

 

vi /home/mistyi/android/ndk/android-ndk-r13/sources/ffmpeg-3.2/android/arm/Android.mk

 

LOCAL_PATH:= $(call my-dir) 

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec
LOCAL_SRC_FILES:= lib/libavcodec.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat
LOCAL_SRC_FILES:= lib/libavformat.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale
LOCAL_SRC_FILES:= lib/libswscale.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil
LOCAL_SRC_FILES:= lib/libavutil.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavfilter
LOCAL_SRC_FILES:= lib/libavfilter.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libwsresample
LOCAL_SRC_FILES:= lib/libswresample.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

mkdir jni

 

심플한 예제를 가지고 ffmpeg library 들을 만들어낼 것입니다.

tutorial02.c, kr_co_joytune_androidffmpegtutorial02_MainActivity.h 파일은 첨부한 파일을 참고하시고

jni 폴더에 넣어주세요.

 

 

jni.zip

 

 

그리고 jni 폴더에 Android.mk, Application.mk 파일을 작성해 줍니다.

 

vi /home/mistyi/android/ndk/android-ndk-r13/sources/ffmpeg-3.2/android/arm/jni/Android.mk

 

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := tutorial02
LOCAL_SRC_FILES := tutorial02.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz -landroid
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil libswresample

include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-3.2/android/arm)

 

vi /home/mistyi/android/ndk/android-ndk-r13/sources/ffmpeg-3.2/android/arm/jni/Application.mk

 

APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-10

 

(armeabi-v7a 은 neon 관련 명령어셋이 추가됨으로써 연산량이 증가해 멀티미디어 성능이 향상된것이라고 합니다)

 

- ndk-build

 

cd /home/mistyi/android/ndk/android-ndk-r13/sources/ffmpeg-2.8/android/arm

 

/home/mistyi/android/ndk/android-ndk-r13/ndk-build

 

완료 후 폴더를 확인해보면 몇개의 디렉토리가 추가된 것이 보입니다.

 

합계 16
-rw-rw-r--. 1 mistyi mistyi 1054  9월 24 03:40 Android.mk
drwxrwxr-x. 8 mistyi mistyi 4096  9월 24 03:27 include
drwxrwxr-x. 2 mistyi mistyi 4096  9월 24 03:38 jni
drwxrwxr-x. 3 mistyi mistyi 4096  9월 24 03:27 lib
drwxrwxr-x. 4 mistyi mistyi   38  9월 24 03:40 libs
drwxrwxr-x. 3 mistyi mistyi   18  9월 24 03:40 obj

 

[mistyi@localhost libs]$ ll libs/armeabi
합계 13036
-rwxr-xr-x. 1 mistyi mistyi 10764156  9월 24 03:40 libavcodec.so
-rwxr-xr-x. 1 mistyi mistyi  1778304  9월 24 03:40 libavformat.so
-rwxr-xr-x. 1 mistyi mistyi   386468  9월 24 03:40 libavutil.so
-rwxr-xr-x. 1 mistyi mistyi   390548  9월 24 03:40 libswscale.so
-rwxr-xr-x. 1 mistyi mistyi    17712  9월 24 03:40 libtutorial02.so
[mistyi@localhost libs]$ ll libs/armeabi-v7a/
합계 13036
-rwxr-xr-x. 1 mistyi mistyi 10764156  9월 24 03:40 libavcodec.so
-rwxr-xr-x. 1 mistyi mistyi  1778304  9월 24 03:40 libavformat.so
-rwxr-xr-x. 1 mistyi mistyi   386468  9월 24 03:40 libavutil.so
-rwxr-xr-x. 1 mistyi mistyi   390548  9월 24 03:40 libswscale.so
-rwxr-xr-x. 1 mistyi mistyi    17720  9월 24 03:40 libtutorial02.so 

 

저기에 생성된 libs 와 include(헤더파일들이 모여있습니다) 을 필요한 프로젝트에 옮겨 사용하시면 됩니다.

 

예를들어 안드로이드 스튜디오의 ffmpeg 이 필요한 다른 프로젝트에 so 파일과 include 파일이 위치된 모습을 보여드릴께요.

 

 

 

 

위와 같이 jni 폴더 아래에 위치해 주시면 되요.

 

작성중....

 

'ffmpeg' 카테고리의 다른 글

ffmpeg 사라진 함수들 수정하는 방법  (0) 2015.09.25
android ndk ffmpeg 컴파일하기 #1  (1) 2015.09.23

ffmpeg 사라진 함수들 수정하는 방법

ffmpeg

시간이 좀 지난 프로젝트의 ffmpeg 버전을 최신버전으로 하여 함께 컴파일 했더니 몇가지 에러와 만나게 되었습니다.

 

AVStream *  av_new_stream (AVFormatContext *s) ->

AVStream *  avformat_new_stream (AVFormatContext *s, const AVCodec *c)

 

int  av_find_stream_info (AVFormatContext *ic) ->

int  avformat_find_stream_info (AVFormatContext *ic, AVDictionary **options)

 

deprecated 된 함수들은 아래를 참고하여 수정해 주시면 됩니다.


 


-    if ((err = av_find_stream_info(fmt_ctx)) < 0) {
+    if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {


     for (i = 1; i < pmp->num_streams; i++) {
-        AVStream *ast = av_new_stream(s, i);
+        AVStream *ast = avformat_new_stream(s, NULL);
         if (!ast)
             return AVERROR(ENOMEM);
+        ast->id = i;
         ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
         ast->codec->codec_id = audio_codec_id;
         ast->codec->channels = channels;

'ffmpeg' 카테고리의 다른 글

android ndk ffmpeg 컴파일하기 #1 20161028 수정판  (1) 2016.10.31
android ndk ffmpeg 컴파일하기 #1  (1) 2015.09.23

android ndk ffmpeg 컴파일하기 #1

ffmpeg

- 컴파일 환경 셋팅

 

Cygwin 등을 설치하여 윈도우에서 컴파일 할 수 있지만 가장 확실한 방법은 리눅스에서 컴파일 하는 것입니다.

접속할 수 있는 리눅스 서버가 있다면 좋고, 아니면 VM 을 이용해서 CentOS 7 버전을 설치해 줍니다.

CentOS 라면 7 버전이 편리합니다. (컴파일시 등)

 

컴파일에 사용할 계정을 하나 만들고 ndk 를 다운 받습니다.

 

useradd mistyi

su - mistyi

 

mkdir android

cd android

 

- ndk 설치

 

http://developer.android.com/ndk/downloads/index.html

 

에서 상황에 맞는 ndk 를 다운 받습니다.

 

혹시 wget 이 없다면 설치해줍니다. root 권한으로

yum -y install wget

 

wget http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin

 

chmod +x android-ndk-r10e-linux-x86_64.bin

 

./android-ndk-r10e-linux-x86_64.bin

 

mv android-ndk-r10e 라는 폴더로 설치가 됩니다.

ndk 폴더를 만들고 이동해주었습니다. 그냥...

 

mkdir ndk
mv android-ndk-r10e ./ndk/

 

- ffmpeg 소스 다운로드

 

ffmpeg 을 아래 주소에서 다운로드 받습니다.

 

https://ffmpeg.org/download.html

 

wget http://ffmpeg.org/releases/ffmpeg-2.8.tar.bz2

 

bz2 압축을 풀 수 없을 경우 root 권한으로

yum install bzip2

 

tar xvf ffmpeg-2.8.tar.bz2

 

압축이 풀린 소스를 ndk 의 sources 폴더로 옮겨줍니다.

 

mv ffmpeg-2.8 ./ndk/android-ndk-r10e/sources/

 

- 툴채인을 이용한 ffmpeg 의 빌드

 

cd ./ndk/android-ndk-r10e/sources/ffmpeg-2.8

vi build_android.sh

 

#!/bin/bash
NDK=/home/mistyi/android/ndk/android-ndk-r10e
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one

 

chmod 755 build_android.sh

./build_android.sh

 

위의 스크립트를 수행하면 없던 android 라는 폴더가 생성됩니다.

 

cd android/arm

ls -al

 

합계 8
drwxrwxr-x. 8 mistyi mistyi 4096  9월 24 02:24 include
drwxrwxr-x. 3 mistyi mistyi 4096  9월 24 02:24 lib

 

- ndk-build 를 수행하기 위한 준비

 

vi /home/mistyi/android/ndk/android-ndk-r10e/sources/ffmpeg-2.8/android/arm/Android.mk

 

LOCAL_PATH:= $(call my-dir) 

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec
LOCAL_SRC_FILES:= lib/libavcodec.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat
LOCAL_SRC_FILES:= lib/libavformat.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale
LOCAL_SRC_FILES:= lib/libswscale.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil
LOCAL_SRC_FILES:= lib/libavutil.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libavfilter
LOCAL_SRC_FILES:= lib/libavfilter.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)
LOCAL_MODULE:= libwsresample
LOCAL_SRC_FILES:= lib/libswresample.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

 

mkdir jni

 

심플한 예제를 가지고 ffmpeg library 들을 만들어낼 것입니다.

tutorial02.c, kr_co_joytune_androidffmpegtutorial02_MainActivity.h 파일은 첨부한 파일을 참고하시고

jni 폴더에 넣어주세요.

 

 

jni.zip

 

 

그리고 jni 폴더에 Android.mk, Application.mk 파일을 작성해 줍니다.

 

vi /home/mistyi/android/ndk/android-ndk-r10e/sources/ffmpeg-2.8/android/arm/jni/Android.mk

 

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := tutorial02
LOCAL_SRC_FILES := tutorial02.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz -landroid
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil libswresample

include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.8/android/arm)

 

vi /home/mistyi/android/ndk/android-ndk-r10e/sources/ffmpeg-2.8/android/arm/jni/Application.mk

 

APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-10

 

(armeabi-v7a 은 neon 관련 명령어셋이 추가됨으로써 연산량이 증가해 멀티미디어 성능이 향상된것이라고 합니다)

 

- ndk-build

 

cd /home/mistyi/android/ndk/android-ndk-r10e/sources/ffmpeg-2.8/android/arm

 

ndk-build

 

완료 후 폴더를 확인해보면 몇개의 디렉토리가 추가된 것이 보입니다.

 

합계 16
-rw-rw-r--. 1 mistyi mistyi 1054  9월 24 03:40 Android.mk
drwxrwxr-x. 8 mistyi mistyi 4096  9월 24 03:27 include
drwxrwxr-x. 2 mistyi mistyi 4096  9월 24 03:38 jni
drwxrwxr-x. 3 mistyi mistyi 4096  9월 24 03:27 lib
drwxrwxr-x. 4 mistyi mistyi   38  9월 24 03:40 libs
drwxrwxr-x. 3 mistyi mistyi   18  9월 24 03:40 obj

 

[mistyi@localhost libs]$ ll libs/armeabi
합계 13036
-rwxr-xr-x. 1 mistyi mistyi 10764156  9월 24 03:40 libavcodec.so
-rwxr-xr-x. 1 mistyi mistyi  1778304  9월 24 03:40 libavformat.so
-rwxr-xr-x. 1 mistyi mistyi   386468  9월 24 03:40 libavutil.so
-rwxr-xr-x. 1 mistyi mistyi   390548  9월 24 03:40 libswscale.so
-rwxr-xr-x. 1 mistyi mistyi    17712  9월 24 03:40 libtutorial02.so
[mistyi@localhost libs]$ ll libs/armeabi-v7a/
합계 13036
-rwxr-xr-x. 1 mistyi mistyi 10764156  9월 24 03:40 libavcodec.so
-rwxr-xr-x. 1 mistyi mistyi  1778304  9월 24 03:40 libavformat.so
-rwxr-xr-x. 1 mistyi mistyi   386468  9월 24 03:40 libavutil.so
-rwxr-xr-x. 1 mistyi mistyi   390548  9월 24 03:40 libswscale.so
-rwxr-xr-x. 1 mistyi mistyi    17720  9월 24 03:40 libtutorial02.so 

 

저기에 생성된 libs 와 include(헤더파일들이 모여있습니다) 을 필요한 프로젝트에 옮겨 사용하시면 됩니다.

 

예를들어 안드로이드 스튜디오의 ffmpeg 이 필요한 다른 프로젝트에 so 파일과 include 파일이 위치된 모습을 보여드릴께요.

 

 

 

 

위와 같이 jni 폴더 아래에 위치해 주시면 되요.

 

작성중....