@@ -12,10 +12,9 @@ Python >= 3.9 is recommended for full capabilities.
12
12
` visual_tests.py ` is a quick check of several command line scripting scenarios on your laptop.
13
13
FFmpeg is used from Python ` subprocess ` to stream to sites including:
14
14
15
- * [ Facebook Live] ( #facebook-live ) (requires FFmpeg >= 4.2 due to mandatory RTMPS)
16
- * [ YouTube Live] ( #youtube-live )
17
- * [ Twitter Live] ( #twitter )
18
- * [ Twitch] ( #twitch )
15
+ * Facebook Live (requires FFmpeg >= 4.2 due to mandatory RTMPS)
16
+ * YouTube Live
17
+ * Twitch
19
18
* also Ustream, Vimeo, Restream.io and more for streaming broadcasts.
20
19
21
20
![ PyLivestream diagram showing screen capture or camera simultaneously livestreaming to multiple services.] ( ./doc/logo.png )
@@ -74,28 +73,24 @@ python3 -m pip install -e .
74
73
You can skip past this section to "stream start" if it's confusing.
75
74
The defaults might work to get you started.
76
75
77
- The pylivestream.json file has parameters relevant to the live stream.
78
- This file is copied into your ` sys.prefix ` /share/pylivestream directory upon ` pip install pylivestream ` .
79
-
80
- We suggest copying this file to another location on your hard drive and editing, then specifying it for your streams.
81
-
82
- The ` [DEFAULT] ` section has parameters that can be overridden for each site, if desired.
76
+ The pylivestream.json file you create has parameters relevant to the live stream.
77
+ We suggest copying the example
78
+ [ pylivestream.json] ( ./src/pylivestream/data/pylivestream.json )
79
+ and editing, then specify it for your streams.
83
80
84
81
* ` screencap_origin ` : origin (upper left corner) of screen capture region in pixels.
85
82
* ` screencap_size ` : resolution of screen capture (area to capture, starting from origin)
86
83
* ` screencap_fps ` : frames/sec of screen capture
87
84
* ` video_kbps ` : override automatic video bitrate in kbps
88
-
89
85
* ` audio_rate ` : audio sampling frequency. Typically 44100 Hz (CD quality).
90
86
* ` audio_bps ` : audio data rate--** leave blank if you want no audio** (usually used for "file", to make an animated GIF in post-processing)
91
87
* ` preset ` : ` veryfast ` or ` ultrafast ` if CPU not able to keep up.
88
+ * ` exe ` : override path to desired FFmpeg executable. In case you have multiple FFmpeg versions installed (say, from Anaconda Python).
92
89
93
90
Next are ` sys.platform ` specific parameters.
94
91
95
92
Seek help in FFmpeg documentation, try capturing to a file first and then update ~ /pylivestream.json for ` sys.platform ` .
96
93
97
- * exe: override path to desired FFmpeg executable. In case you have multiple FFmpeg versions installed (say, from Anaconda Python).
98
-
99
94
### Deduce inputs
100
95
101
96
Each computer will need distinct pylivestream.json device input parameters:
@@ -150,25 +145,23 @@ The user must specify this JSON file location.
150
145
### YouTube Live
151
146
152
147
1 . [ configure] ( https://www.youtube.com/live_dashboard ) YouTube Live.
153
- 2 . Edit file ` youtube .json` to have the YouTube hexadecimal stream key
148
+ 2 . Edit "pylivestream .json" to have the YouTube streamid
154
149
3 . Run Python script and chosen input will stream on YouTube Live.
155
150
156
151
``` sh
157
- python -m pylivestream.screen youtube
152
+ python -m pylivestream.screen youtube ./pylivestream.json
158
153
```
159
154
160
155
### Facebook Live
161
156
162
157
Facebook Live requires FFmpeg >= 4.2 due to mandatory RTMPS
163
158
164
159
1 . configure your Facebook Live stream
165
- 2 . Put stream ID from
166
- [ < https://www.facebook.com/live/create > ] ( https://www.facebook.com/live/create )
167
- into the file ` ~/facebook.json `
160
+ 2 . Put [ stream ID] ( https://www.facebook.com/live/create ) into the JSON file
168
161
3 . Run Python script for Facebook with chosen input
169
162
170
163
``` sh
171
- python -m pylivestream.screen facebook
164
+ python -m pylivestream.screen facebook ./pylivestream.json
172
165
```
173
166
174
167
### Twitter
177
170
178
171
### Twitch
179
172
180
- Create stream from [ Twitch Dashboard] ( https://dashboard.twitch.tv/settings/channel#stream-preferences ) .
181
- Create pylivestream.json file with "url" and "streamid" for Twitch.
173
+ Create stream from
174
+ [ Twitch Dashboard] ( https://dashboard.twitch.tv/settings/channel#stream-preferences ) .
175
+ Edit pylivestream.json file with "url" and "streamid" for Twitch.
182
176
Run Python script for Twitch with chosen input:
183
177
184
178
``` sh
@@ -189,21 +183,10 @@ python -m pylivestream.screen twitch ./pylivestream.json
189
183
190
184
Due to the complexity of streaming and the non-specific error codes FFmpeg emits, the default behavior is that if FFmpeg detects one stream has failed, ALL streams will stop streaming and the program ends.
191
185
192
- Setup ~ /pylivestream.json for computer and desired parameters.
193
- Setup a JSON file "pylivestream.json" with values you determine, not these dummy values:
194
-
195
- ``` json
196
- {
197
- "facebook" : {
198
- "url" : " rtmps://live-api-s.facebook.com:443/rtmp" ,
199
- "streamid" : " your-stream-id" ,
200
- },
201
- "youtube" : {
202
- "url" : " rtmp://a.rtmp.youtube.com/live2" ,
203
- "streamid" : " your-stream-id"
204
- }
205
- }
206
- ```
186
+ Setup a pylivestream.json for computer and desired parameters.
187
+ Copy the provided
188
+ [ pylivestream.json] ( ./src/pylivestream/data/pylivestream.json )
189
+ and edit with values you determine.
207
190
208
191
[ File-Streaming] ( ./File-Streaming.md )
209
192
@@ -219,23 +202,23 @@ JSON:
219
202
Stream to multiple sites, in this example Facebook Live and YouTube Live simultaneously:
220
203
221
204
``` sh
222
- python -m pylivestream.camera youtube facebook
205
+ python -m pylivestream.camera youtube facebook ./pylivestream.json
223
206
```
224
207
225
208
### Screen Share Livestream
226
209
227
210
Stream to multiple sites, in this example Facebook Live and YouTube Live simultaneously:
228
211
229
212
``` sh
230
- python -m pylivestream.screen youtube facebook
213
+ python -m pylivestream.screen youtube facebook ./pylivestream.json
231
214
```
232
215
233
216
### Image + Audio Livestream
234
217
235
218
Microphone audio + static image is accomplished by
236
219
237
220
``` sh
238
- python -m pylivestream.microphone youtube facebook -image doc/logo.jpg
221
+ python -m pylivestream.microphone youtube facebook ./pylivestream.json -image doc/logo.jpg
239
222
```
240
223
241
224
or wherever your image file is.
@@ -248,15 +231,15 @@ That's not something we can fix within the scope of this project.
248
231
You can test it to your own computer by:
249
232
250
233
``` sh
251
- python -m pylivestream.microphone localhost
234
+ python -m pylivestream.microphone localhost ./pylivestream.json
252
235
```
253
236
254
237
### Screen capture to disk
255
238
256
239
This script saves your screen capture to a file on your disk:
257
240
258
241
``` sh
259
- python -m pylivestream.screen2disk myvid.avi
242
+ python -m pylivestream.screen2disk myvid.avi ./pylivestream.json
260
243
```
261
244
262
245
## Utilities
0 commit comments