Skip to content
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

Handle videos with begin_stream_seconds > 0 #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion benchmarks/decoders/benchmark_decoders_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,12 @@ def run_benchmarks(
metadata_label = f"{metadata.codec} {metadata.width}x{metadata.height}, {metadata.duration_seconds}s {metadata.average_fps}fps"

duration = metadata.duration_seconds
uniform_pts_list = [i * duration / num_samples for i in range(num_samples)]
# The epislon of 1e-6 is added to avoid floating point issues. Otherwise I see error messages like:
# RuntimeError: frame pts is 0.015999; must be in range [0.015999, 5.004316).
begin = metadata.begin_stream_seconds + 1e-6
uniform_pts_list = [
i * duration / num_samples + begin for i in range(num_samples)
]
Comment on lines +497 to +502
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: try to rely on torch.arange instead, like we do in the samplers

clip_start_seconds = torch.arange(
. It should start exactly at begin which hopefully wouldn't cause the error we're seeing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought when I was refactoring things, and I can't remember why I didn't do it. :) I'll dig in later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like arange doesn't work here, possibly due to rounding:

        uniform_pts_list = list(
            torch.arange(
                metadata.begin_stream_seconds,
                metadata.end_stream_seconds,
                (metadata.end_stream_seconds - metadata.begin_stream_seconds)
                / num_samples,
            )
        )

Gives me the same error:

RuntimeError: frame pts is 0.015999; must be in range [0.015999, 5.004316).


# Note that we are using the same random pts values for all decoders for the same
# video. However, because we use the duration as part of this calculation, we
Expand Down
Loading