ソスソスソスCソスuソスzソスMソス^ソスソス

ソスナ終ソスXソスVソスソスソスF 2019.06.17

ソスソスソスTソスv

ソスソスソスソスzソスMソスTソス[ソスoソス[ソスナ配ソスMソスソスソス驛会ソスCソスuソスzソスMソスソスソスソスソス^ソスソスナゑソスソスソス謔、ソスノゑソスソスソスBソスソスソスソスソスナは、ソスソスソスCソスuソスzソスMソスソスソスソスソスMP4ソス`ソスソスソスナ録ソス謔オソスAソス゚具ソス24ソスソスソスヤ包ソスソスソスロ托ソスソスソスソストゑソスソスソスソス謔、ソスノゑソスソスソスBソスワゑソスソスAソス^ソス謔オソスソスソスソスソスCソスuソスzソスMソスソスソスソスソスWebソスuソスソスソスEソスUソスソスソス邇具ソスソスソスソスソス驍スソス゚ゑソスHTMLソスソスソスソスソスソスソスソスソスソスソスソスソスソスB

ソスソスソスソスソスソスzソスMソスTソス[ソスoソス[ソス\ソスzソスマでゑソスソス驍アソスソス


ソスソスnginxソスン抵ソス

[root@centos ~]# vi /usr/local/nginx/conf/nginx.confソス@ソスソスソス@nginxソスン抵ソスtソス@ソスCソスソスソスメ集
        # ソスソスソスCソスuソスzソスMソスン抵ソス
        application live {
            live on;

            # 192.168.1.0/24ソスソスソスソスフみソスソスCソスuソスzソスMソスfソス[ソス^ソスフ趣ソスMソスソスソスソスソスソス
            allow publish 192.168.1.0/24;
            deny publish all;

            # HLSソスzソスMソスン抵ソス
            hls on;
            hls_path /usr/local/nginx/html/live; # HLS(HTTP Live Streaming)ソスtソス@ソスCソスソスソス成ソスソス
            hls_fragment 10s; # HLS(HTTP Live Streaming)ソスtソス@ソスCソスソスソスソスソスソスソスソスソスソス

            ソスソスソスCソスuソスzソスMソス^ソスソスン抵ソスヌ会ソスソスiソスソスソスソスソスソスソスソスj
            # ソスソスソスCソスuソスzソスMソス^ソスソスン抵ソス
            record all;
            record_path /usr/local/nginx/html/rec; # ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスロ托ソスソスソス
            record_suffix -%Y%m%d%H%M%S.flv; # ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスtソス^ソスソスソスソスソスソスiソスソス:live-20170226194852.flvソスj
            record_max_size 50M; # ソスソスソスCソスuソスzソスMソス^ソスソス1ソスtソス@ソスCソスソスソスソスソスソスソスソスナ托ソスTソスCソスYソスiソスTソスCソスYソスヘ任ソスモ)
            exec_record_done /usr/local/bin/record_done.sh $path $filename $basename $dirname; # ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソスソスソスソスソスソス
            ソスソスソスCソスuソスzソスMソス^ソスソスン抵ソスヌ会ソスソスiソスソスソスソスソスワで)

        }

[root@centos ~]# mkdir /usr/local/nginx/html/recソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスロ托ソスソスソスfソスBソスソスソスNソスgソスソスソス成

[root@centos ~]# chown nobody /usr/local/nginx/html/rec/ソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスロ托ソスソスソスfソスBソスソスソスNソスgソスソスソスソスソスLソスメ変更

ソスソスソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソス成

ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスiソスソスqソスjソスヨの表ソスソスソスpソスTソスソスソスlソスCソスソスソス鞫懶ソス成ソスAソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスFLVソス`ソスソスソスソスMP4ソス`ソスソスソスヨの変奇ソスソスAソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソスソスソスソスソス鼕ソスソスソスト行ソスソスソスXソスNソスソスソスvソスgソスソスソス成ソスソスソスソスB
[root@centos ~]# vi /usr/local/bin/record_done.shソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソス成
#!/bin/bash

# ${1} path - recorded file path (/tmp/rec/mystream-1389499351.flv)
# ${2} filename - path with directory omitted (mystream-1389499351.flv)
# ${3} basename - file name with extension omitted (mystream-1389499351)
# ${4} dirname - directory path (/tmp/rec)

# ソス^ソスソスtソス@ソスCソスソスソスフサソスソスソスlソスCソスソスソス鞫懶ソス成
JPG_NAME=${4}/${3}.jpg
ffmpeg -y -i ${1} -ss 1 -vframes 1 -f image2 ${JPG_NAME} > /dev/null 2>&1

# MP4ソス`ソスソスソスヨ変奇ソス
ffmpeg -y -i ${1} -vcodec copy -acodec copy ${4}/${3}.mp4
[ $? -eq 0 ] && rm -f ${1}

# ソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソス成
HTML_PATH=`echo ${4} | sed -e 's/\/usr\/local\/nginx\/html\([^ ]*\)/\1/p' -e d`
HTML_NAME=${4}/${3}.html
FLV_NAME=${3}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' > ${HTML_NAME}
echo '  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' >> ${HTML_NAME}
echo '<html xmlns="http://www.w3.org/1999/xhtml">' >> ${HTML_NAME}
echo '<head>' >> ${HTML_NAME}
echo '    <title>'${FLV_NAME}'</title>' >> ${HTML_NAME}
echo '    <link href="//vjs.zencdn.net/5.11.6/video-js.css" rel="stylesheet">' >> ${HTML_NAME}
echo '</head>' >> ${HTML_NAME}
echo '<body>' >> ${HTML_NAME}
echo '    <video id="'${FLV_NAME}'" class="video-js vjs-default-skin" autoplay="autoplay" controls="controls" width="320" height="240" data-setup="{}">' >> ${HTML_NAME}
echo '        <source src="'${HTML_PATH}/${FLV_NAME}.mp4'">' >> ${HTML_NAME}
echo '        <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-sup
port/" target="_blank">supports HTML5 video</a></p>' >> ${HTML_NAME}
echo '    </video>' >> ${HTML_NAME}
echo '</body>' >> ${HTML_NAME}
echo '</html>' >> ${HTML_NAME}


# ソス^ソスソスtソス@ソスCソスソスソスフ更ソスVソスソスソスソスソスソスソスtソス@ソスCソスソスソス成ソスソスソスソスソスノ変更
tmp=`echo ${3} | sed -e 's/live-\([^ ]*\)/\1/p' -e d`
datetime=`echo ${tmp:0:4}`/`echo ${tmp:4:2}`/`echo ${tmp:6:2}`' '`echo ${tmp:8:2}`:`echo ${tmp:10:2}`:`echo ${tmp:12:2}`
touch -d "${datetime}" ${4}/${3}.*

[root@centos ~]# chmod +x /usr/local/bin/record_done.shソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソスヨ趣ソスソスsソスソスソスソスソスtソスソス

[root@centos ~]# systemctl restart nginxソス@ソスソスソス@nginxソスト起ソスソス

ソスソスソスソスソスCソスuソスzソスMソス^ソスソスmソスF

ソスソスhttp://ソスTソス[ソスoソス[ソスソス:8080/rec/live-YYYYMMDDHHMMSS.htmlソスヨアソスNソスZソスXソスソスソストソスソスCソスuソスzソスMソス^ソス謔ェソスソスソスソスソスナゑソスソス驍アソスソス
ソスソスソスソスソスCソスuソスzソスMソス^ソス謔ェrecord_pathソスナ指ソス閧ウソス黷スソスfソスBソスソスソスNソスgソスソスソスi/usr/local/nginx/html/recソスjソスノ作成ソスソスソスソスAソス^ソスソスtソス@ソスCソスソスソスフサソスCソスYソスソスrecord_max_sizeソスナ指ソス閧オソスソスソスTソスCソスYソスノなゑソスソスexec_record_doneソスナ指ソス閧ウソス黷スソスXソスNソスソスソスvソスgソスi/usr/local/bin/record_done.shソスjソスソスソスソスソスsソスソスソスソス驍アソスニにゑソスソスAソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソスソスソスソスソスyソス[ソスWソスソスソス成ソスソスソスソスソス


ソスソスソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソス成

[root@centos ~]# vi /etc/cron.hourly/record_listソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソス成ソスソス1ソスソスソスヤゑソスソスニに趣ソスソスソスソスソスソスsソスソスソスソスソスfソスBソスソスソスNソスgソスソスソスヨ作成
#!/bin/bash

RECORD_PATH=`grep record_path /usr/local/nginx/conf/nginx.conf|awk '{print $2}'|tr -d ";"`

# 24ソスソスソスヤ以前ソスフソスソスCソスuソスzソスMソス^ソスソスヨ連ソスtソス@ソスCソスソスソスiソス^ソスソスtソス@ソスCソスソスソス{ソスフ、ソスTソスソスソスlソスCソスソスソスAソスソスソスソスソスyソス[ソスWソスjソスソスソス除ソスソスソスソス
tmpwatch -m 24 ${RECORD_PATH}

# ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスソスソスソス
HTML_PATH=`echo ${RECORD_PATH} | sed -e 's/\/usr\/local\/nginx\/html\([^ ]*\)/\1/p' -e d`
cd ${RECORD_PATH}
ls *.mp4 > /dev/null 2>&1 ; [ $? -ne 0 ] && exit

rm -f ${RECORD_PATH}/index.html
echo "<html>" >> ${RECORD_PATH}/index.html
echo "<head>" >> ${RECORD_PATH}/index.html
echo "<title>LIVE RECORD LIST</title>" >> ${RECORD_PATH}/index.html
echo "</head>" >> ${RECORD_PATH}/index.html
echo "<body>" >> ${RECORD_PATH}/index.html
echo "<table border=1 style=\"border-collapse:collapse;\">" >> ${RECORD_PATH}/index.html

for mp4 in `ls *.mp4`
do
    fuser ${mp4} > /dev/null 2>&1
    [ $? -eq 0 ] && continue
    jpg=`basename ${mp4} .mp4`.jpg
    html=`basename ${mp4} .mp4`.html
    datetime=`ls -l --time-style="+%Y/%m/%d %H:%M:%S" ${mp4}|awk '{print $6 " " $7}'`
    echo "<tr><td><a href=\"${HTML_PATH}/${html}\" target=\"_blank\"><img src=\"${jpg}\" style=\"width:320px; height:240px;\"></a></td>" >> ${RECORD_PATH}/index.html
    echo "<td>${datetime}</td></tr>" >> ${RECORD_PATH}/index.html
done

echo "</table>" >> ${RECORD_PATH}/index.html
echo "</body>" >> ${RECORD_PATH}/index.html
echo "</html>" >> ${RECORD_PATH}/index.html

[root@centos ~]# chmod +x /etc/cron.hourly/record_listソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスソスソスソスソスXソスNソスソスソスvソスgソスヨ趣ソスソスsソスソスソスソスソスtソスソス

[root@centos ~]# /etc/cron.hourly/record_listソス@ソスソスソス@ソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスソスソスソスソスソスソスソスソスiソスソスソスソスソスソスsソスj

ソスソスソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスyソス[ソスWソスmソスF

ソスソスhttp://ソスTソス[ソスoソス[ソスソス:8080/rec/ソスヨアソスNソスZソスXソスソスソストソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスソスソス\ソスソスソスソスソスソス驍アソスソス
ソスソスソスソスソスCソスuソスzソスMソス^ソスソスtソス@ソスCソスソスソス齬暦ソスソスソスソスCソスモのソスソスCソスuソスzソスMソス^ソスソスyソス[ソスWソスヨアソスNソスZソスXソスソスソストソスソスCソスuソスzソスMソス^ソス謔ェソスソスソスソスソスナゑソスソス驍アソスソス


ソスソスソスヨ連ソスRソスソスソスeソスソスソスc

<!ソス\ソスeソスLソスXソスgソスフみゑソス4ソスsソス\ソスソスソスノ追会ソスソスソスCソスソスソスソスソスソス\>



ソスソスソスソスソスフペソス[ソスWソスフトソスbソスvソスヨ戻ゑソス

ソスvソスソスソスCソスoソスVソス[ソス|ソスソスソスVソス[
centossrv.com