메뉴 닫기

nginx RTMP 모듈을 이용한 스트리밍

nginx 웹서버에도 스트리밍을 할수 있는 rtmp 외부 모듈이 존재 합니다

apache mod_h264모듈과 비슷하지만 apache 웹서버는 프로토콜을 HTTP (80)을 사용하고 nginx rtmp 모듈은

RTMP(1935)포트를 이용한다. 물론 nginx에도 h264 모델도 설치가 가능하다. 간혹 꼭 rtmp 프로토콜을 사용해야 될 경우가 있다

이럴경우 nginx 를 웹서버로 이용하고 있다면 외부 모듈 추가로 간단하게 RTMP 프로토콜을 사용할 수가 있다

테스트 환경 

하드웨어 : Cloudv 가상서버  (자세한 사양은 URL 참조)

                 http://www.cloudv.kr/rew1/cloud/cloud_v_linux-2.1.html

OS : Ubuntu 14.04 x64

 

1. RTMP 모듈 설치 방법

1) 필요한 모듈 설치
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev

2) nginx 소스와 rtmp 모듈 소스 다운로드
wget http://nginx.org/download/nginx-1.7.5.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

3) 파일 압축 해제
tar -zxvf nginx-1.7.5.tar.gz
unzip master.zip
(unzip 명령어가 없을경우 apt-get install unzip 으로 설치)

4) nginx 컴파일
./configure –with-http_ssl_module –add-module=/usr/local/src/nginx-rtmp-module-master
make
make install

5) nginx 데몬 스크립트
wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d nginx defaults

6) FFmpeg 설치
ffmpeg를 통해서 Transcoding이 가능하기 때문에 설치

– apt-add-repository ppa:jon-severinsson/ffmpeg
– apt-get update
– apt-get install ffmpeg

 

 

2. nginx.conf 파일 설정

conf파일에 포함되는 옵션이 너무 많기 때문에 간단하게 VOD 만 테스트를 진행
자세한 설정파일은 URL 참조
https://github.com/arut/nginx-rtmp-module/blob/master/README.md

1) nginx.conf 추가
마지락 라인에 아래 내용을 추가

nginx

rtmp {

server {

listen 1935;

chunk_size 4000;

# video on demand
application vod {
play /usr/local/nginx/html; ## VOD파일 경로
}

}
}

 

3. VOD 영상 테스트

– html을 생성한후 아래 소스 추가
“<HTML>
<HEAD>
<TITLE>JW Player 6</TITLE>

<script type=’text/javascript’ src=’jwplayer/jwplayer.js’></script>

</HEAD>

<BODY>

<div id=’mediaplayer’></div>
<script type=”text/javascript”>
jwplayer(‘mediaplayer’).setup({
file: “rtmp://스트리밍서버주소/vod/mp4:test.mp4”,
width: “720”,
height: “480”
});
</script>

</BODY>
</HTML>”

 

[polldaddy rating=”7739789″]

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] RTMP 모듈을 이용한 스트리밍 http://idchowto.com/?p=13416 […]

김동규
김동규
6 years ago

음.. 저렇게 그대로 파일만 넣으면 스트리밍이 되긴 하는데

스트리밍을 했더니 seek 가 잘 작동이 안되는것 같네요.. 이럴땐 파일에 인코딩을 해주는게 맞을까요?

2
0
Would love your thoughts, please comment.x
()
x