Express์ HLS๋ก ๋์์์ ์คํธ๋ฆฌ๋ฐํ๋ ์์ ์ ๋๋ค.
This is an example that stream video using HLS and Node.js
์์ ์ ๋ํด ์ค๋ช ํ ๋ธ๋ก๊ทธ ๊ธ ์ ๋๋ค. ํ๊ตญ์ด์ ์์ด ์ค ํ๋๋ก ๋ณด์ค ์ ์์ต๋๋ค.
The links below are my blog posts that explain about this example. You can choose between Korean and English.
Node.js, Express, HLS๋ก ๋์์ ์คํธ๋ฆฌ๋ฐํ๊ธฐ (ํ๊ตญ์ด)
Video Streaming with Node.js / HLS (English)
์ ์ฅ์๋ฅผ ํด๋ก ํด์ฃผ์ธ์.
Clone this repository.
git clone https://github.com/HoseungJang/express-hls-example.git
์์กด์ฑ์ ์ค์นํด์ฃผ์ธ์.
Install dependencies.
cd express-hls-example
npm install
src ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํด์ฃผ์ธ์.
Go to 'src' directory.
cd src
videos ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ ํ mp4 ํ์์ ๋์์์ ๋ฃ์ด์ฃผ์ธ์.
๋์์ ํ์ผ์ ์ด๋ฆ์ video๋ก ํด์ฃผ์ธ์.
์ฌ๊ธฐ๊น์ง ์ค์ จ๋ค๋ฉด src ๋๋ ํ ๋ฆฌ ๋ด๋ถ๊ฐ ์๋์ ๊ฐ์ ๊ฒ์ ๋๋ค.
After making 'videos' directory, Put 'video.mp4' file into there.
If you complete this step, 'videos' directory is composed of:
/src
/videos
video.mp4
app.js
client.html
ffmpeg.js
ffmpeg.js๋ฅผ ์คํํด์ฃผ์ธ์.
Run ffmpeg.js.
node ffmpeg.js
end๊ฐ ์ถ๋ ฅ๋๋ฉด ffmpeg.js๋ฅผ ์ข ๋ฃํ๊ณ app.js๋ฅผ ์คํํด์ฃผ์ธ์.
Terminate ffmpeg.js and Run app.js when 'end' is logged.
node app.js
localhost:3000์ผ๋ก ์ ์ํ๊ณ , ๋์์์ ์ฌ์ํด๋ณด์ธ์.
F12๋ฅผ ๋๋ฅด๊ณ Network ํญ๋ ํ์ธํด๋ณด์ธ์.
Now go to localhost:3000 and play your video.
Press F12 key and check the Network tab.