-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example: Add interval edit script #108
base: main
Are you sure you want to change the base?
Conversation
Adds a script that cuts between Flows on a fixed time interval, demonstrating `sample_offset` and `sample_count`. Also updates the `simple_edit` script to set some custom tags on created Flows.
5d5f1d1
to
9de71c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments inline (and a bug found elsewhere) and otherwise LGTM
@@ -61,6 +65,37 @@ async def put_flow( | |||
resp.raise_for_status() | |||
|
|||
|
|||
async def get_segments( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest using the segment generator code but that complicates the use of deque. Also, I note that there is a bug in the function: segment_timerange not in timerange
should be segment_timerange in timerange
and TimeRange.__contains__
has a bug as TimeRange.from_str("[0:0_1:0)") in TimeRange.eternity()
evaluates to False
. I'll take a look at fixing the bug and updating the TAMS example.
next_seg = current_seg["list"][0] | ||
next_seg_tr = TimeRange.from_str(next_seg["timerange"]).normalise(edit_rate.numerator, | ||
edit_rate.denominator) | ||
if next_seg_tr.end <= position_in_flow_timeline: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is this simpler?
if next_seg_tr.end <= position_in_flow_timeline: | |
if next_seg_tr.ends_earlier_than_timerange(position_in_flow_timeline): |
current_seg["list"].popleft() | ||
continue | ||
|
||
next_seg_offset = Timestamp.from_str(next_seg.get("ts_offset", "0:0")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was slightly confused about what each offset was from the name used. Could this one (which is only used once) be called next_seg_ts_offset
and rename the offset
in current_seg
and other_seg
to timeshift
? However, it's a personal choice and so I leave it to you to decide what makes sense.
segment_length_remaining = next_seg_tr.end - position_in_flow_timeline | ||
remaining_time_in_cut = next_switch_at - working_time | ||
|
||
if (remaining_time_in_cut < segment_length_remaining): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be some anomalies when doing this and other comparisons if the media rates are not integers (because of rounding errors in some of the calculations using nanoseconds), but I think on balance it isn't helpful to have those complications in this example script.
Details
Adds a script that cuts between Flows on a fixed time interval, demonstrating
sample_offset
andsample_count
.Also updates the
simple_edit
script to set some custom tags on created Flows.Jira Issue (if relevant)
Jira URL: https://jira.dev.bbc.co.uk/browse/CLOUDFIT-5392
Related PRs
Follows #107 (because you can't test this script without those fixes)
Submitter PR Checks
(tick as appropriate)
Reviewer PR Checks
(tick as appropriate)
Info on PRs
The checks above are guidelines. They don't all have to be ticked, but they should all have been considered.