Skip to content

Commit

Permalink
get_packet_sizes: Set packet size to -1 with negative offsets
Browse files Browse the repository at this point in the history
fix typo oops
  • Loading branch information
LightArrowsEXE committed May 19, 2024
1 parent 0a53ca2 commit 3021e0a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lvsfunc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ def get_packet_sizes(
If a Keyframes object is passed, additional scene-based frame props will be added. These are the min, max, and
average packet sizes of a scene based on these Keyframes.
If a non-zero `offset` is set, the function will trim or duplicate the list of packet sizes to match. This
should be the same value as your trim at the start of the clip. Make sure your Keyframes object also matches
the trimmed clip.
If a non-zero `offset` is set, the function will trim the list of packet sizes to match. Negative values will
instead set the packet sizes for the first `offset` frames to -1. This is intended to be used with trimmed clips.
Dependencies:
Expand All @@ -269,15 +268,16 @@ def get_packet_sizes(
:param filepath: The path to the original file that was indexed.
If None, tries to read the `idx_filepath` property from `clip`.
Will throw an error if it can't find either.
This parameter is ignored if `out_file` is set and a file can be read.
:param out_file: Output file for packet sizes. If set, the results will be written to that file,
and also read from that file in subsequent calls. This saves us from having to
call ffprobe every time you refresh the preview.
:param keyframes: A Keyframes object to identify scene changes. If set, scene-based metrics will
be calculated and added as frame props alongside the `pkt_size` frame prop.
:param offset: Offset to trim or duplicate the list of packet sizes. This is useful when you're
working with a trimmed clip. Should be the same value as your trim at the start
of the clip. Negative values will duplicate the first frame's packet size instead.
Default: 0 frames.
of the clip. Negative values will set the packet sizes for the first `offset`
frames to -1 instead.
:param return_packet_sizes: If set to True, the function will return the packet sizes as a list of integers.
To get the scene-based stats, you will need to pass this list to the
`get_packet_scene_stats` function along with a Keyframes object.
Expand Down Expand Up @@ -306,7 +306,7 @@ def get_packet_sizes(
sout.write_text("\n".join([str(pkt) for pkt in pkt_sizes]), "utf-8", newline="\n")

if offset < 0:
pkt_sizes = [pkt_sizes[0]] * -offset + pkt_sizes
pkt_sizes = [-1] * -offset + pkt_sizes
elif offset > 0:
pkt_sizes = pkt_sizes[offset:]

Expand Down

0 comments on commit 3021e0a

Please sign in to comment.