728x90

출처 : [FFmpeg]FFmpegをVisualStudioでコンパイル→デバッグする
Guide : How to compile ffmpeg under Windows7 and VS2012
msinttypes(ISO C9x compliant stdint.h and inttypes.h for Microsoft Visual Studio)
libav/c99-to-c89
FFmpeg 소스 빌드
FFMPEG build for Windows & VS2010 (ffmpeg 빌드)
the MinGW + MSYS environment

MinGW설치

mingw-get-setup.exe 다운로드

Path 추가

C:\MinGW\bin
C:\MinGW\msys\1.0\bin

Git 설치

http://msysgit.github.io/

Path 추가

C:\Program Files (x86)\Git\bin

yasm 설치 다운로드

vsyasm-1.2.0-win64.zip 파일을 받아 압축을 풀고,
vsyasm.exe 파일을 C:\MinGW\msys\1.0\bin 폴더에 복사

C:\MinGW\msys\1.0\msys.bat 수정

call "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/vcvarsall.bat"
set path=C:/MinGW/bin;C:/MinGW/msys/1.0/bin;%path%

link.exe 이름 변경

D:\MinGW\msys\1.0\bin\link.exe와 msvc의 link.exe 이름이 동일해서
D:\MinGW\msys\1.0\bin\link.exe 파일명을 변경해야 컴파일 가능 (-> _link.exe)

pkg-config 설치 glib_2.28.1-1_win32.zip pkg-config_0.23-3_win32.zip

c99-to-c89 https://github.com/libav/c99-to-c89/downloads, ftp://ftp.videolan.org/pub/contrib/c99-to-c89/1.0.1/win32/


MSYS Shell 실행

C:\MinGW\msys\1.0\msys.bat 

 FFmpeg 소스 빌드

 

 - 작성중 -


728x90
728x90

출처
http://erato1004.tistory.com/entry/eclipse에서-static-library를-만들고-링크하여-컴파일-하기

정적(Static) 라이브러리 만들기

1. 메뉴[New] -> [C++ Project] 선택

[Project name] : testlib [입력]
[Project type] : Static Library -> Empty Project [선택]
[Toolchains] : Cygwin GCC [선택]

버튼 [Finish] 선택

프로젝트 선택 -> [New] -> [Folder] 선택

[Folder Name] : inc [입력]
버튼 [Finish] 선택

아래 그림과 같이 폴더 구조와 파일을 생성

testlib.h

/*
 * testlib.h
 *
 *  Created on: 2012. 9. 6.
 *      Author: bluexmas
 */

#ifndef LIBTEST_H_
#define LIBTEST_H_

extern const char* get_version();

#endif /* LIBTEST_H_ */

testlib.cpp

/*
 * testlib.cpp
 *
 *  Created on: 2012. 9. 6.
 *      Author: bluexmas
 */

#include "testlib.h"

const char* get_version() {
  return "testlib ver 0.1";
}

inclue 폴더 설정
프로젝트 선택 -> [Properties] 선택


[C/C++ Build] -> [Settings] -> [Cygwin C++ Compiler] -> [Includes] - 버튼 [Add] 선택

버튼 [Workspace...] 선택

[testlib] -> [inc] 폴더 선택

버튼 [OK] 선택

추가된 Include 폴더 확인

키 [Ctrl] + [B] 선택하여 컴파일하고, [Debug] 폴더 밑에 libtestlib.a 확인

정적 라이브러리 사용하기

1. 메뉴[New] -> [C++ Project] 선택

[Project name] : testlib_sample [입력]
[Project type] : Executable -> Empty Project [선택]
[Toolchains] : Cygwin GCC [선택]

버튼 [Finish] 선택

testlib_sample.cpp 파일

#include 
#include "testlib.h"

int main(int argc, char **argv) {
	fprintf(stdout, "%s", get_version());
	return 0;
}

inclue 폴더 설정

Libraries 추가
Library search path 추가

키 [Ctrl] + [B] 선택하여 컴파일

실행해서 확인하기

실행결과

728x90
728x90

출처 : RTMPDump
Compiling RTMPdump on Max OS X
Compiling FFmpeg 0.9 with libRTMP and libmp3lame for Intel and ARM CPUs
Compiling FFMPEG 0.6 with RTMP Support for OSX
ffmpeg ndk 빌드 #2 ffmpeg 옵션별 빌드
best-video-player
Fix rtmp double cflags in pkgconfig module

다운로드

RTMPDump 에서 rtmpdump-2.3.tgz 파일 다운로드

압축풀기

$ tar xvfz rtmpdump-2.3.gz

ffmpeg 폴더로 이동 시키기

mv rtmpdump-2.3/librtmp ffmpeg-0.10.3

rtmp 라이브러리 컴파일, 설치

$ cd ffmpeg-0.10.3/librtmp
$ make SYS=linux install
$ echo 'export PKG_CONFIG_PATH=/lib/pkgconfig:/usr/local/lib/pkgconfig' | tee -a ~/.bashrc

configure

config.sh 파일

export TMPDIR=c:/ffmpegtmp

./configure --disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-devices \
--disable-filters \
--disable-yasm \
--enable-network \
--enable-protocol=tcp \
--enable-demuxer=rtsp \
--enable-decoder=h264 \
--enable-librtmp

$ ./config.sh

$ make

testmain.c

#include <stdio.h> 
#include <stdlib.h> 
#include <libavcodec/avcodec.h> 
#include <libavformat/avformat.h> 
#include <libavformat/avio.h> 
 
 
int main(int argc, char** argv) { 
 
    AVFormatContext* context = avformat_alloc_context(); 
    int video_stream_index; 
 
    av_register_all(); 
    avcodec_register_all(); 
    avformat_network_init(); 

    //if(avformat_open_input(&context, "rtsp://192.168.0.40/vod/mp4:sample.mp4",NULL,NULL) != 0){ 
  	//if(avformat_open_input(&context, "rtmp://192.168.0.40/vod/sample.mp4",NULL,NULL) != 0){     	
    //if(avformat_open_input(&context, "d:\\windows\\b.mp4",NULL,NULL) != 0){ 
 
    //open rtsp 
    if(avformat_open_input(&context, "rtmp://192.168.0.40/vod/sample.mp4",NULL,NULL) != 0){     	
        return EXIT_FAILURE; 
    } 
 
    if(avformat_find_stream_info(context,NULL) < 0){ 
        return EXIT_FAILURE; 
    } 
 
    //search video stream 
    int i;
    for(i =0;i<context->nb_streams;i++){ 
        if(context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) 
            video_stream_index = i; 
    } 
 
    AVPacket packet; 
    av_init_packet(&packet); 
 
    //open output file 
    AVOutputFormat* fmt = av_guess_format(NULL,"test2.avi",NULL); 
    AVFormatContext* oc = avformat_alloc_context(); 
    oc->oformat = fmt; 
    avio_open2(&oc->pb, "test.avi", AVIO_FLAG_WRITE,NULL,NULL); 
 
    AVStream* stream=NULL; 
    int cnt = 0; 
    //start reading packets from stream and write them to file 
 
    av_read_play(context);//play RTSP 
    while(av_read_frame(context,&packet)>=0 && cnt <100){//read 100 frames 
        if(packet.stream_index == video_stream_index){//packet is video                
            if(stream == NULL){//create stream in file 
                stream = avformat_new_stream(oc,context->streams[video_stream_index]->codec->codec); 
                avcodec_copy_context(stream->codec,context->streams[video_stream_index]->codec); 
                stream->sample_aspect_ratio = context->streams[video_stream_index]->codec->sample_aspect_ratio; 
                avformat_write_header(oc,NULL); 
            } 
            packet.stream_index = stream->id; 
 
            av_write_frame(oc,&packet); 
            cnt++; 
        } 
        av_free_packet(&packet); 
        av_init_packet(&packet); 
    } 
    av_read_pause(context); 
    av_write_trailer(oc); 
    avio_close(oc->pb); 
    avformat_free_context(oc); 
 
    return (EXIT_SUCCESS); 
} 

Makefile

TARGET = hello3

FFMPEGDIR = /home/bluesanta/ffmpeg-0.10.3

LIBDIR = /lib

CC 	= gcc
AR 	= ar
LD 	= ld
NM 	= nm
RANLIB 	= ranlib
STRIP = strip

INCLUDE = -I.. -I.

CFLAGS = -Wall
LDFFMPEG = -L$(FFMPEGDIR)/libavformat -L$(FFMPEGDIR)/libavcodec -L$(FFMPEGDIR)/libavutil -L$(FFMPEGDIR)/librtmp
LDFLAGS = -L$(LIBDIR) $(LDFFMPEG) -lavformat -lavcodec -lavutil -lrtmp -lkernel32 -lcygwin -lm -lgcc -lc -lssl -lz -lcrypto

# application file
APPSOURCES = testmain.c
APPOBJS = $(APPSOURCES:.c=.o)

# define the rule
.SUFFIXES:.c .o 

.c.o:
	@echo Compiling: $< 
	$(CC) -c $(CFLAGS)  $(INCLUDE) -o $@ $<

all: app

app: $(APPOBJS)
	@echo Linking: $(TARGET) 
	$(CC) -o $(TARGET) $(APPOBJS) $(LDFLAGS)
	$(STRIP) -s $(TARGET)

clean:
	@rm -vf $(APPOBJS) $(TARGET) 

컴파일, 실행

 

728x90
728x90

출처 : Record RTSP stream with FFmpeg libavformat
Android NDK FFmpeg 컴파일 강좌 (1/4)

환경

wowza 2.2.4, ffmpeg-0.10.3, cygwin, windows 7

압축풀기

$ tar xvfz ffmpeg-0.10.3.tar.gz

configure

config.sh 파일

export TMPDIR=c:/ffmpegtmp

./configure --disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-devices \
--disable-filters \
--disable-yasm \
--enable-network \
--enable-protocol=tcp \
--enable-demuxer=rtsp \
--enable-decoder=h264 

$ ./config.sh

$ make

testmain.c

#include <stdio.h> 
#include <stdlib.h> 
#include <libavcodec/avcodec.h> 
#include <libavformat/avformat.h> 
#include <libavformat/avio.h> 
 
 
int main(int argc, char** argv) { 
 
    AVFormatContext* context = avformat_alloc_context(); 
    int video_stream_index; 
 
    av_register_all(); 
    avcodec_register_all(); 
    avformat_network_init(); 

  	//if(avformat_open_input(&context, "rtmp://192.168.0.40/vod/sample.mp4",NULL,NULL) != 0){     	
    //if(avformat_open_input(&context, "d:\\windows\\b.mp4",NULL,NULL) != 0){ 
 
    //open rtsp 
    if(avformat_open_input(&context, "rtsp://192.168.0.40/vod/mp4:sample.mp4",NULL,NULL) != 0){ 
        return EXIT_FAILURE; 
    } 
 
    if(avformat_find_stream_info(context,NULL) < 0){ 
        return EXIT_FAILURE; 
    } 
 
    //search video stream 
    int i;
    for(i =0;i<context->nb_streams;i++){ 
        if(context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) 
            video_stream_index = i; 
    } 
 
    AVPacket packet; 
    av_init_packet(&packet); 
 
    //open output file 
    AVOutputFormat* fmt = av_guess_format(NULL,"test2.avi",NULL); 
    AVFormatContext* oc = avformat_alloc_context(); 
    oc->oformat = fmt; 
    avio_open2(&oc->pb, "test.avi", AVIO_FLAG_WRITE,NULL,NULL); 
 
    AVStream* stream=NULL; 
    int cnt = 0; 
    //start reading packets from stream and write them to file 
 
    av_read_play(context);//play RTSP 
    while(av_read_frame(context,&packet)>=0 && cnt <100){//read 100 frames 
        if(packet.stream_index == video_stream_index){//packet is video                
            if(stream == NULL){//create stream in file 
                stream = avformat_new_stream(oc,context->streams[video_stream_index]->codec->codec); 
                avcodec_copy_context(stream->codec,context->streams[video_stream_index]->codec); 
                stream->sample_aspect_ratio = context->streams[video_stream_index]->codec->sample_aspect_ratio; 
                avformat_write_header(oc,NULL); 
            } 
            packet.stream_index = stream->id; 
 
            av_write_frame(oc,&packet); 
            cnt++; 
        } 
        av_free_packet(&packet); 
        av_init_packet(&packet); 
    } 
    av_read_pause(context); 
    av_write_trailer(oc); 
    avio_close(oc->pb); 
    avformat_free_context(oc); 
 
    return (EXIT_SUCCESS); 
} 

Makefile

TARGET = hello2

FFMPEGDIR = /home/bluesanta/ffmpeg-0.10.3

LIBDIR = /lib

CC 	= gcc
AR 	= ar
LD 	= ld
NM 	= nm
RANLIB 	= ranlib
STRIP = strip

INCLUDE = -I$(FFMPEGDIR)

CFLAGS = -Wall
LDFFMPEG = -L$(FFMPEGDIR)/libavformat -L$(FFMPEGDIR)/libavcodec -L$(FFMPEGDIR)/libavutil 
LDFLAGS = -L$(LIBDIR) $(LDFFMPEG) -lavformat -lavcodec -lavutil -lkernel32 -lcygwin -lm -lgcc -lc

# application file
APPSOURCES = testmain.c
APPOBJS = $(APPSOURCES:.c=.o)

# define the rule
.SUFFIXES:.c .o 

.c.o:
	@echo Compiling: $< 
	$(CC) -c $(CFLAGS)  $(INCLUDE) -o $@ $<

all: app

app: $(APPOBJS)
	@echo Linking: $(TARGET) 
	$(CC) -o $(TARGET) $(APPOBJS) $(LDFLAGS)
	$(STRIP) -s $(TARGET)

clean:
	@rm -vf $(APPOBJS) $(TARGET) 

컴파일, 실행

728x90
728x90

 FILETIME ft;
 GetSystemTimeAsFileTime(&ft);
 static DWORD dwVal = 0x21;
 DWORD dwSeed = (dwVal++ << 0x18) | (ft.dwLowDateTime & 0x00ffff00) | dwVal++ & 0x000000ff;
 srand(dwSeed);

 int iRandom = rand()%10+1;

728x90
728x90

BSTR -> char 배열

char szData[200];
BSTR decodeData;

USES_CONVERSION;
strcpy(szData,OLE2A(decodeData));

char 배열 -> BSTR

USES_CONVERSION;
char* szData = "char array";
BSTR sbstr;

sbstr = SysAllocString(A2W(szData)); 

728x90

+ Recent posts