본문 바로가기

Programming/C++

[ffmpeg] Visual Studio에서 ffmpeg 사용하는 방법

Window환경에서 ffmpeg을 사용하기 위해 얼마나 삽질했던가...

 

아래는 ffmpeg shared library를 직접 컴파일 한것..(2012년 9월 16일 현재 최신 버전) + 에러나는 부분 조금 수정한 것.. int64니 뭐니 해서 에러 나는 헤더파일들을 좀 수정해줬다. 컴파일 하는건 msys, mingw등등 여러가지 써서 직접 했음..

 ffmpeg.zip

 

사용 법은.. C++에서 사용할때는 아래와 같이.. C에서 사용할 땐 extern "C"를 제거하고 사용 하면 된다.

 

#define inline _inline //이걸 제일 위에 써줘야 한다. 

 

extern "C" {
#include "include/libswscale/swscale.h"
#include "include/libavformat/avformat.h"
#include "include/libavcodec/avcodec.h"
}
#pragma comment( lib, "avcodec.lib");
#pragma comment( lib, "avformat.lib");
#pragma comment( lib, "avutil.lib");
#pragma comment( lib, "swscale.lib");

 

이를 위에 쓰고 컴파일 해주면 된다.

lib파일은 소스파일이 있는 경로에 같이 넣어주면 된다.

 

inttypes.h는 vs의 기본 include폴더에 넣어주면 됨.

 

extern "C" 생각 안하고 그냥 쓸려다가 1주일 삽질 한것 생각하면 맘이 아프다...ㅜㅜ


컴파일 시 ''UINT64_C': identifier not found'라고 뜬다면 아래의 구문을 common.h의 상단에 추가해야 한다.

#ifndef INT64_C

#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

 

 

추가:

최신버전은 예전거랑 좀 다른 것 같다..

예전에는 av_open_input_file 이었던 메소드가 avformat_open_input 으로 바뀌어 있음..

이런게 꽤 되는 것 같다.. avcodec_init()도 사용 안되는 것 같고.. 흐음 공부할게 많구만.


출처 : http://roter.pe.kr/

로터와 프로그래밍

'Programming > C++' 카테고리의 다른 글

[MFC] 리듬 액션 게임 자동 노트 생성  (1) 2012.11.12