요즘 스마트폰 성능도 좋아지고, 망과의 데이터 속도도 좋아짐에 따라, 멀티미디어 서비스 분야에 더욱더 초점이 맞추어지고 있습니다. 이러한 분위기에 발맞추어 멀티미디어 분야에 대해 스터디 중인데요...

 

http://www.androidpub.com/index.php?mid=android_dev_info&page=1&search_target=tag&search_keyword=FFmpeg&document_srl=1645684 

에 스터디 하기 좋은 자료가 있어서 따라해 보았습니다.

 

아래 웹페이지에서는 테스트시 사용할 수 있는 전체코드를 배포하고 있습니다.

http://www.androidpub.com/index.php?_filter=search&mid=android_dev_info&search_target=title&search_keyword=ffmpeg&document_srl=1648388

 

준비물 및 빌드 방법은 다음과 같습니다.

 

1) cygwin 

   윈도우 환경에서 cross compiler 로 빌드하기 위한 준비단계로, cygwin 을 설치합니다. 아래 버전을 사용하고 있습니다.

$ uname -a
CYGWIN_NT-6.1 wolf-PC 1.7.10(0.259/5/3) 2012-02-05 12:36 i686 Cygwin

 

2) NDK 설치

   http://developer.android.com/sdk/ndk/index.html 에서 다운로드 받을 수 있습니다.

   32비트 환경에서 작업하므로, android-ndk-r9c-windows-x86.zip 를 다운로드 하였습니다. 설치디렉토리를 환경설정의 PATH 에 등록해 줍니다.( 예: C:\work\android-ndk-r9c)

 

3) standalone tool 설치

   다운로드 받은 NDK 안에서 아래 명령어를 통해 추출해 낼 수 있습니다. cygwin Terminal 을 관리자 권한으로 실행 후, 아래 명령을 입력합니다.

  

$ /cygdrive/c/work/android-ndk-r9c/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=/android-toolchain

 

   관리자 권한으로 실행하지 않으면, 아래와 같은 Permission denied 에러 메시지가 출력됩니다.

$ make-standalone-toolchain.sh --platform=android-8 --install-dir=/path/to/target --ndk-dir=/path/to/android-ndk/
Auto-config: --toolchain=arm-linux-androideabi-4.4.3
Copying prebuilt binaries...
Copying sysroot headers and libraries...
Copying libstdc++ headers and libraries...
mkdir: cannot create directory `/tmp/build-6212/standalone/arm-linux-androideabi-4.4.3/arm-linux-androideabi': Permission denied
ERROR: Cannot copy to directory: /tmp/build-6212/standalone/arm-linux-androideabi-4.4.3/arm-linux-androideabi/include/c++/4.4.3

 

4) android app project 생성

   http://www.androidpub.com/index.php?mid=android_dev_info&page=1&search_target=tag&search_keyword=FFmpeg&document_srl=1645684  를 참고하여 생성합니다.  필자는 E:\212.JavaTraning\FFmpeg 에 생성하였는데, 원하는 위치에 하면됩니다.

   프로젝트 디렉토리 안에 jni 디렉토리를 생성합니다. ( E:\212.JavaTraning\FFmpeg\jni 처럼)

 

5) ffmpeg 소스 및 jni 를 이용하기 위한 소스 추가

  http://www.androidpub.com/index.php?_filter=search&mid=android_dev_info&search_target=title&search_keyword=ffmpeg&document_srl=1648388 에서 소스를 다운로드 하여 jni 디렉토리 하위 내용을 전부 해당 위치로 복사해 옵니다. (안드로이드 앱 프로젝트 소스도 포함되어 있으니 참고하면 됩니다.)

  변경 사항들에대해서 알고 싶으면 위의 URL 로 가서, 강좌를 쭉~ 보시기 바랍니다.

 

  a. config.sh 에서

  export ANDROID_ROOT=/cygdrive/c/my-android-toolchain  를 자신의 환경에 맞게 바꾸어 줍니다.

  필자는 export ANDROID_ROOT=/android-toolchain 로 변경함. 

 

   b. C:\ffmpegtmp 디렉토리를 생성합니다. configure 명령을 실행하면서 중간에 필요한 파일들의 임시 저장소로 사용됩니다.

 

6) ffmpeg source 빌드

   cygwin terminal 에서 jni/ffmpeg 위치로 이동합니다. ( 필자는 /cygdrive/e/212.JavaTraning/FFmpeg/jni/ffmpeg 위치)

 

   $ .  ./config.sh  를 입력하여 정상적으로 configure 가 실행된다면, 해당 디렉토리에 config.h 가 생깁니다.

 

   이 명령이 실행되면서 출력되는 메시지를 보면, no such file or directory 들도 보이고,

   WARNING: /android-toolchain/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
   이런 warning 도 보이지만, config.h 가 최종 생성됩니다.

   (사실, 전체소스안에 이미 config.h 가 생성되어 있는데, 새로이 생성해 보았습니다.)

 

   그 후, android app project 디렉토리로 이동하여 (/cygdrive/e/212.JavaTraning/FFmpeg)

  

  $ ndk-build 명령을 실행합니다.

 

  실행시 아래와 같은 에러가 발생한다면...

 

jni/ffmpeg/libavcodec/srtdec.c: In function 'srt_to_ass':

jni/ffmpeg/libavcodec/srtdec.c:113:61: error: format not a string literal and no format arguments [-Werror=format-security]

jni/ffmpeg/libavcodec/srtdec.c:149:53: error: format not a string literal and no format arguments [-Werror=format-security]

cc1.exe: some warnings being treated as errors

 

/cygdrive/c/work/android-ndk-r9c/build/core/build-binary.mk:386: recipe for target `obj/local/armeabi-v7a/objs/avcodec/srtdec.o' failed

make: *** [obj/local/armeabi-v7a/objs/avcodec/srtdec.o] Error 1

 

  >>>웹서핑을 해보니 이런 내용이 있습니다. 

srtdec.c 파일 113 라인의 snprintf 부분에서 오류가 났습니다. NDK 버젼이 바뀌면서 snprintf "%s" 같은 포멧 선언이 빠지면 컴파일시 warring 나오던데서 에러가 나오게 변경되서 컴파일이 겁니다. 설명대로 CFLAG -Werror=format-security 추가하셔도 되고, snprintf 사이에 "%s" 같은 것을 넣어주셔도 됩니다.
 예) out += snprintf(out, out_end-out, "%s", stack[j].param[i]); 필자는 이런식으로 수정해서 빌드했습니다.

  제법 시간이 흐린 뒤, 빌드에 성공하면, {android app project directory}\FFmpeg\libs\armeabi-v7a\ 에 libbasicplayer.so 가 생성됩니다.

 

7) android app project build

   eclipse 에서 해당 프로젝트를 열고, 안드로이드 폰을 usb 케이블로 PC와 연결후, build 버튼을 선택합니다. 필자는 아래 동영상이 플레이됩니다. (윈도우즈 OS에 기본적으로 있는 "야생.wmv" 를 실행시켜 보았습니다. 소리는 나지 않고요... ^^;; audio codec에 대한 디코딩 부분을 확인해 봐야겠죠...)

 

  

 

'Biz > Multimedia' 카테고리의 다른 글

How to build Mediainfo open source in VS2010  (0) 2013.12.07
OpenCV in Linux  (0) 2013.11.29
Visual Studio Build error - opencv_core247d.lib  (0) 2013.11.14
OpenCV & VS2010  (0) 2013.11.14
ffmpeg compile in Ubuntu  (0) 2013.10.14
by JNexOnSoft 2014. 2. 3. 00:11

media file 의 정보를 알려주는 MediaInfo 프로그램의 소스를 아래 사이트에서 다운로드 가능하다.

- http://mediaarea.net/EN/MediaInfo/Download/Source

- http://mediaarea.net/en/MediaInfo/Support/Build_From_Sources/ThirdParty

 

1. wxWidgets 설치

 

  wxWidgets is not built into useable libraries when you "install" the wxMSW installer. This is because there are so many configurable elements, which is precisely what the setup.h you refer to is for.
If you just want to build it with default options as quickly as possible and move on, here is how:
 

  1) Start the "Visual Studio Command Prompt." You'll find this in the start menu under "Microsoft Visual Studio -> Visual Studio Tools".

  2) Change to folder: [WXWIN root]\build\msw

  3) Build default debug configuration: nmake -f makefile.vc BUILD=debug

  4) Build default release configuration: nmake -f makefile.vc BUILD=release

  5) Make sure the DLLs are in your PATH. They'll be found in [WXWIN root]\lib\vc_dll

  6) Under the DLL folder mentioned above, you will find subfolders for each build variant (The instructions above made two, debug and release.) In each variant folder you'll find a 'wx' folder containing a 'setup.h" file. You'll see that the setup.h files are actually different for each build variant. These are the folders you need to add to your project build configuration include path, one per build variant. So, for example, you'd add [WXWIN root]\lib\vc_dll\mswud to the include path for your debug build, [WXWIN root]\lib\vc_dll\mswu for your release build.

  7) It is possible to build lots of other variant combinations: static libs, monolithic single library, non-Unicode, etc. See [WXWIN root]\docs\msw\install.txt for much more extensive instructions.

 

참고) wxWidgets is a C++ library that lets developers create applications for Windows, OS X, Linux and UNIX on 32-bit and 64-bit architectures as well as several mobile platforms including Windows Mobile, iPhone SDK and embedded GTK+. (http://www.wxwidgets.org/)


2. VS 에서 설정

 

  1) MediaInfo_GUI 프로젝트를 "StartUp Project" 로 설정한다.

  2) include path 추가 :  MeidaInfo_GUI 프로젝트의 속성 > Configuration Properties > C/C++ > General > Additional Include Directories > 아래 내용을 추가한다.

       - {설치디렉토리}\wxWidgets-3.0.0\include\msvc

       - {설치디렉토리}\wxWidgets-3.0.0\include

  3) lib path 추가 :  MeidaInfo_GUI 프로젝트의 속성 > Configuration Properties > Linker > General > Additional Library Directories > 아래 내용을 추가한다

      - {설치디렉토리}\wxWidgets-3.0.0\lib\vc_lib

  4) lib 이름변경 : mediainfo 소스에서 wxbase28ud.lib, wxmsw28ud_core.lib, wxmsw28ud_html.lib 들을 사용하고 있는데, wxWidgets 3.0 버전을 설치하였으므로, wxbase30ud.lib, wxmsw30ud_core.lib, wxmsw30ud_html.lib 으로 변경해 준다.

 

3. Debug mode 로 빌드시 링크 에러 발생

 

디버그 모드로 빌드시, 아래와 같은 링크에러가 발생한다면,

Project Property ==>  Configuration Properties ==> C/C++ ==> Code Generation ==> Runtime Library ==> Multi-threaded Debug DLL (/MDd) 로 모든 프로젝트들에 대해서 변경 후,

rebuild 한다.

 

<참고 : 링크에러 메시지>

1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmtd.lib(xthrow.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmtd.lib(xthrow.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in Core.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in Core.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in Core.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::clear(int,bool)" (?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in CommandLine_Parser.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: int __thiscall std::ios_base::setf(int,int)" (?setf@ios_base@std@@QAEHHH@Z) already defined in ZenLib.lib(Ztring.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::precision(__int64)" (?precision@ios_base@std@@QAE_J_J@Z) already defined in libcpmtd.lib(iomanip.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in CommandLine_Parser.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: virtual __thiscall std::basic_ostream<char,struct std::char_traits<char> >::~basic_ostream<char,struct std::char_traits<char> >(void)" (??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in CommandLine_Parser.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: __thiscall std::basic_ios<char,struct std::char_traits<char> >::basic_ios<char,struct std::char_traits<char> >(void)" (??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in CommandLine_Parser.obj
...

1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: ___iob_func already defined in LIBCMTD.lib(_file.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _abort already defined in LIBCMTD.lib(abort.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _wcslen already defined in LIBCMTD.lib(wcslen.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
...

1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Win32\Debug\MediaInfo.exe : fatal error LNK1169: one or more multiply defined symbols found

'Biz > Multimedia' 카테고리의 다른 글

android app with ffmpeg  (0) 2014.02.03
OpenCV in Linux  (0) 2013.11.29
Visual Studio Build error - opencv_core247d.lib  (0) 2013.11.14
OpenCV & VS2010  (0) 2013.11.14
ffmpeg compile in Ubuntu  (0) 2013.10.14
by JNexOnSoft 2013. 12. 7. 18:47

1. OpenCV 패키지 다운로드
- http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.7/

(현재시점 2.4.7)

 

2. 필요한 파일들을 받는다.
# apt-get install libssl-dev openssl
# apt-get install pkg-config
# apt-get install libgtk2.0-0
# apt-get install libgtk2.0-dev
# apt-get install libavformat-dev libswscale-dev
# apt-get install libjpeg-dev
# apt-get install cmake

# apt-get update
# apt-get install gcc-4.3
# apt-get install build-essential

 

3. OpenCV 압축파일을 해제한다.
# tar xzvf opencv-2.4.7.tar.gz // 압축을 푼다.
# cd opencv-2.4.7
# mkdir release
# cd release

 

4. 중간 파일 빌드 (다시 컴파일 할 경우 여기부터)
# cmake -D CMAKE_BUILD_TYPE=release -D CMAKE_INSTALL_PREFIX=/root/lib -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ../
or
# cmake . -DUSE_SSE=ON -DUSE_SSE2=ON

 

5. 최종 바이너리 빌드
# make
# make install
# ldconfig

 

6. sample code - mywebcam.c

#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <objdetect/objdetect.hpp>
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>

 

char key;
int main()
{
  CvCapture *capture = cvCaptureFromCAM(CV_CAP_ANY);
  //capture.set(CV_CAP_PROP_FRAME_WIDTH, 400);
  //capture.set(CV_CAP_PROP_FRAME_HEIGHT, 300);
  cvNamedWindow("CAM",1);
  cvResizeWindow("CAM", 400, 300);
 
  while(1)
  {
    IplImage *image = cvQueryFrame(capture);
    cvShowImage("CAM", image);
   
    key = cvWaitKey(10);
    // ESC - break;
    if(key >= 27 ) break;
  }
 
  cvReleaseCapture(&capture);
  cvDestroyWindow("CAM");

  return 0;
}


 

7. make file - mywebcam.mak (mywebcam.mak)

#
# http://www.gnu.org/software/make/manual/make.html
#
CC:=gcc

INCDIR:= -I/root/lib/include -I/root/lib/include/opencv -I/root/lib/include/opencv2
LIBDIR:= -L/root/lib/lib

CFLAGS:=-Wall #-ggdb

LDFLAGS:= -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

EXE:= mywebcam.out

#
# This is here to prevent Make from deleting secondary files.
#
.SECONDARY:
 
#
# $< is the first dependency in the dependency list
# $@ is the target name
#
all: dirs $(addprefix bin/, $(EXE)) tags

dirs:
 mkdir -p obj
 mkdir -p bin

tags: *.c

bin/%.out: obj/%.o
 $(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) $(LDFLAGS) -o $@ $<

obj/%.o : %.c
 $(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) $(INCLUDES) -c -o $@ $<

clean:
 rm -f obj/*
 rm -f bin/*

 

8. make & execution

# make -f mywebcam.mak

# ./bin/mywebcam.out

 

 

 

'Biz > Multimedia' 카테고리의 다른 글

android app with ffmpeg  (0) 2014.02.03
How to build Mediainfo open source in VS2010  (0) 2013.12.07
Visual Studio Build error - opencv_core247d.lib  (0) 2013.11.14
OpenCV & VS2010  (0) 2013.11.14
ffmpeg compile in Ubuntu  (0) 2013.10.14
by JNexOnSoft 2013. 11. 29. 14:42

1>opencv_core247d.lib(out.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

이런 에러가 발생하면 Project Property> Linker > Advanced > Target Machine > 에서 설정을 변경하라고 한다. x64로 ...  (JNexOnSoft : 해도 안되더만...)

 

 

'Biz > Multimedia' 카테고리의 다른 글

android app with ffmpeg  (0) 2014.02.03
How to build Mediainfo open source in VS2010  (0) 2013.12.07
OpenCV in Linux  (0) 2013.11.29
OpenCV & VS2010  (0) 2013.11.14
ffmpeg compile in Ubuntu  (0) 2013.10.14
by JNexOnSoft 2013. 11. 14. 15:59

1. OpenCV 패키지 다운로드
- http://sourceforge.net/projects/opencvlibrary/
(현재시점 2.4.7)

 

2. 시스템 환경변수 추가
- 변수이름 : OPENCV_BUILD
- 변수 값 : C:\openCV\build

 

3. 시스템 Path 변수에 추가
- %OPENCV_BUILD%\x86\vc10\bin;

 

4. VS2010 에서 Win32 console 프로젝트 생성 후 코드 추가

<MyOpenCV.cpp>


#include "stdafx.h"

// { for show_image()
#include <opencv\cv.h>
#include <opencv\highgui.h>
// for show_image() }

//
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

void show_image();
void camera_capture();
char key;

int _tmain(int argc, _TCHAR* argv[])
{
 //show_image();
 camera_capture();

 return 0;
}

void show_image()
{
 IplImage * image = cvLoadImage("Hydrangeas.jpg");

 cvShowImage("test image", image);
 cvWaitKey(0);

 cvReleaseImage(&image);
}

void camera_capture()
{
 cvNamedWindow("Camera_Output", 1);    //Create window   
 CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);  //Capture using any camera connected to your system   
 while(1){ //Create infinte loop for live streaming        
  IplImage* frame = cvQueryFrame(capture); //Create image frames from capture       
  cvShowImage("Camera_Output", frame);   //Show image frames on created window       
  key = cvWaitKey(10);     //Capture Keyboard stroke       
  if (char(key) == 27){           
   break;      //If you hit ESC key loop will break.       
  }   
 }   
 cvReleaseCapture(&capture); //Release capture.   
 cvDestroyWindow("Camera_Output"); //Destroy Window
}

 


3. Project Property > C/C++ > General > Additional Include Directories
$(OPENCV_BUILD)\include


4. Project Property > Linker > General > Additional Library Directories
$(OPENCV_BUILD)\x86\vc10\lib

>> 32비트 운영체제에서 빌드 성공함

 

참고 1) VS2005 & 64비트 환경에서  $(OPENCV_BUILD)\x64\vc10\lib 로 설정한 뒤,
빌드하였더니 아래와 같은 링크 에러가 발생함.
1>MyOpenCV.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _main
1>MyOpenCV.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main
1>MyOpenCV.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _main
1>MyOpenCV.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _main
1>E:\998.HaHa\myproject\MyOpenCV\Debug\MyOpenCV.exe : fatal error LNK1120: 4 unresolved externals

 

 

5. Project Property > Linker > Input > Additional Dependencies
opencv_core247d.lib
opencv_imgproc247d.lib
opencv_highgui247d.lib
opencv_ml247d.lib
opencv_video247d.lib
opencv_features2d247d.lib
opencv_calib3d247d.lib


빌드 및 실행 (Esc 키를 누르면 종료함)

 

 


 

'Biz > Multimedia' 카테고리의 다른 글

android app with ffmpeg  (0) 2014.02.03
How to build Mediainfo open source in VS2010  (0) 2013.12.07
OpenCV in Linux  (0) 2013.11.29
Visual Studio Build error - opencv_core247d.lib  (0) 2013.11.14
ffmpeg compile in Ubuntu  (0) 2013.10.14
by JNexOnSoft 2013. 11. 14. 15:18

 

Compile FFmpeg on Ubuntu, Debian, or Mint

(from https://trac.ffmpeg.org/wiki/UbuntuCompilationGuide

 

This guide for supported releases of Ubuntu, Debian, and Linux Mint will provide a local install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs). This will not provide a system installation and therefore will not interfere with anything such as repository packages. Recent static builds are also available for lazy people or those who are unable to compile.


Get the Dependencies

Copy and paste the whole code box for each step.

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential git libass-dev libgpac-dev \
  libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
  libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev

JNexOnSoft : BackTrack5 R2에서는 위의 명령에 문제가 있음. Kali 1.0.5에서는 잘 수행됨.

mkdir ~/ffmpeg_sources
  • Server users can omit the ffplay and x11 dependencies: libsdl1.2-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxfixes-dev.
  • Ubuntu 10.04 Lucid users will need to install the git-core package instead of the git package. Lucid lacks the package libva-dev. This can be ignored.

Compilation & Installation

One advantage to compiling is that you can build ffmpeg to your liking. If you do not require certain encoders you may skip the relevant section and then remove the appropriate ./configure option in FFmpeg. For example, if libopus is not needed, then skip that section and then remove --enable-libopus from the Install FFmpeg section.

Yasm

Yasm is an assembler used by x264 and FFmpeg.

Ubuntu 13.04 and Mint 15 users can alternatively install the yasm package from the repository instead of compiling.

cd ~/ffmpeg_sources
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 --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
make distclean
. ~/.profile

x264

H.264 video encoder. See the x264 Encoding Guide for more information and examples.

cd ~/ffmpeg_sources
git clone --depth 1 git://git.videolan.org/x264.git
cd x264
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make
make install
make distclean

Note: You can download the nightly  x264 source snapshot as an alternative to using git.

fdk-aac

AAC audio encoder. See the AAC Encoding Guide for more information and examples.

cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean

Note: You can download a  fdk-aac source snapshot as an alternative to using git.

libmp3lame

MP3 audio encoder.

Most users can install the repository package:

sudo apt-get install libmp3lame-dev

JNexOnSoft : Kali 1.0.5 에서는 위의 명령만 실행함. 아래 소스빌드는 하지 않음.

 

Ubuntu 10.04 and Debian Squeeze users must compile:

sudo apt-get install nasm
cd ~/ffmpeg_sources
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 --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean

libopus

Opus audio decoder and encoder.

Ubuntu 13.04 and Mint 15 users can alternatively install the libopus-dev package from the repository instead of compiling.

cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
tar xzvf opus-1.0.3.tar.gz
cd opus-1.0.3
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean

libvpx

VP8/VP9 video encoder and decoder. See the vpx (WebM) Encoding Guide for more information and examples.

Ubuntu 13.04 and Mint 15 users can alternatively install the libvpx-dev package from the repository instead of compiling.

cd ~/ffmpeg_sources
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --prefix="$HOME/ffmpeg_build" --disable-examples
make
make install
make clean

Note: You can download a  libvpx source snapshot as an alternative to using git.

ffmpeg

Note: Server users should remove --enable-x11grab from the following command:

cd ~/ffmpeg_sources git clone --depth 1 git://source.ffmpeg.org/ffmpeg cd ffmpeg PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" export PKG_CONFIG_PATH ./configure --prefix="$HOME/ffmpeg_build" \ --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \ --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \ --enable-libx264 --enable-nonfree --enable-x11grab make

 

make install make distclean hash -r

Note: You can download the nightly FFmpeg source snapshot as an alternative to using git.


Finish

Installation is now complete and ffmpeg is now ready for use. Check to see if you're using your new ffmpeg:

$ ffmpeg 2>&1 | head -n1
ffmpeg version git-2013-05-18-5918b7a Copyright (c) 2000-2013 the FFmpeg developers

If you do not see FFmpeg developers in your output then something went wrong and you're probably using the  fake "ffmpeg" from the repository.

You can keep the ffmpeg_sources directory if you plan on updating later. See Updating FFmpeg below for more details followed by instructions for reverting all changes made by this guide.

 

 

JNexOnSoft : ~/ffmpeg_build/share/ffmpeg/examples/ 에 있는 소스 코드 빌드.

#PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
#export PKG_CONFIG_PATH
#make 

빌드하는데 시간 좀 걸림

 

만약 ffmepg tutorial  소스를 구하여 빌드하였는데, 아래와 같은 에러가 나온다면...

 

cc   tutorial01.o  -pthread -L/root/ffmpeg_build/lib -lavdevice -lavfilter -lpostproc -lavformat -lavcodec -lva -lXfixes -lXext -lX11 -lasound -lSDL -lx264 -lvpx -lvorbisenc -lvorbis -ltheoraenc -ltheoradec -logg -lopus -lmp3lame -lfdk-aac -lass -lz -lrt -ldl -lswresample -lswscale -lavutil -lm    -o tutorial01
tutorial01.o: In function `main':
/root/workspace/streaming/sample-code/tutorial01.c:69: undefined reference to `av_open_input_file'
/root/workspace/streaming/sample-code/tutorial01.c:77: undefined reference to `dump_format'
/root/workspace/streaming/sample-code/tutorial01.c:100: undefined reference to `avcodec_open'
/root/workspace/streaming/sample-code/tutorial01.c:128: undefined reference to `avcodec_decode_video'
/root/workspace/streaming/sample-code/tutorial01.c:134: undefined reference to `img_convert'
collect2: error: ld returned 1 exit status
make: *** [tutorial01] Error 1

 

ffmpeg이 버전업 되면서 변경된 함수들이 있어서 발생하는 문제이므로, tutorial source를 최신 버전으로 다운받으면 문제가 해결된다.

new version : https://github.com/chelyaev/ffmpeg-tutorial

 

 

- streaming test (audio 만 출력됨, from http://playready.directtaps.net/smoothstreaming/)

컴파일한 ffmpeg 에 대한 동작을 확인하고 싶으면 아래 명령을 입력한다.

#ffplay http://playready.directtaps.net/smoothstreaming/ISMAAACLCPR/Taxi3_AACLC.mp4 

 

- 로컬 PC에서 스트리밍 테스트를 하고 싶다면 아래 내용을 따라하도록 한다.

(1) ffserver.conf 수정

기본 ffserver.conf (ffserver.conf)를 하나 구하여 아래 내용을 추가한다.

------------------------------------------------

RTSPPort 7000

 

<Stream what.mp4>
Format rtp
File "/mnt/01.backup/what01.mp4"
</Stream>

------------------------------------------------

(2) ffserver 실행

# ffserver -f ./ffserver.conf

 

(3) ffplay 실행

# ffplay rtsp://{ffserver IP}:7000/what.mp4

잠시 후 동영상이 플레이 된다.

 

 

 

 

(4) what.mp4 정보

Container : MPEG-4

Video Format : AVC

Audio Format : AAC

 

참고로... ffplay 로 동영상 플레이하면 괜찮지만, tutorial source로 play하면 견디기 힘들 정도의 성능을 보임.

 


'Biz > Multimedia' 카테고리의 다른 글

android app with ffmpeg  (0) 2014.02.03
How to build Mediainfo open source in VS2010  (0) 2013.12.07
OpenCV in Linux  (0) 2013.11.29
Visual Studio Build error - opencv_core247d.lib  (0) 2013.11.14
OpenCV & VS2010  (0) 2013.11.14
by JNexOnSoft 2013. 10. 14. 11:18
| 1 |