Skip to content

Commit

Permalink
Merge pull request plugorgau#15 from valerio-bozzolan/master
Browse files Browse the repository at this point in the history
add support to --start and --end time formats like mm:ss or hh:mm:ss or dd:hh:mm:ss
  • Loading branch information
jhenstridge authored Jun 9, 2021
2 parents a3c1051 + 339ce2c commit e137d9d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,14 +50,20 @@ 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.
* `--backdrop=FILE` sets a still image to place behind other elements. This can be used to fill in the empty space in the frame.
* `--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:
Expand All @@ -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
Expand All @@ -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.
47 changes: 44 additions & 3 deletions make-xges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit e137d9d

Please sign in to comment.