Last active
June 26, 2021 14:33
-
-
Save zwh8800/3ced21987775745ec2a0832170f38af0 to your computer and use it in GitHub Desktop.
将nas中的b站热门视频推成m3u8流,支持竖屏加边框,内嵌弹幕,内嵌av号,内嵌播放进度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir="/_ds3617xs/bilibili" | |
file_list=`find $dir -name "*.flv" | shuf | head -n 30` | |
list_file="$dir/live$1.list" | |
echo > $list_file | |
ass_file_list="" | |
for file in $file_list; do | |
echo ${file//\/_ds3617xs\/bilibili/http://10.0.0.220:8004/bilibili} >> $list_file | |
ass_file_list="$ass_file_list${file//.flv/.xml} " | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
base_dir="$1" | |
stream_num="$2" | |
cd $base_dir | |
function toTs { | |
for f in $@; do | |
>&2 echo $f | |
if [ -z "$f" ]; then | |
continue | |
fi | |
rm live$stream_num.ass | |
wget -q ${f//.flv/.ass} -O live$stream_num.ass | |
av=${f//http:\/\/10.0.0.220:8004\/bilibili\//} | |
av=${av//.flv/} | |
if [ -f "live$stream_num.ass" ]; then | |
duration=`ffmpeg -i $f 2>&1 | egrep '[0-9]{2}:[0-9]{2}:[0-9]{2}' -o | sed 's/:/\\\\:/g'` | |
ffmpeg -c:v h264_mmal -i $f \ | |
-vf "scale=-1:720,pad=1280:ih:(ow-iw)/2,drawtext=text=$av:x=10:y=685:fontsize=24:borderw=1:fontcolor=white:alpha=0.5,drawtext=text='%{pts\:gmtime\:0\:%H\\\\\:%M\\\\\:%S}/${duration}':x=1100:y=685:fontsize=16:borderw=1:fontcolor=white:alpha=0.5,ass=live$stream_num.ass" \ | |
-c:v h264_omx -b:v 6000k -c:a copy -sn \ | |
-f ismv \ | |
pipe:1 2>/dev/null | |
fi | |
done | |
} | |
while : | |
do | |
# rm $base_dir/* | |
wget -q "http://10.0.0.220:8004/bilibili/live$stream_num.list" -O live$stream_num.list | |
list=`cat live$stream_num.list` | |
toTs $list | | |
ffmpeg -re -y \ | |
-i - \ | |
-c:v copy -c:a copy -sn \ | |
-f hls -hls_list_size 6 -hls_wrap 10 -hls_time 10 -hls_segment_filename "live$stream_num-%03d.ts" \ | |
$base_dir/live$stream_num.m3u8 | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
base_dir="$1" | |
stream_num="$2" | |
cd $base_dir | |
function toTs { | |
for f in $@; do | |
>&2 echo $f | |
if [ -z "$f" ]; then | |
continue | |
fi | |
rm live$stream_num.ass | |
wget -q ${f//.flv/.ass} -O live$stream_num.ass | |
av=${f//http:\/\/10.0.0.220:8004\/bilibili\//} | |
av=${av//.flv/} | |
if [ -f "live$stream_num.ass" ]; then | |
duration=`ffmpeg -i $f 2>&1 | egrep '[0-9]{2}:[0-9]{2}:[0-9]{2}' -o | sed 's/:/\\\\:/g'` | |
ffmpeg -loglevel warning \ | |
-hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format nv12 \ | |
-i $f \ | |
-vaapi_device /dev/dri/renderD128 \ | |
-vf "scale=-1:720,pad=1280:ih:(ow-iw)/2,drawtext=text=$av:x=10:y=685:fontsize=24:borderw=1:fontcolor=white:alpha=0.5,drawtext=text='%{pts\:gmtime\:0\:%H\\\\\:%M\\\\\:%S}/${duration}':x=1100:y=685:fontsize=16:borderw=1:fontcolor=white:alpha=0.5,fps=30,ass=live$stream_num.ass,format=nv12,hwupload" \ | |
-c:v h264_vaapi -c:a aac -sn \ | |
-f mpegts \ | |
pipe:1 | |
fi | |
done | |
} | |
while : | |
do | |
# rm $base_dir/* | |
wget -q "http://10.0.0.220:8004/bilibili/live$stream_num.list" -O live$stream_num.list | |
list=`cat live$stream_num.list` | |
toTs $list | | |
ffmpeg -y -re \ | |
-i - \ | |
-c:v copy -c:a copy -sn \ | |
-f hls -hls_list_size 6 -hls_wrap 10 -hls_time 10 -hls_segment_filename "live$stream_num-%03d.ts" \ | |
$base_dir/live$stream_num.m3u8 | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
将nas中拉去到的b站热门视频推成m3u8流,支持竖屏加边框,内嵌弹幕,内嵌av号,内嵌播放进度