Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
run: |
python -m pip install pre-commit
- name: Run pre-commit checks
# Continue on error to display the formatting diff in case lint fails.
continue-on-error: true
Comment on lines -39 to -40
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what prevented the CI to be red when the pre-commit job failed.

We'll have to find a better way to display the formatting diff.

run: |
pre-commit run --all-files
- name: Check to see what files pre-commit modified
Expand Down
12 changes: 5 additions & 7 deletions benchmarks/decoders/benchmark_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
plot_data,
run_benchmarks,
TorchAudioDecoder,
TorchCodecCoreCompiled,
TorchCodecCoreBatch,
TorchCodecCore,
TorchCodecCoreBatch,
TorchCodecCoreCompiled,
TorchCodecPublic,
TorchVision,
)
Expand Down Expand Up @@ -120,8 +120,8 @@ def main() -> None:
continue
k, v = item.split("=")
kwargs_dict[k] = v
decoder_dict["TorchCodecCoreBatch" + options] = (
TorchCodecCoreBatch(**kwargs_dict)
decoder_dict["TorchCodecCoreBatch" + options] = TorchCodecCoreBatch(
**kwargs_dict
)
elif decoder.startswith("tcoptions:"):
options = decoder[len("tcoptions:") :]
Expand All @@ -131,9 +131,7 @@ def main() -> None:
continue
k, v = item.split("=")
kwargs_dict[k] = v
decoder_dict["TorchCodecCore:" + options] = (
TorchCodecCore(**kwargs_dict)
)
decoder_dict["TorchCodecCore:" + options] = TorchCodecCore(**kwargs_dict)
video_paths = args.bm_video_paths.split(",")
if args.bm_video_dir:
video_paths = []
Expand Down
17 changes: 12 additions & 5 deletions benchmarks/decoders/benchmark_decoders_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,12 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
)
return frames


class TorchCodecPublic(AbstractDecoder):
def __init__(self, num_ffmpeg_threads=None):
self._num_ffmpeg_threads = int(num_ffmpeg_threads) if num_ffmpeg_threads else None
self._num_ffmpeg_threads = (
int(num_ffmpeg_threads) if num_ffmpeg_threads else None
)

def get_frames_from_video(self, video_file, pts_list):
decoder = VideoDecoder(video_file, num_ffmpeg_threads=self._num_ffmpeg_threads)
Expand All @@ -246,6 +249,7 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
break
return frames


@torch.compile(fullgraph=True, backend="eager")
def compiled_seek_and_next(decoder, pts):
seek_to_pts(decoder, pts)
Expand Down Expand Up @@ -468,9 +472,11 @@ def plot_data(df_data, plot_path):
plot_path,
)


def get_metadata(video_file_path: str) -> VideoStreamMetadata:
return VideoDecoder(video_file_path).metadata


def run_benchmarks(
decoder_dict: dict[str, AbstractDecoder],
video_files_paths: list[str],
Expand All @@ -492,9 +498,7 @@ 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)
]
uniform_pts_list = [i * duration / num_samples for i in range(num_samples)]

# 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 All @@ -504,7 +508,10 @@ def run_benchmarks(
for decoder_name, decoder in decoder_dict.items():
print(f"video={video_file_path}, decoder={decoder_name}")

for kind, pts_list in [("uniform", uniform_pts_list), ("random", random_pts_list)]:
for kind, pts_list in [
("uniform", uniform_pts_list),
("random", random_pts_list),
]:
if verbose:
print(
f"video={video_file_path}, decoder={decoder_name}, pts_list={pts_list}"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/decoders/benchmark_readme_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@
"python_version": "3.11.10",
"system": "Linux"
}
]
]
8 changes: 2 additions & 6 deletions benchmarks/decoders/generate_readme_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ def main() -> None:

decoder_dict = {}
decoder_dict["TorchCodec"] = TorchCodecPublic()
decoder_dict["TorchCodec[num_threads=1]"] = TorchCodecPublic(
num_ffmpeg_threads=1
)
decoder_dict["TorchVision[backend=video_reader]"] = TorchVision(
"video_reader"
)
decoder_dict["TorchCodec[num_threads=1]"] = TorchCodecPublic(num_ffmpeg_threads=1)
decoder_dict["TorchVision[backend=video_reader]"] = TorchVision("video_reader")
decoder_dict["TorchAudio"] = TorchAudioDecoder()

# These are the number of uniform seeks we do in the seek+decode benchmark.
Expand Down
Loading