diff --git a/README.md b/README.md index 5b3fd15..421d6e7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ This project provides some scripts to download the assets for a recorded presentation, and assemble them into a single video suitable for archive or upload to other video hosting sites. - ## Prerequisites The scripts are written in Python, and rely on the GStreamer Editing @@ -51,7 +50,7 @@ Editing Services project. It takes the following optional parameters to influence the project: -* `--start=SECONDS` and `--end=SECONDS` can be used to trim footage from the start or end of the recording. This can be helpful if the recording was started early, or you want to split the recoridng into multiple projects. +* `--start=TIME` and `--end=TIME` can be used to trim footage from the start or end of the recording. This can be helpful if the recording was started early, or you want to split the recoridng into multiple projects. * `--width=WIDTH` and `--height=HEIGHT` control the dimensions of the video. The default resolution is 1920x1080. * `--webcam-size=PERCENT` controls how much of the frame width will be devoted to the webcam footage. This defaults to 20%. * `--stretch-webcam` stretches the webcam footage by 33%. This was added to correct the camera aspect ratio in some of our recordings. @@ -59,6 +58,12 @@ It takes the following optional parameters to influence the project: * `--opening-credits=FILE[:DURATION]` and `--closing-credits=FILE[:DURATION]` will add credits to project. These can either be videos or still images (which will default to 3 seconds duration). These options can be repeated to add multiple credits. * `--annotations` will include whiteboard annotations and red dot cursor to slides. +Some accepted `TIME` formats: + +* `ss` seconds (example: 1500 or 1500.3) +* `mm:ss` minutes and seconds +* `hh:mm:ss` hours minutes and seconds +* `dd:hh:mm:ss` days, hours, minutes and seconds Currently the project includes the following aspects of the BBB recording: @@ -82,7 +87,6 @@ ges-launch-1.0 --load presentation.xges It can also be loaded in Pitivi if you want to tweak the project before rendering. - ## Render Video If everything looks good, the project can be rendered to a video. The @@ -98,3 +102,11 @@ Or alternatively, it can be rendered as WebM: ges-launch-1.0 --load presentation.xges -o presentation.webm \ --format 'video/webm:video/x-vp8:audio/x-vorbis' ``` + +## License + +Copyright (c) 2020-2021 [James Henstridge](https://github.com/jhenstridge) and contributors + +The project is Free as in freedom software, released under the terms of the MIT License. + +See the LICENSE file. diff --git a/make-xges.py b/make-xges.py index feda92e..977d639 100755 --- a/make-xges.py +++ b/make-xges.py @@ -388,11 +388,52 @@ def save(self): self.timeline.save_to_uri(file_to_uri(self.opts.project), None, True) +def parse_time(value): + """Parse a time interval string into a floating point seconds value. + + Supported formats include: + ss (seconds) + ss.dd (seconds with decimals) + mm:ss (minutes and seconds) + mm:ss.dd (minutes and seconds with decimals) + hh:mm:ss (hours, minutes and seconds) + hh:mm:ss.dd (hours, minutes and seconds with decimals) + dd:hh:mm:ss (days,hours, minutes and seconds) + dd:hh:mm:ss.dd (days,hours, minutes and seconds with decimals) + """ + # allow an empty value + if value == '': + return 0 + + # seconds should be always 0 + # minutes should be always 1 ecc. + parts = value.split(':') + if len(parts) > 4: + raise ValueError('The provided time does not respect the supported formats: SS, MM:SS, HH:MM:SS, DD:HH:MM:SS.') + + parts.reverse() + seconds = float(parts[0]) + + # minutes (mm:ss) + if len(parts) > 1: + seconds += int(parts[1]) * 60 + + # hours (hh:mm:ss) + if len(parts) > 2: + seconds += float(parts[2]) * 3600 + + # days (dd:hh:mm:ss) + if len(parts) > 3: + seconds += float(parts[3]) * 86400 + + return seconds + + def main(argv): parser = argparse.ArgumentParser(description='convert a BigBlueButton presentation into a GES project') - parser.add_argument('--start', metavar='SECONDS', type=float, default=0, - help='Seconds to skip from the start of the recording') - parser.add_argument('--end', metavar='SECONDS', type=float, default=None, + parser.add_argument('--start', metavar='TIME', type=parse_time, default=0, + help='Start point in the recording (seconds, or mm:ss, hh:mm:ss, dd:hh:mm:ss)') + parser.add_argument('--end', metavar='TIME', type=parse_time, default=None, help='End point in the recording') parser.add_argument('--width', metavar='WIDTH', type=int, default=1920, help='Video width')