[Mediaserver]miniMediaserver-(1)

πŸ‘‰πŸ»μ•„λž˜λŠ” miniMediaserver μ„œλ²„μ— λŒ€ν•œ μ„€λͺ…μž…λ‹ˆλ‹€.
Below is a description of the miniMediaserver server.

πŸ‘‰πŸ» λ‘œμ»¬μ—μ„œ ν…ŒμŠ€νŠΈ κ°€λŠ₯ν•œ λ―Έλ””μ–΄μ„œλ²„μ˜ κ°€μž₯ κΈ°λ³Έν˜•μž…λ‹ˆλ‹€.
This is the most basic type of media server that can be tested locally.

πŸ‘‰πŸ» 디렉토리 ꡬ쑰 /
directory structure

βœ”οΈ CMakeLists.txt : λΉŒλ“œλ„κ΅¬ / Build Tools

βœ”οΈ main.cpp : μ•± μ§„μž…μ  cpp파일 / App entry point cpp file

βœ”οΈ src : cpp및 h파일 디렉토리 / cpp and h file directories

mini_mediaserver_1/
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ main.cpp
└── src/
β”œβ”€β”€ rtmp_server.h
β”œβ”€β”€ rtmp_server.cpp
β”œβ”€β”€ rtmp_session.h
β”œβ”€β”€ rtmp_session.cpp
β”œβ”€β”€ amf0.h
β”œβ”€β”€ amf0.cpp
β”œβ”€β”€ flv_writer.h
└── flv_writer.cpp

πŸ‘‰πŸ» μ—¬κΈ°μ„œλŠ” obsμ—μ„œ rtmpν”„λ‘œν† μ½œλ‘œ μ„œλ²„μ— μ ‘μ†ν•˜κ³  flv파일둜 μ €μž₯ν•˜κ³  VLC Player둜 μž¬μƒκΉŒμ§€ ν™•μΈν•΄λ΄…λ‹ˆλ‹€.
Here, we connect to the server using the RTMP protocol in OBS, save it as an FLV file, and verify playback using VLC Player.

πŸ‘‰πŸ» rtmp(Real-Time Messaging Protocol)λŠ” 어도비가 Flash용으둜 λ§Œλ“  μ‹€μ‹œκ°„ 슀트리밍 ν”„λ‘œν† μ½œμž…λ‹ˆλ‹€.
RTMP (Real-Time Messaging Protocol) is a real-time streaming protocol created by Adobe for Flash.

πŸ‘‰πŸ» rtmpν”„λ‘œν† μ½œμ€ OBSμ—μ„œ μ„œλ²„λ‘œ μ˜μƒ μ†‘μΆœν•  λ•Œ μ‚¬μš©λ©λ‹ˆλ‹€.
The RTMP protocol is used to send video from OBS to the server.

πŸ‘‰πŸ» flvνŒŒμΌμ€ ν”Œλž˜μ‹œ λΉ„λ””μ˜€ ν¬λ§·μž…λ‹ˆλ‹€.
FLV files are Flash video formats.

πŸ‘‰πŸ» μ•„λž˜μ˜ 도ꡬ듀을 μ„€μΉ˜ν•©λ‹ˆλ‹€. / Install the tools below.

βœ”οΈopenssl : λ³΄μ•ˆ,μ•”ν˜Έν™” λ‹΄λ‹Ή 도ꡬ / Security and encryption tools

βœ”οΈ FFmpeg(ffmpeg + ffprobe + ffplay)  :
μ˜μƒ, μŒμ„±, 이미지 파일 λ³€ν™˜/νŽΈμ§‘ν•˜λŠ” 도ꡬ / A tool for converting/editing video, audio, and image files

— ffmpeg , ffprobe , ffplay)

ffmpeg  : λ³€ν™˜, 인코딩, 자λ₯΄κΈ°, ν•©μΉ˜κΈ°, μ••μΆ• / Convert, Encode, Crop, Merge, Compress.
ffprobe : 파일 정보 뢄석. 코덱, 해상도, λΉ„νŠΈλ ˆμ΄νŠΈ ν™•μΈμš© /
File information analysis. For checking codec, resolution, and bitrate.
ffplay : κ°„λ‹¨ν•œ μž¬μƒκΈ°, ν…ŒμŠ€νŠΈμš© / Simple player, for testing

βœ”οΈ VLC Player : λŒ€λΆ€λΆ„μ˜ λ―Έλ””μ–΄νŒŒμΌ μž¬μƒ κ°€λŠ₯ν•œ ν”Œλ ˆμ΄μ–΄(flv파일 μž¬μƒκ°€λŠ₯)
Player capable of playing most media files (plays FLV files)

πŸ‘‰πŸ» λΉŒλ“œ / Build

project dir/
cd build
cmake ..
make

πŸ‘‰πŸ» μ‹€ν–‰ / Run

./media_server

βœ”οΈ μ ‘μ†λŒ€κΈ° / Waiting for connection

MacBookAir build % ./media_server
RTMP Server listening on 1935...

βœ”οΈ OBSμ—μ„œμ ‘μ†ν•˜κΈ° / Connecting from OBS

— OBSμ„€μ • / OBS Settings

— OBSμ—μ„œ μ„œλ²„μ— μ ‘μ†ν•˜λ©΄ 터미널에 λ‘œκ·Έκ°€ ν”„λ¦°νŠΈ λ©λ‹ˆλ‹€.
When you connect to the server in OBS, logs are printed in the terminal.

[Server] Ack sent: 16149755 bytes
[Server] Ack sent: 16153851 bytes
[Server] Ack sent: 16157947 bytes
[Server] Ack sent: 16162043 bytes
[Server] Ack sent: 16166139 bytes
[Server] Ack sent: 16170235 bytes
[Server] Ack sent: 16174331 bytes
[Server] Ack sent: 16178427 bytes
[Server] Ack sent: 16182523 bytes
[Server] Ack sent: 16186619 bytes
[Server] Ack sent: 16190715 bytes
[Server] Ack sent: 16194811 bytes

–10~20μ΄ˆμ •λ„ 방솑후에 μ„œλ²„μ™€ obsλ₯Ό μ’…λ£Œν•©λ‹ˆλ‹€.
Close the server and OBS after broadcasting for about 10 to 20 seconds.

— project dir/build디렉토리 내에 test.flv파일이 μƒμ„±λœ 것을 확인 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
You can verify that the test.flv file has been created in the project dir/build directory.

MacBookAir build % ls -hl
total 43112
-rw-r--r--   1 user  staff   2.0K  5μ›” 16 13:43 cmake_install.cmake
-rw-r--r--   1 user  staff    16K  5μ›” 16 13:42 CMakeCache.txt
drwxr-xr-x  13 user  staff   416B  5μ›” 16 13:43 CMakeFiles
-rw-r--r--   1 user  staff   8.8K  5μ›” 16 13:43 Makefile
-rwxr-xr-x   1 user  staff   975K  5μ›” 16 13:43 media_server
-rw-r--r--@  1 user  staff    20M  5μ›” 16 14:34 test.flv

— VLC ν”Œλ ˆμ΄μ–΄μ—μ„œ 이 test.flvνŒŒμΌμ„ μž¬μƒν•΄ λ΄…λ‹ˆλ‹€.
Try playing this test.flv file in VLC Player.

VLC Player

Leave a Reply