This repository was archived by the owner on Mar 6, 2025. It is now read-only.
File tree 5 files changed +23
-16
lines changed
5 files changed +23
-16
lines changed Original file line number Diff line number Diff line change 1
1
name : ci
2
2
3
- env :
4
- HOMEBREW_NO_INSTALL_CLEANUP : 1
5
-
6
3
on :
7
4
push :
8
5
paths :
45
42
- name : install prereqs (macOS)
46
43
if : runner.os == 'macOS'
47
44
run : brew install ffmpeg
45
+ env :
46
+ HOMEBREW_NO_INSTALL_CLEANUP : 1
48
47
49
48
- name : Install winget
50
49
if : runner.os == 'Windows'
Original file line number Diff line number Diff line change @@ -205,7 +205,9 @@ JSON:
205
205
* ` camera_size ` : camera resolution -- find from ` v4l2-ctl --list-formats-ext ` or camera spec sheet.
206
206
* ` camera_fps ` : camera fps -- found from command above or camera spec sheet
207
207
208
- Stream to multiple sites, in this example Facebook Live and YouTube Live simultaneously:
208
+ Stream to multiple sites. This uses FFmpeg
209
+ [ -f tee] ( https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Teepseudo-muxer ) .
210
+ For example, Facebook Live and YouTube Live simultaneously:
209
211
210
212
``` sh
211
213
python -m pylivestream.camera youtube facebook ./pylivestream.json
Original file line number Diff line number Diff line change @@ -103,7 +103,12 @@ def startlive(self, sinks: list[str] | None = None):
103
103
run (self .cmd )
104
104
elif len (sinks ) == 1 :
105
105
run (self .cmd )
106
- else : # multi-stream output tee
106
+ else :
107
+ """
108
+ multi-stream output tee
109
+ https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Teepseudo-muxer
110
+ https://trac.ffmpeg.org/wiki/EncodingForStreamingSites#Outputtingtomultiplestreamingserviceslocalfile
111
+ """
107
112
cmdstem : list [str ] = self .cmd [:- 3 ]
108
113
# +global_header is necessary to tee to multiple services
109
114
cmd : list [str ] = cmdstem + ["-flags:v" , "+global_header" , "-f" , "tee" ]
@@ -115,7 +120,8 @@ def startlive(self, sinks: list[str] | None = None):
115
120
if self .vidsource == "file" :
116
121
# picks first video and audio stream, often correct
117
122
cmd += ["-map" , "0:v" , "-map" , "0:a:0" ]
118
- else : # device (Camera)
123
+ else :
124
+ # device (Camera)
119
125
# connect video device to video stream,
120
126
# audio device to audio stream
121
127
cmd += ["-map" , "0:v" , "-map" , "1:a" ]
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def __init__(self):
21
21
# default 8, increasing can help avoid warnings
22
22
self .QUEUE = ["-thread_queue_size" , "8" ]
23
23
24
+ # https://trac.ffmpeg.org/wiki/StreamingGuide#The-reflag
24
25
self .THROTTLE = "-re"
25
26
26
27
def timelimit (self , t : str | int | float | None ) -> list [str ]:
Original file line number Diff line number Diff line change @@ -212,17 +212,16 @@ def audioOut(self) -> list[str]:
212
212
https://www.facebook.com/facebookmedia/get-started/live
213
213
"""
214
214
215
- if not (self .audio_bps and self .acap and self .audio_chan and self .audio_rate ):
216
- return []
215
+ o = []
216
+
217
+ if self .audio_codec :
218
+ o += ["-codec:a" , self .audio_codec ]
219
+ if self .audio_bps :
220
+ o += ["-b:a" , str (self .audio_bps )]
221
+ if self .audio_rate :
222
+ o += ["-ar" , str (self .audio_rate )]
217
223
218
- return [
219
- "-codec:a" ,
220
- self .audio_codec ,
221
- "-b:a" ,
222
- str (self .audio_bps ),
223
- "-ar" ,
224
- str (self .audio_rate ),
225
- ]
224
+ return o
226
225
227
226
def video_bitrate (self ) -> None :
228
227
"""
You can’t perform that action at this time.
0 commit comments