forked from m1k1o/hls-restream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abr_transcoding_hd_1080p.sh
executable file
·109 lines (106 loc) · 3.94 KB
/
abr_transcoding_hd_1080p.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
cd "$(dirname "$0")"
source .helpers.sh
function generate_playlist {
echo '#EXTM3U'
echo '#EXT-X-VERSION:3'
echo '#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360'
echo "$1_360p.m3u8"
echo '#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=842x480'
echo "$1_480p.m3u8"
echo '#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720'
echo "$1_720p.m3u8"
echo '#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080'
echo "$1_1080p.m3u8"
} > "/var/www/html/$1.m3u8"
generate_playlist "$1"
ffmpeg -hide_banner -hwaccel_output_format cuda -c:v "$(cuvid_codec "$2")" \
-i "$2" \
-map 0:v:0 -map 0:a:0 \
-vf hwupload_cuda,yadif_cuda=0:-1:0,scale_npp=640:360:interp_algo=super \
-c:a aac \
-ar 48000 \
-b:a 96k \
-c:v h264_nvenc \
-profile:v main \
-b:v 800k \
-maxrate 856k \
-bufsize 1200k \
-crf 20 \
-sc_threshold 0 \
-g 48 \
-keyint_min 48 \
-f hls \
-hls_time 6 \
-hls_list_size 4 \
-hls_delete_threshold 1 \
-hls_flags delete_segments \
-hls_start_number_source datetime \
-hls_segment_filename "/var/www/html/$1_360p_%03d.ts" \
"/var/www/html/$1_360p.m3u8" \
-map 0:v:0 -map 0:a:0 \
-vf hwupload_cuda,yadif_cuda=0:-1:0,scale_npp=842:480:interp_algo=super \
-c:a aac \
-ar 48000 \
-b:a 128k \
-c:v h264_nvenc \
-profile:v main \
-b:v 1400k \
-maxrate 1498k \
-bufsize 2100k \
-crf 20 \
-sc_threshold 0 \
-g 48 \
-keyint_min 48 \
-f hls \
-hls_time 6 \
-hls_list_size 4 \
-hls_delete_threshold 1 \
-hls_flags delete_segments \
-hls_start_number_source datetime \
-hls_segment_filename "/var/www/html/$1_480p_%03d.ts" \
"/var/www/html/$1_480p.m3u8" \
-map 0:v:0 -map 0:a:0 \
-vf hwupload_cuda,yadif_cuda=0:-1:0,scale_npp=1280:720:interp_algo=super \
-c:a aac \
-ar 48000 \
-b:a 128k \
-c:v h264_nvenc \
-profile:v main \
-b:v 2800k \
-maxrate 2996k \
-bufsize 4200k \
-crf 20 \
-sc_threshold 0 \
-g 48 \
-keyint_min 48 \
-f hls \
-hls_time 6 \
-hls_list_size 4 \
-hls_delete_threshold 1 \
-hls_flags delete_segments \
-hls_start_number_source datetime \
-hls_segment_filename "/var/www/html/$1_720p_%03d.ts" \
"/var/www/html/$1_720p.m3u8" \
-map 0:v:0 -map 0:a:0 \
-vf hwupload_cuda,yadif_cuda=0:-1:0,scale_npp=1920:1080:interp_algo=super \
-c:a aac \
-ar 48000 \
-b:a 192k \
-c:v h264_nvenc \
-profile:v main \
-b:v 5000k \
-maxrate 5350k \
-bufsize 7500k \
-crf 20 \
-sc_threshold 0 \
-g 48 \
-keyint_min 48 \
-f hls \
-hls_time 6 \
-hls_list_size 4 \
-hls_delete_threshold 1 \
-hls_flags delete_segments \
-hls_start_number_source datetime \
-hls_segment_filename "/var/www/html/$1_1080p_%03d.ts" \
"/var/www/html/$1_1080p.m3u8";