去部落格設定頁面,選擇一款你喜歡的程式碼片高亮樣式,下面 下麪展示同樣高亮的 程式碼片
.
// An highlighted block
#!/bin/bash
################
#auth:dengwei
#Date:2020-05-14
#Version:V1.0.5
#Description:format video
################
##檔案路徑###
File=/usr/local/nginx/html
###需要處理的目錄###
SP=glgs3
SP_N=glgs*
####解析度####
retn4=480
retn7=720
####每個片段的時間###
htime=2
####分片合併腳本###
Format=$File/ffm_hb.py
####本地時間戳###
Date=$(date "+%F %T")
if [ ! -d ${File}/${SP} ];then
mkdir -p ${File}/${SP}
else
echo "${File}/${SP} Directory exists!!!"
fi
cp -i $File/video/${SP_N} ${File}/${SP}/
for dir in $(ls -l $File/$SP |awk '{print $9}'|grep -v "^$"|awk -F"." '{print $1}')
do
echo ${File}/${SP}/${dir}
if [ ! -d ${File}/${SP}/${dir}/480 ];then
echo "Creat ${dir} ${retn4} ${retn7} dir."
mkdir -p ${File}/${SP}/${dir}/{480,720}
else
echo "$SP Directory exists, no need to create!!!!"
fi
done
#獲取檔案列表##
file_n=$(ls -l $File/$SP |awk '{print $9}'|grep -vE "mp4|^$")
file_i=$file_n
for VEO in ${file_i[*]}
do
Vio=$VEO\.mp4
SCE=/usr/local/nginx/html/$SP
#du -sh $SCE/$VEO.mp4
DSTD1=${File}/${SP}/${VEO}/${retn4}/
if [ -d "${DSTD1}" ];then
echo "####Clean Dir!!!####"
for i in $(ls -l ${File}/${SP}|awk '{print $9}'|grep -vE "mp4|^$");do
rm -f {File}/${SP}/$i/{480,720,480_2,720_2}/*;
done
else
echo "directory already exists!!!"
#continue
fi
DSTD2=${File}/${SP}/${VEO}/${retn7}/
/usr/bin/ffmpeg -i ${SCE}/${Vio} -c copy -c:v libx264 -force_key_frames "expr:gte(t,n_forced*1)" -vf scale=-2:${retn4} -c:a aac -strict -2 -f hls -hls_list_size 0 -hls_time ${htime} ${DSTD1}/list.m3u8
echo -e "\033[47;30m #######TIMEWAIT!!! Format 720 video!!!####### \033[0m"
/usr/bin/ffmpeg -i ${SCE}/${Vio} -c copy -c:v libx264 -force_key_frames "expr:gte(t,n_forced*1)" -vf scale=-2:${retn7} -c:a aac -strict -2 -f hls -hls_list_size 0 -hls_time ${htime} ${DSTD2}/list.m3u8
/usr/bin/python3 ${Format} ${DSTD1} ${File}/${SP}/${VEO}/480_2/ >>${File}/hb.log
/usr/bin/python3 ${Format} ${DSTD2} ${File}/${SP}/${VEO}/720_2/ >>${File}/hb.log
if [ -d "${File}/${SP}/${VEO}/480_2" ];then
echo -e "\033[31m Overwrite directory for 2 sec!!!! \033[0m"
/usr/bin/rm -fr ${DSTD1}
/usr/bin/mv ${File}/${SP}/${VEO}/480_2 ${DSTD1}
/usr/bin/rm -fr ${DSTD2}
/usr/bin/mv ${File}/${SP}/${VEO}/720_2 ${DSTD2}
else
echo -e "\033[35m Check is Failed!!!! \033[0m"
fi
echo "######$Date $VEO壓縮完成!!!" >>${File}/format.log
echo -e "\033[36m ==================++++++++++++================= \033[0m"
done
for i in $(ls -l ${File}/${SP} |awk '{print $9}'|grep -vE "mp4|^$")
do
echo -e "\033[44;37m ADD \#EXT-X-PLAYLIST-TYPE\:VOD conf to list.m3u8!!! \033[0m"
/usr/bin/sed -i '3i #EXT-X-PLAYLIST-TYPE:VOD' ${File}/${SP}/${i}/{480,720}/list.m3u8
done