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

Commit 63ce3b6

Browse files
committed
specify devices at top of each script for clarity
1 parent 1bbe604 commit 63ce3b6

7 files changed

+58
-15
lines changed

FileGlob2YouTubeLive.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from getpass import getpass
1010
from youtubelive_ffmpeg import youtubelive
1111

12+
1213
def playonce(flist:list, P:dict):
1314

1415
for f in flist:

FileLoop2YouTubeLive.py

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
p = p.parse_args()
1818

1919
P = {'filein': p.filein,
20-
'fps':30, # TODO auto-determine input FPS
21-
'audiochan': 'default',
2220
'vidsource': 'file',
2321
'loop':True,
2422
}

README.rst

+14-7
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,33 @@ From PyPi::
4040
Or for the latest copy from Github::
4141

4242
python -m pip install -e .
43-
44-
43+
44+
4545
Usage
4646
=====
4747
In all cases, you must first `configure YouTube Live <https://www.youtube.com/live_dashboard>`_.
4848
Then your chosen input will stream live on YouTube Live.
4949

50+
In the non-file streaming scripts, you can specify your video/audio device if desired at the top of the script.
51+
You can find device names with commands like:
52+
53+
* Windows: ``ffmpeg -list_devices true -f dshow -i dummy``
54+
* Mac: ``ffmpeg -f avfoundation -list_devices true -i ""``
55+
* Linux: ``v4l2-ctl --list-devices``
56+
5057
Webcam
5158
------
5259
Audio is included::
5360

5461
python Webcam2YouTubeLive.py
55-
56-
62+
63+
5764
Screen Share
5865
------------
5966
Audio is included::
6067

6168
python Screenshare2YouTubeLive.py
62-
69+
6370
-fps set frames/second
6471
-res set resolution XxY of your screen
6572
-o set origin (upper left)
@@ -70,7 +77,7 @@ Several video files
7077
Glob list of video files to stream::
7178

7279
python FileGlob2YouTubeLive.py path pattern
73-
80+
7481
-loop optionally loop endlessly the globbed file list
7582

7683

@@ -92,7 +99,7 @@ Several audio files
9299
Glob list of video files to stream. Note you must include a static image (could be your logo)::
93100

94101
python FileGlob2YouTubeLive.py path pattern -i image
95-
102+
96103
path path to where video files are
97104
pattern e.g. "*.avi" pattern matching video files
98105
-i filename of image to use as stream background

ScreenCapture2disk.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@
55
https://www.scivision.co/youtube-ffmpeg-screen-capture-with-audio/
66
https://trac.ffmpeg.org/wiki/Capture/Desktop
77
https://support.google.com/youtube/answer/2853702
8+
9+
Windows: get DirectShow device list from:
10+
ffmpeg -list_devices true -f dshow -i dummy
811
"""
912
from youtubelive_ffmpeg import disksave4youtube
13+
import sys
14+
#
15+
if sys.platform.startswith('win'):
16+
audiochan = 'audio="Internal Microphone"'
17+
videochan = 'video="UScreenCapture"'
18+
elif sys.platform.startswith('darwin'):
19+
audiochan = 'default'
20+
videochan = 'default'
21+
elif sys.platform.startswith('linux'):
22+
audiochan = 'default'
23+
videochan = '/dev/video0'
1024

1125
if __name__ == '__main__':
1226
import signal
@@ -24,7 +38,8 @@
2438
P = {'fps': p.fps,
2539
'res': p.res,
2640
'origin':p.origin,
27-
'audiochan': 'default',
41+
'videochan': videochan,
42+
'audiochan': audiochan,
2843
'vidsource': 'screen',
2944
}
3045

Screenshare2YouTubeLive.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,23 @@
44
55
https://www.scivision.co/youtube-live-ffmpeg-livestream/
66
https://support.google.com/youtube/answer/2853702
7+
8+
Windows: get DirectShow device list from:
9+
ffmpeg -list_devices true -f dshow -i dummy
710
"""
811
from youtubelive_ffmpeg import youtubelive
12+
import sys
13+
#
14+
if sys.platform.startswith('win'):
15+
audiochan = 'audio="Internal Microphone"'
16+
videochan = 'video="UScreenCapture"'
17+
elif sys.platform.startswith('darwin'):
18+
audiochan = 'default'
19+
videochan = 'default'
20+
elif sys.platform.startswith('linux'):
21+
audiochan = 'default'
22+
videochan = '/dev/video0'
23+
924

1025
if __name__ == '__main__':
1126
import signal
@@ -22,7 +37,8 @@
2237
P = {'fps': p.fps,
2338
'res': p.res,
2439
'origin':p.origin,
25-
'audiochan': 'default',
40+
'videochan': videochan,
41+
'audiochan': audiochan,
2642
'vidsource': 'screen',
2743
}
2844

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(name='YouTubeLiveFFmpeg',
66
packages=find_packages(),
7-
version = '1.0.2',
7+
version = '1.0.3',
88
author='Michael Hirsch, Ph.D.',
99
url='https://github.com/scivision/ffmpeg-youtube-live',
1010
description='Easy streaming using FFmpeg to YouTube Live.',

youtubelive_ffmpeg/__init__.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
sp.check_call(('avconv','-h'), stdout=sp.DEVNULL, stderr=sp.DEVNULL)
1313
FFMPEG = 'avconv'
1414
except FileNotFoundError:
15-
raise FileNotFoundError('FFmpeg is not installed for your system.')
15+
raise FileNotFoundError('FFmpeg program is not found. Is ffmpeg on your PATH?')
1616
# %% https://trac.ffmpeg.org/wiki/Capture/Desktop
1717
if platform.startswith('linux'):
1818
if 'XDG_SESSION_TYPE' in os.environ and os.environ['XDG_SESSION_TYPE'] == 'wayland':
@@ -119,8 +119,14 @@ def _screengrab(P:dict) -> list:
119119
"""choose to grab video from desktop. May not work for Wayland."""
120120
vid1 = ['-f', vcap,
121121
'-r',str(P['fps']),
122-
'-s',P['res'],
123-
'-i',f':0.0+{P["origin"][0]},{P["origin"][1]}']
122+
'-s',P['res']]
123+
124+
if platform.startswith('linux'):
125+
vid1 += ['-i',f':0.0+{P["origin"][0]},{P["origin"][1]}']
126+
elif platform.startswith('win'):
127+
vid1 += ['-i',P['videochan']]
128+
elif platform.startswith('darwin'):
129+
pass # FIXME: verify
124130

125131
return vid1
126132

0 commit comments

Comments
 (0)