動画配信サーバ

(16)

https://ticktakclock.hatenablog.com/entry/2018/09/12/203900


-- 1. nginxのコンパイル

apt update
apt upgrade
apt install wget gcc openssl libssl-dev git
apt install build-essential libpcre3 libpcre3-dev unzip zlib1g-dev

mkdir /storeaming
cd /storeaming

git clone https://github.com/arut/nginx-rtmp-module.git

wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxf nginx-1.12.2.tar.gz
rm -rf nginx-1.12.2.tar.gz

cd /storeaming/nginx-1.12.2
./configure --add-module=/storeaming/nginx-rtmp-module
make
make install


-- 2. nginxの設定、起動

mkdir /usr/local/nginx/html/movie
mkdir /usr/local/nginx/html/hls
chown nobody /usr/local/nginx/html/movie
vim /usr/local/nginx/conf/nginx.conf
追記
rtmp {
server {
listen 1935;
access_log logs/rtmp_access.log;
application live {
live on;
wait_video on;
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 5s;
}
application vod {
play /usr/local/nginx/html/movie;
}
}
}


vim /etc/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

systemctl enable nginx
systemctl restart nginx
systemctl status nginx

 

-- 3. htmlファイル作成

rm -rf /usr/local/nginx/html/index.html
vim /usr/local/nginx/html/index.html

<DOCTYPE html>
<html lang="en" class="">
<body>
<p>This Is Web Storeaming StartPage!!</p>
<hr>
<a href="live.html">Live</a><br/>
<a href="vod.html">Video On Demand</a>
</body>


vim /usr/local/nginx/html/vod.html

<DOCTYPE html>
<html lang="en" class="">
<head>
<title>ONDEMAND</title>
<link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<p> Video On Demand </p>
<video id="video" class="video-js vjs-default-skin" width="640" height="480" controls>
<script type="text/javascript">
var source = '/movie/test.m3u8';
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
// iOS
document.write('<source src=' + source + ' type="application/x-mpegURL">');
document.write('</video>');
}else{
// OTHER
document.write('</video>');
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource(source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.pause();
});
}
}
</script>
</body>
</html>


-- 4. 動画ファイルをHLS形式に変換

apt install ffmpeg
ffmpeg -version

cd /usr/local/nginx/html/movie

ffmpeg -re -i test.mp4 -vcodec libx264 -vprofile baseline -codec:a libmp3lame -ar 44100 -ac 1 \
-top -1 -deinterlace \
-f segment -segment_format mpegts -segment_time 10 -segment_list test.m3u8 test-%04d.ts

 

 

(9)


-- 1. nginxのコンパイル

apt update
apt upgrade
apt install wget gcc openssl libssl-dev git
apt install build-essential libpcre3 libpcre3-dev unzip zlib1g-dev

mkdir /storeaming
cd /storeaming

git clone https://github.com/arut/nginx-rtmp-module.git

wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxf nginx-1.12.2.tar.gz
rm -rf nginx-1.12.2.tar.gz

cd /storeaming/nginx-1.12.2
./configure --add-module=/storeaming/nginx-rtmp-module
make
make install


-- 2. nginxの設定、起動

mkdir /usr/local/nginx/html/movie
mkdir /usr/local/nginx/html/hls
chown nobody /usr/local/nginx/html/movie
vim /usr/local/nginx/conf/nginx.conf
追記
rtmp {
server {
listen 1935;
access_log logs/rtmp_access.log;
application live {
live on;
wait_video on;
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 5s;
}
application vod {
play /usr/local/nginx/html/movie;
}
}
}


vim /etc/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

systemctl enable nginx
systemctl restart nginx
systemctl status nginx

 

-- 3. htmlファイル作成

rm -rf /usr/local/nginx/html/index.html
vim /usr/local/nginx/html/index.html

<DOCTYPE html>
<html lang="en" class="">
<body>
<p>This Is Web Storeaming StartPage!!</p>
<hr>
<a href="live.html">Live</a><br/>
<a href="vod.html">Video On Demand</a>
</body>


vim /usr/local/nginx/html/vod.html

<DOCTYPE html>
<html lang="en" class="">
<head>
<title>ONDEMAND</title>
<link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<p> Video On Demand </p>
<video id="video" class="video-js vjs-default-skin" width="640" height="480" controls>
<script type="text/javascript">
var source = '/movie/test.m3u8';
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
// iOS
document.write('<source src=' + source + ' type="application/x-mpegURL">');
document.write('</video>');
}else{
// OTHER
document.write('</video>');
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource(source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.pause();
});
}
}
</script>
</body>
</html>


-- 4. 動画ファイルをHLS形式に変換

apt install ffmpeg
ffmpeg -version

cd /usr/local/nginx/html/movie

ffmpeg -re -i test.mp4 -vcodec libx264 -vprofile baseline -codec:a libmp3lame -ar 44100 -ac 1 \
-top -1 -deinterlace \
-f segment -segment_format mpegts -segment_time 10 -segment_list test.m3u8 test-%04d.ts

 

 

(7)

https://qiita.com/yo_dazy/items/e14464367ec8d4a26b6a


-- 1. nginxのコンパイル

yum update -y
yum install -y wget gcc pcre-devel openssl openssl-devel git

mkdir /storeaming
cd /storeaming

git clone https://github.com/arut/nginx-rtmp-module.git

wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxf nginx-1.12.2.tar.gz
rm -rf nginx-1.12.2.tar.gz

cd /storeaming/nginx-1.12.2
./configure --add-module=/storeaming/nginx-rtmp-module
make
make install


-- 2. nginxの設定、起動

mkdir /usr/local/nginx/html/movie
mkdir /usr/local/nginx/html/hls
chown nobody /usr/local/nginx/html/movie
vim /usr/local/nginx/conf/nginx.conf
追記
rtmp {
server {
listen 1935;
access_log logs/rtmp_access.log;
application live {
live on;
wait_video on;
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 5s;
}
application vod {
play /usr/local/nginx/html/movie;
}
}
}


vim /etc/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

systemctl enable nginx
systemctl restart nginx
systemctl status nginx

 

-- 3. htmlファイル作成

rm -rf /usr/local/nginx/html/index.html
vim /usr/local/nginx/html/index.html

<DOCTYPE html>
<html lang="en" class="">
<body>
<p>This Is Web Storeaming StartPage!!</p>
<hr>
<a href="live.html">Live</a><br/>
<a href="vod.html">Video On Demand</a>
</body>


vim /usr/local/nginx/html/vod.html

<DOCTYPE html>
<html lang="en" class="">
<head>
<title>ONDEMAND</title>
<link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<p> Video On Demand </p>
<video id="video" class="video-js vjs-default-skin" width="640" height="480" controls>
<script type="text/javascript">
var source = '/movie/test.m3u8';
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
// iOS
document.write('<source src=' + source + ' type="application/x-mpegURL">');
document.write('</video>');
}else{
// OTHER
document.write('</video>');
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource(source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.pause();
});
}
}
</script>
</body>
</html>


-- 4. 動画ファイルをHLS形式に変換

yum install -y epel-release
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
yum install ffmpeg ffmpeg-devel
ffmpeg -version

cd /usr/local/nginx/html/movie

ffmpeg -re -i test.mp4 -vcodec libx264 -vprofile baseline -codec:a libmp3lame -ar 44100 -ac 1 \
-top -1 -deinterlace \
-f segment -segment_format mpegts -segment_time 10 -segment_list test.m3u8 test-%04d.ts

(2019)

https://bizvalley.co.jp/blog/1471.html

-- 1. 役割と機能の追加からIISインストール

-- 2. IISマネージャでMIMEの種類追加
ファイルの拡張子: .m3u8
MIMEの種類: application/x-mpegURL

-- 3. htmlファイル作成

cd C:\inetpub\wwwroot
notepad index.html

<DOCTYPE html>
<html lang="en" class="">
<body>
<p>This Is Web Storeaming StartPage!!</p>
<hr>
<a href="live.html">Live</a><br/>
<a href="vod.html">Video On Demand</a>
</body>


notepad vod.html

<DOCTYPE html>
<html lang="en" class="">
<head>
<title>ONDEMAND</title>
<link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<p> Video On Demand </p>
<video id="video" class="video-js vjs-default-skin" width="640" height="480" controls>
<script type="text/javascript">
var source = '/movie/test.m3u8';
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
// iOS
document.write('<source src=' + source + ' type="application/x-mpegURL">');
document.write('</video>');
}else{
// OTHER
document.write('</video>');
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource(source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.pause();
});
}
}
</script>
</body>
</html>

-- 4. 動画ファイルをHLS形式に変換
ffmpeg -re -i test.mp4 -vcodec libx264 -vprofile baseline -codec:a libmp3lame -ar 44100 -ac 1 ^
-f segment -segment_format mpegts -segment_time 10 -segment_list test.m3u8 test-%04d.ts

"C:\inetpub\wwwroot\movie"にm3u8ファイル,tsファイルを配置