-
Notifications
You must be signed in to change notification settings - Fork 7
/
transcode
executable file
·45 lines (41 loc) · 3.3 KB
/
transcode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
trap "pkill -KILL -P $$" TERM
streamInfo=$(/usr/local/nginx/ffmpeg/bin/ffprobe -v error -select_streams v:0 -show_entries stream=width,height,avg_frame_rate rtmp://localhost/stream/"$1")
width=$(echo "$streamInfo" | grep width | cut -d '=' -f 2)
height=$(echo "$streamInfo" | grep height | cut -d '=' -f 2)
frameRate=$(($(echo "$streamInfo" | grep avg_frame_rate | cut -d '=' -f 2)))
if [ $width -ge 1920 ] && [ $height -ge 1080 ]; then
if [ $frameRate -ge 60 ]; then
/usr/local/nginx/ffmpeg/bin/ffmpeg -i rtmp://localhost/stream/$1 \
-c copy -f flv rtmp://localhost/hls/"$2"_108060 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 1920x1080 -r 30 -b:v 5000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 192k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_108030 \
-c:v libx264 -x264opts keyint=120:no-scenecut -s 1280x720 -r 60 -b:v 4500k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 128k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_72060 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 1280x720 -r 30 -b:v 4000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 128k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_72030 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 852x480 -r 30 -b:v 2000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 96k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_48030 \
-vf fps=1/10 -y -update 1 ./thumbnails/$2.png &
else
/usr/local/nginx/ffmpeg/bin/ffmpeg -i rtmp://localhost/stream/$1 \
-c copy -f flv rtmp://localhost/hls/"$2"_108030 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 1280x720 -r 30 -b:v 4000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 128k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_72030 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 852x480 -r 30 -b:v 2000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 96k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_48030 \
-vf fps=1/10 -y -update 1 ./thumbnails/$2.png &
fi
elif [ $width -ge 1280 ] && [ $height -ge 720 ]; then
if [ $frameRate -ge 60 ]; then
/usr/local/nginx/ffmpeg/bin/ffmpeg -i rtmp://localhost/stream/$1 \
-c copy -f flv rtmp://localhost/hls/"$2"_72060 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 1280x720 -r 30 -b:v 4000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 128k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_72030 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 852x480 -r 30 -b:v 2000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 96k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_48030 \
-vf fps=1/10 -y -update 1 ./thumbnails/$2.png &
else
/usr/local/nginx/ffmpeg/bin/ffmpeg -i rtmp://localhost/stream/$1 \
-c copy -f flv rtmp://localhost/hls/"$2"_72030 \
-c:v libx264 -x264opts keyint=60:no-scenecut -s 852x480 -r 30 -b:v 2000k -profile:v main -preset veryfast -c:a libfdk_aac -b:a 96k -sws_flags bilinear -hls_list_size 6 -f flv rtmp://localhost/hls/"$2"_48030 \
-vf fps=1/10 -y -update 1 ./thumbnails/$2.png &
fi
else
/usr/local/nginx/ffmpeg/bin/ffmpeg -i rtmp://localhost/stream/$1 \
-c copy -f flv rtmp://localhost/hls/"$2"_48030 \
-vf fps=1/10 -y -update 1 ./thumbnails/$2.png &
fi
wait