-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
43 lines (39 loc) · 1.89 KB
/
main.py
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
import os
import sys
import urllib3
import xml.etree.ElementTree as ET
http = urllib3.PoolManager()
if len(sys.argv) > 1:
# TODO: check if begins with http etc
url_parts = sys.argv[1].split('/')
base_url = '/'.join(url_parts[0:3])
# check BBB version
if "/2.0/" in sys.argv[1]:
bbb_id = url_parts[len(url_parts) - 1].split('=')[1]
elif "/2.3/" in sys.argv[1]:
bbb_id = url_parts[len(url_parts) - 1]
else:
print("WARNING unsupported version")
exit(1)
shapes_url = base_url + "/presentation/" + bbb_id + "/shapes.svg"
r = http.request('GET', shapes_url)
if r.status == 404:
print("WARNING 404")
exit(2)
shapes = r.data.decode('utf-8')
shapes_xml_root = ET.fromstring(shapes)
print("wget " + base_url + "/presentation/" + bbb_id + "/video/webcams.webm")
print("ffmpeg -i webcams.webm -vn -c:a copy audio.ogg") # read webcams write no video use same audio codec
with open(os.getcwd() + '/parts.txt', 'w') as f:
for child in shapes_xml_root:
if 'image' in child.tag: # this ignores polls, drawn elements etc
start_str = child.attrib["in"].split(".")[0]
end_str = child.attrib["out"].split(".")[0]
print("wget " + base_url + "/presentation/" + bbb_id + "/" + child.attrib['{http://www.w3.org/1999/xlink}href'] + " -O " + child.attrib["id"] + ".png")
print("ffmpeg -loop 1 -i " + child.attrib["id"] + ".png -c:v libx264 -t " + str(int(end_str) - int(start_str)) + " -pix_fmt yuv420p -r 15.000150 " + child.attrib[
"id"] + ".mp4") # read image write using H264 use duration from shapes file, use frame rate from webcam file
f.writelines(["file '" + child.attrib["id"] + ".mp4'\n"])
print("ffmpeg -f concat -safe 0 -i " + os.getcwd() + "/parts.txt -c copy slides.mp4") # read list from file, use same codecs
print("ffmpeg -i slides.mp4 -i audio.ogg -c copy final.mp4") # read video-only and audio-only, output using same codec
else:
print("No argument supplied, call with BBB URL")