일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- BAM
- 패턴인식
- Friendship
- Neural Network
- 하이퍼바이저
- 구글 앱 엔진
- 인공지능
- 갤럭시탭S8울트라
- SSM
- 빅데이터
- 패턴 인식
- 고려대학교
- NarwalFreo
- 파이썬
- Bidirectional Associative Memory
- 신경망
- 나르왈프레오
- 가상화
- 신경회로망
- hopfield network
- 삼성소프트웨어멤버십
- Python
- Google App Engine
- 동아리
- 삼성전자 소프트웨어멤버십 SSM
- 삼성
- 물걸레로봇청소기추천
- 물걸레자동세척로봇청소기
- 증강현실
- 멤버십
- Today
- Total
정보공간_1
[6기 부산 박천경]SDL (Simple DirectMedia layer) #3 본문
안녕하세요 부산 멤버십 박천경 입니다.
SDL (Simple DirectMedia layer) #1 과 #2 에서는 SDL의 설치법 과, window에 이미지 생성
그리고 사운드 카드 지정 후 소리 재생에 관해서 알아 보았습니다.
이번 시간은 SDL 의 마지막 시간 입니다. 지금까지 SDL(Simple DirectMedia layer)의
소스들을 토대로 ffmpeg 라이브러리의 사용법을 간단히 익힌 후 ffmpeg을
SDL2.0버전에서 동영상 재생하는 작업을 연재 하겠습니다.
참고로 필자는 window 환경에서 개발을 진행 하였습니다.
FFmpeg은 크로스 플랫폼을 지원하는 오픈소스 멀티미디어 프레임워크입니다.
FFmpeg을 이용해 인코딩/디코딩, 트랜스코딩(transcode), 먹싱/디먹싱, 스트림(stream)은
물론 '재생'까지 멀티미디어와 관련한 거의 모든 기능을 다 갖추고 있습니다.
FFmpeg의 라이센스는 GPL과 LGPL입니다.
FFmpeg에는 다음과 같은 여러 세부 라이브러리가 있습니다.
libavcodec: 오디오/비디오의 인코더/디코더
libavformat: 오디오/비디어 컨테이너 포맷의 muxer/demuxer
libavutil: FFmpeg 개발 시 필요한 다양한 유틸리티
libpostproc: video post-processing
libswscale: 비디오의 image scaling, color-space, pixel-format 변환
libavfilter: 인코더와 디코더 사이에서 오디오/비디오를 변경하고 검사
libswresample: 오디오 리샘플링(audio resampling)
FFmpeg을 이용하여 동영상 파일을 읽어 원본 데이터를 추출하는 과정은 다음과 같습니다.
2. ffmpeg 개발 환경 구축
3. ffmpeg 과 SDL 2.0 을 이용한 간단한 플레이어 만들기
자, 이제 ffmpeg에 대한 정의도 익혔고, ffmpeg의 환경구축도 완료되었기때문에
ffmpeg 과 SDL을 잘 mixing 하여서 avi 동영상을 SDL window 창을 이용하여 재생시키겠습니다.
extern "C"
{
#include <libavcodec\avcodec.h>
#include <libavformat\avformat.h>
#include <libswscale\swscale.h>
#include <SDL.h>
#include <SDL_thread.h>
}
#pragma comment( lib, "avcodec.lib" )
#pragma comment( lib, "avformat.lib" )
#pragma comment( lib, "swscale.lib" )
#pragma comment( lib , "avutil.lib" )
#pragma comment( lib , "SDL2.lib" )
#pragma comment( lib , "SDL2main.lib" )
AVFormatContext *pFormatCtx = NULL ;
int i , videoStream ; brief
AVCodecContext *pCodecCtx = NULL ;
AVCodec *pCodec = NULL ;
AVFrame *pFrame = NULL ;
AVPacket packet ;
int frameFinished ;
AVDictionary *optionDict = NULL ;
struct SwsContext *sws_ctx = NULL ;
SDL_Texture *bmp = NULL ;
SDL_Window *window = NULL ;
SDL_Rect rect ;
SDL_Event even ;
const char *FilePath = "test.avi" ;
av_register_all() ;
SDL_Init(SDL_INIT_VIDEO);
avformat_open_input(&pFormatCtx , FilePath , NULL , NULL) ;
avformat_find_stream_info(pFormatCtx , NULL);
av_dump_format(pFormatCtx , 0 , FilePath , 0) ;
sws_ctx = sws_getContext(pCodecCtx->width ,pCodecCtx->height , pCodecCtx->pix_fmt ,
pCodecCtx->width ,pCodecCtx->height ,PIX_FMT_YUV420P ,
SWS_BILINEAR , NULL , NULL , NULL) ;
int numBytes = avpicture_get_size(PIX_FMT_YUV420P , pCodecCtx->width , pCodecCtx->height) ;
uint8_t *buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t)) ;
avpicture_fill((AVPicture *)pFrameYUV , buffer , PIX_FMT_YUV420P ,
pCodecCtx->width , pCodecCtx->height) ;
rect.x = 0 ; rect.y = 0 ; rect.w = pCodecCtx->width ;rect.h = pCodecCtx->height ;
'IT 놀이터' 카테고리의 다른 글
[6기 수원 김병연] Node.js Server Testing (0) | 2014.12.13 |
---|---|
[6기 부산 박천경] mixare(증강현실) opensource 분석 #1 (0) | 2014.10.26 |
[6기 수원 김병연] Node.js 디버깅 및 실제 함수의 동작 이해 (0) | 2014.09.05 |
[UX research] 사용자 리서치를 간략하게 설명해봅시다. (0) | 2011.07.02 |