Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Commit 3074c9d

Browse files
committed
don't run command, just print it
1 parent 8784bf8 commit 3074c9d

File tree

6 files changed

+20
-260
lines changed

6 files changed

+20
-260
lines changed

File-Streaming.md

+1-69
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,7 @@
11
# File Livestream
22

3-
Captions: if you have installed the optional `tinytag` Python module,
4-
the Title - Artist will be added automatically onto the video from the
5-
audio/video files.
6-
7-
## Loop single video endlessly
3+
Stream single video file:
84

95
```sh
106
python -m pylivestream.loopfile videofile site
117
```
12-
13-
## several video files
14-
15-
Glob list of video files to stream:
16-
17-
```sh
18-
python -m pylivestream.fglob path site -glob glob_pattern
19-
```
20-
21-
* `-glob` glob pattern of files to stream e.g. `*.avi`. For [recursive globbing](https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob), do like `**/*.avi`.
22-
* `-loop` optionally loop endlessly the globbed file list
23-
* `-shuffle` optionally shuffle the globbed file list
24-
* `-image` if you have AUDIO files, you should normally set an image to display, as most/all streaming sites REQUIRE a video feed--even a static image.
25-
* `-nometa` disable Title - Artist text overlay
26-
27-
## stream all videos in directory
28-
29-
Example: all AVI videos in directory `~/Videos`:
30-
31-
```sh
32-
python -m pylivestream.fglob ~/Videos youtube -glob "*.avi"
33-
```
34-
35-
## stream endlessly looping videos
36-
37-
Example: all AVI videos in `~/Videos` are endlessly looped:
38-
39-
```sh
40-
python -m pylivestream.fglob ~/Videos youtube -glob "*.avi" -loop
41-
```
42-
43-
## stream m3u8 playlist
44-
45-
m3u8 playlist [example](./Examples/playlist_m3u8.py)
46-
47-
## stream all audio files in directory
48-
49-
Glob list of video files to stream. Suggest including a static -image (could be your logo):
50-
51-
```sh
52-
python -m pylivestream.fglob path site -glob glob_pattern -image image
53-
```
54-
55-
* `path` path to where video files are
56-
* `glob_pattern` e.g. `*.avi` pattern matching video files
57-
* `-image` filename of image to use as stream background (REQUIRED for most websites)
58-
59-
Example: stream all .mp3 audio under `~/music` directory:
60-
61-
```sh
62-
python -m pylivestream.fglob ~/music youtube -glob "*.mp3" -image mylogo.jpg
63-
```
64-
65-
Example: stream all .mp3 audio in `~/music` with an animated GIF or video clip repeating:
66-
67-
```sh
68-
python -m pylivestream.fglob ~/music youtube -glob "*.mp3" -image myclip.avi
69-
```
70-
71-
or
72-
73-
```sh
74-
python -m pylivestream.fglob ~/music youtube -glob "*.mp3" -image animated.gif
75-
```

README.md

+14-26
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
[![DOI](https://zenodo.org/badge/91214767.svg)](https://zenodo.org/badge/latestdoi/91214767)
44
![Actions Status](https://github.com/scivision/pylivestream/workflows/ci/badge.svg)
5-
[![pypi versions](https://img.shields.io/pypi/pyversions/PyLivestream.svg)](https://pypi.python.org/pypi/PyLivestream)
6-
[![PyPi Download stats](https://static.pepy.tech/badge/pylivestream)](https://pepy.tech/project/pylivestream)
5+
[![PyPI versions](https://img.shields.io/pypi/pyversions/PyLivestream.svg)](https://pypi.python.org/pypi/PyLivestream)
6+
[![PyPI Download stats](https://static.pepy.tech/badge/pylivestream)](https://pepy.tech/project/pylivestream)
77

8-
Streams to a livestreaming video service, using pure object-oriented Python (no extra packages) to call FFmpeg.
8+
NOTE: This project is archived effectively. Use OBS Studio etc. for livestreaming.
9+
10+
Emits command to run FFmpeg for livestreaming video services, using pure object-oriented Python.
911
Tested with `flake8`, `mypy` type checking and `pytest`.
1012
`visual_tests.py` is a quick check of several command line scripting scenarios on your laptop.
1113
FFmpeg is used from Python `subprocess` to stream to sites including:
@@ -48,8 +50,6 @@ Other projects using FFmpeg from Python include:
4850

4951
## Install
5052

51-
Requires FFmpeg ≥ 4.2 for RTMPS as required or recommended by Facebook Live, YouTube Live, etc.
52-
5353
Latest release:
5454

5555
```sh
@@ -128,9 +128,6 @@ v4l2-ctl --list-devices
128128

129129
## API
130130

131-
There are two ways to start a stream (assuming you've configured as per following sections).
132-
Both do the same thing.
133-
134131
* command line
135132
* python -m pylivestream.fglob
136133
* python -m pylivestream.screen
@@ -152,7 +149,7 @@ The user must specify this JSON file location.
152149

153150
1. [configure](https://www.youtube.com/live_dashboard) YouTube Live.
154151
2. Edit "pylivestream.json" to have the YouTube streamid
155-
3. Run Python script and chosen input will stream on YouTube Live.
152+
3. Run Python script for YouTube with chosen input
156153

157154
```sh
158155
python -m pylivestream.screen youtube ./pylivestream.json
@@ -183,14 +180,16 @@ python -m pylivestream.screen twitch ./pylivestream.json
183180

184181
## Usage
185182

186-
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.
187-
188183
Setup a pylivestream.json for computer and desired parameters.
189184
Copy the provided
190185
[pylivestream.json](./src/pylivestream/data/pylivestream.json)
191186
and edit with values you determine.
192187

193-
[File-Streaming](./File-Streaming.md)
188+
Single video file:
189+
190+
```sh
191+
python -m pylivestream.loopfile videofile youtube
192+
```
194193

195194
### Camera
196195

@@ -201,43 +200,32 @@ JSON:
201200
* `camera_size`: camera resolution -- find from `v4l2-ctl --list-formats-ext` or camera spec sheet.
202201
* `camera_fps`: camera fps -- found from command above or camera spec sheet
203202

204-
Stream to livestreaming service using FFmpeg.
205203
```sh
206204
python -m pylivestream.camera youtube ./pylivestream.json
207205
```
208206

209-
### Screen Share Livestream
210-
211-
Stream to livestreaming service, in this example Facebook Live:
207+
Screenshare Livestream:
212208

213209
```sh
214210
python -m pylivestream.screen facebook ./pylivestream.json
215211
```
216212

217-
### Image + Audio Livestream
218-
219-
Microphone audio + static image is accomplished by
213+
Microphone audio + static image is accomplished by:
220214

221215
```sh
222216
python -m pylivestream.microphone youtube ./pylivestream.json -image doc/logo.jpg
223217
```
224218

225-
or wherever your image file is.
226-
227219
### Audio-only Livestream
228220

229221
Audio-only streaming is not typically allowed by the Video streaming sites.
230222
It may fail to work altogether, or may fail when one file is done and another starts.
231-
That's not something we can fix within the scope of this project.
232-
You can test it to your own computer by:
233223

234224
```sh
235225
python -m pylivestream.microphone localhost ./pylivestream.json
236226
```
237227

238-
### Screen capture to disk
239-
240-
This script saves your screen capture to a file on your disk:
228+
Saves screen capture to a file on your disk:
241229

242230
```sh
243231
python -m pylivestream.screen2disk myvid.avi ./pylivestream.json

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ version = {attr = "pylivestream.__version__"}
2727
[project.optional-dependencies]
2828
tests = ["pytest", "pytest-timeout"]
2929
lint = ["flake8", "flake8-bugbear", "flake8-builtins", "flake8-blind-except", "mypy"]
30-
captions = ["tinytag"]
3130

3231
[tool.black]
3332
line-length = 100

src/pylivestream/api.py

+4-24
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
from pathlib import Path
1313

1414
from .base import FileIn, Microphone, SaveDisk, Camera
15-
from .fglob import stream_files
1615
from .screen import stream_screen
1716

1817
__all__ = [
1918
"stream_file",
20-
"stream_files",
2119
"stream_microphone",
2220
"stream_camera",
2321
"stream_screen",
@@ -35,14 +33,7 @@ def stream_file(
3533
):
3634
S = FileIn(ini_file, websites, infn=video_file, loop=loop, yes=assume_yes, timeout=timeout)
3735

38-
# %% Go live
39-
if assume_yes:
40-
print(f"going live on {websites} with file {video_file}")
41-
else:
42-
input(f"Press Enter to go live on {websites} with file {video_file}")
43-
print("Or Ctrl C to abort.")
44-
45-
S.stream.startlive()
36+
print(" ".join(S.stream.cmd))
4637

4738

4839
def stream_microphone(
@@ -57,15 +48,9 @@ def stream_microphone(
5748
livestream audio, with still image background
5849
"""
5950

60-
s = Microphone(ini_file, websites, image=still_image, yes=assume_yes, timeout=timeout)
61-
62-
# %% Go live
63-
if assume_yes:
64-
print("going live on", websites)
65-
else:
66-
input(f"Press Enter to go live on {websites}. Or Ctrl C to abort.")
51+
S = Microphone(ini_file, websites, image=still_image, yes=assume_yes, timeout=timeout)
6752

68-
s.stream.startlive()
53+
print(" ".join(S.stream.cmd))
6954

7055

7156
def capture_screen(
@@ -85,10 +70,5 @@ def capture_screen(
8570
def stream_camera(ini_file: Path, websites: str, *, assume_yes: bool, timeout: float):
8671

8772
S = Camera(ini_file, websites, yes=assume_yes, timeout=timeout)
88-
# %% Go live
89-
if assume_yes:
90-
print("going live on", websites)
91-
else:
92-
input(f"Press Enter to go live on {websites}. Or Ctrl C to abort.")
9373

94-
S.stream.startlive()
74+
print(" ".join(S.stream.cmd))

src/pylivestream/fglob.py

-133
This file was deleted.

0 commit comments

Comments
 (0)