forked from streamlinevideo/streamline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildEncoder.sh
executable file
·157 lines (106 loc) · 3.82 KB
/
buildEncoder.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# update the OS
sudo apt-get -y update
sudo apt-get -y upgrade
# Download capture card drivers and SDK
wget https://hellavision.s3-us-west-2.amazonaws.com/Blackmagic_Desktop_Video_Linux_10.9.10.tar.gz
wget https://hellavision.s3-us-west-2.amazonaws.com/Blackmagic_DeckLink_SDK_10.9.10.zip
# Install dependencies
sudo apt-get install -y --allow-unauthenticated nasm autoconf htop \
automake build-essential libass-dev curl zlib1g-dev openssh-server \
autoconf libfreetype6-dev texinfo nvidia-384 zlibc \
libsdl2-dev libtool libvdpau-dev libxcb1-dev libxcb-shm0-dev \
libpango1.0-0 libfdk-aac-dev yasm unzip libxcb-xfixes0-dev texi2html \
libssl-dev libx264-dev dkms libssh-dev pkg-config \
nvidia-cuda-toolkit g++-5 libnuma1 libnuma-dev libc6 libc6-dev
# Install NVIDIA GPU SDK
unzip -n *.zip
#sudo cp nvenc_5.0.1_sdk/Samples/common/inc/* /usr/include/
sudo cp -vr Video_Codec_SDK_8.0.14/Samples/common/inc/GL/* /usr/include/GL/
sudo cp -vr Video_Codec_SDK_8.0.14/Samples/common/inc/*.h /usr/include/
# Install FFmpeg NVIDIA headers
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd ~/streamline/nv-codec-headers
make
sudo make install
cd ~/streamline
# Install Black Magic capture card driver and SDK
unzip -n Blackmagic_DeckLink_SDK_10.9.10.zip
mv -n "Blackmagic DeckLink SDK 10.9.10/" Blackmagic_DeckLink_SDK_10.9.10
tar -xvf Blackmagic_Desktop_Video_Linux_10.9.10.tar.gz
sudo dpkg -i Blackmagic_Desktop_Video_Linux_10.9.10/deb/x86_64/*
sudo cp -r Blackmagic_DeckLink_SDK_10.9.10/Examples/Linux/bin/x86_64/* /bin/
# Download and compile FFmpeg
rm -r -f ~/streamline/FFmpeg/
git clone https://github.com/FFmpeg/FFmpeg.git -b master
cd FFmpeg
# Check out a version of FFmpeg without a certain HLS bug
git checkout f5f2209d689cd17f4bce7ce5c4f0b1634befc785
# Create patch for FFmpeg for an HTTP bug that affects persistent connections over time.
cat > patch.patch << _PATCH_
---
libavformat/http.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavformat/http.c b/libavformat/http.c
index 344fd60..a93fa54 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1611,6 +1611,18 @@ static int http_write(URLContext *h, const uint8_t *buf, int size)
return size;
}
+static int http_read_response(URLContext *h) {
+ HTTPContext *s = h->priv_data;
+ char buf[1024];
+ int ret;
+
+ /* dummy read in nonblocking mode to clear the receive buffer */
+ s->hd->flags |= AVIO_FLAG_NONBLOCK;
+ ret = ffurl_read(s->hd, buf, sizeof(buf));
+ s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
+ return ret;
+}
+
static int http_shutdown(URLContext *h, int flags)
{
int ret = 0;
@@ -1622,6 +1634,7 @@ static int http_shutdown(URLContext *h, int flags)
((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) {
ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
ret = ret > 0 ? 0 : ret;
+ http_read_response(h);
s->end_chunked_post = 1;
}
--
1.9.1
_PATCH_
# Run patch for FFmpeg
patch -p1 < patch.patch
# Configure FFmpeg build
./configure \
--extra-cflags=-I$HOME/streamline/Blackmagic_DeckLink_SDK_10.9.10/Linux/include \
--extra-ldflags=-L-I$HOME/streamline/Blackmagic_DeckLink_SDK_10.9.10/Linux/include \
--extra-cflags=-I/usr/local/cuda/include/ \
--extra-ldflags=-L/usr/local/cuda/lib64/ \
--extra-cflags=-I/usr/local/include/ \
--extra-ldflags=-L/usr/local/include/ \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libx264 \
--enable-nonfree \
--enable-openssl \
--enable-decklink \
--enable-libnpp \
--enable-cuda-sdk \
--enable-libfreetype
# Build ffmpeg
make
# Install FFmpeg
sudo make -j$(nproc) install
make -j$(nproc) distclean
hash -r
# Remove downloads
cd ~/streamline
rm -r -f *.zip *.deb *.tar FFmpeg*
rm -r -f nv-codec-headers *Blackmagic*
echo "You are ready to reboot."