내 연락처 정보
우편메소피아@프로톤메일.com
2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
1. 펄 설치
설치 주소: https://strawberryperl.com, msi 설치 프로그램을 선택하세요.
2. Windows용 sed 설치
다운로드 주소: https://sourceforge.net/projects/gnuwin32/files/sed/ 설치 프로그램 실행 후 설치 패키지의 bin 디렉터리를 환경변수로 설정합니다.
3. Visual Studio 2022 커뮤니티 버전 설치
4. 에서한국어: 한국어: https://github.com/nginx/nginx버전 1.26.1의 소스 코드를 다운로드하고 소스 코드에 새 디렉터리 objslib를 만듭니다.
nginx-http-flv-모듈 다운로드:https://github.com/winshining/nginx-http-flv-모듈(버전 1.2.10)
pcre 다운로드:https://github.com/PCRE2Project/pcre2/태그(버전 10.2.39)
zlib 다운로드:https://github.com/madler/zlib(버전 1.3.1)
openssl 다운로드:한국어: 한국어: https://www.openssl.org/source/index.html(버전 3.0.13)
nginx-http-flv-module, openssl, pcre 및 zlib를 이 디렉터리에 복사하고 압축을 풉니다.
5. nginx 컴파일 매개변수 보기
nginx-1.26.1의 컴파일된 버전을 다운로드하고 nginx.exe -V를 실행하면 다음 결과를 얻을 수 있습니다.
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre2-10.39 --with-zlib=objs.msvc8/lib/zlib-1.3.1 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-stream_realip_module --with-stream_ssl_preread_module --with-openssl=objs.msvc8/lib/openssl-3.0.13 --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module
일부 매개변수를 수정합니다.
--with-pcre=objs/lib/pcre2-10.39 --with-zlib=objs/lib/zlib-1.3.1 --with-openssl=objs/lib/openssl-3.0.13 --add-module=objs/lib/nginx-http-flv-module-1.2.10
7、구성
MSYS2 또는 MINGW64를 실행하고 nginx 소스 코드 nginx-release-1.26.1을 입력한 후 다음 명령을 실행합니다.
auto/configure --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-stream_realip_module --with-stream_ssl_preread_module --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-pcre=objs/lib/pcre2-10.39 --with-zlib=objs/lib/zlib-1.3.1 --with-openssl=objs/lib/openssl-3.0.13 --add-module=objs/lib/nginx-http-flv-module-1.2.10
objs.msvc8/Makefile을 수정하고 세 번째 줄을 수정합니다.
CFLAGS = -O2 -W4 -WX -nologo -MT -Zi -Fdobjs.msvc8/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H
-WX 제거, -MP 추가
CFLAGS = -O2 -W4 -MP -nologo -MT -Zi -Fdobjs.msvc8/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H
8. 컴파일
VS 2022용 개발자 명령 프롬프트를 열고 nginx 소스 디렉터리를 입력한 후 nmake 명령을 입력하고 Enter 키를 누릅니다.
컴파일 시간은 10~30분 정도 소요됩니다. 완료 후 objs.msvc8 아래의 nginx.exe를 nginx 소스 코드 디렉터리에 복사합니다.
새 디렉터리 로그, 임시 및 html을 만듭니다.
9. ffmpeg 설치
ffmpeg bin 디렉터리를 다운로드하여 설치하고 환경 변수로 설정합니다.
conf/nginx.conf 수정
- worker_processes 1;
-
- events {
- worker_connections 1024;
- }
-
- http {
- include mime.types;
- default_type application/octet-stream;
-
- sendfile on;
- keepalive_timeout 65;
-
- server {
- listen 8553;
- server_name localhost;
-
- location / {
- root html;
- index index.html index.htm;
- }
-
- location /live {
- flv_live on;
- chunked_transfer_encoding on;
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Allow-Methods' '*';
- }
-
- location /hls {
- add_header 'Access-Control-Allow-Origin' '*';
- types {
- application/vnd.apple.mpegurl m3u8;
- video/mp2t ts;
- }
- alias /test;
- expires -1;
- }
-
- location /stat {
- rtmp_stat all;
- rtmp_stat_stylesheet stat.xsl;
- }
-
- location /stat.xsl {
- root /usr/local/nginx/nginx-http-flv-module;
- }
- }
- }
-
- rtmp {
- server {
- listen 1938; #nginx监听的rtmp推流/拉流端口
- application myapp {
- live on; #当推流时,rtmp路径中的app(rtmp中的一个概念)匹配myapp时,开始直播
- meta off;
- gop_cache on;
- allow play all;
- record off;
- hls on;
- hls_path /test;
- hls_fragment 1s;
- }
- }
- }
ffmpeg 푸시 스트림(Haikang 카메라)
- ffmpeg -i rtsp://用户名:密码@ip:554/H.264/ch1/main/av_stream -c:v libx264 -an -f
- flv rtmp://127.0.0.1:1938/myapp/main
flv.html
- <html>
- <head>
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
- <title>flv.js demo</title>
- <style>
- .mainContainer {
- display: block;
- width: 1024px;
- margin-left: auto;
- margin-right: auto;
- }
-
- .urlInput {
- display: block;
- width: 100%;
- margin-left: auto;
- margin-right: auto;
- margin-top: 8px;
- margin-bottom: 8px;
- }
-
- .centeredVideo {
- display: block;
- width: 100%;
- height: 576px;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: auto;
- }
-
- .controls {
- display: block;
- width: 100%;
- text-align: center;
- margin-left: auto;
- margin-right: auto;
- }
- </style>
- </head>
-
- <body>
-
- <p class="mainContainer">
- <video name="videoElement" id="videoElement" class="centeredVideo" controls muted autoplay width="1024"
- height="576">
- Your browser is too old which doesn't support HTML5 video.
- </video>
- </p>
-
- <script src="flv.min.js"></script>
-
- <script>
-
- function start() {
- if (flvjs.isSupported()) {
- var videoElement = document.getElementById('videoElement');
- var flvPlayer = flvjs.createPlayer({
- type: 'flv',
- url: 'http://ip:8553/live?port=1938&app=myapp&stream=main'
- });
- flvPlayer.attachMediaElement(videoElement);
- flvPlayer.load();
- flvPlayer.play();
- }
- }
-
- document.addEventListener('DOMContentLoaded', function () {
- start();
- });
- </script>
- </body>
-
- </html>
flv.min.js 다운로드 주소:http://flv.jnyzh.cn/flv.min.js
효과는 다음과 같습니다.