Skip to content

Commit 316f218

Browse files
committed
Merge branch 'main' of github.com:pytorch/torchcodec into aeaenjfjanef
2 parents b45decc + c66da14 commit 316f218

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

benchmarks/decoders/benchmark_decoders.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import argparse
88
import importlib.resources
9+
import json
910
import os
1011
import platform
1112
from pathlib import Path
@@ -106,6 +107,12 @@ def main() -> None:
106107
default=False,
107108
action=argparse.BooleanOptionalAction,
108109
)
110+
parser.add_argument(
111+
"--output-json",
112+
help="Output the results to a JSON file",
113+
type=str,
114+
default="",
115+
)
109116

110117
args = parser.parse_args()
111118
specified_decoders = set(args.decoders.split(","))
@@ -146,6 +153,10 @@ def main() -> None:
146153
min_runtime_seconds=args.min_run_seconds,
147154
benchmark_video_creation=args.bm_video_creation,
148155
)
156+
if args.output_json:
157+
with open(args.output_json, "w") as f:
158+
json.dump(results, f, indent=2)
159+
149160
data = {
150161
"experiments": results,
151162
"system_metadata": {

src/torchcodec/_core/Encoder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,6 @@ VideoEncoder::VideoEncoder(
574574
fileName,
575575
", make sure it's a valid path? ",
576576
getFFMPEGErrorStringFromErrorCode(status));
577-
// TODO-VideoEncoder: Add tests for above fileName related checks
578-
579577
initializeEncoder(videoStreamOptions);
580578
}
581579

test/test_ops.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,26 @@ def test_bad_input(self, tmp_path):
12681268
filename=output_file,
12691269
)
12701270

1271+
with pytest.raises(
1272+
RuntimeError,
1273+
match=r"Couldn't allocate AVFormatContext. The destination file is ./file.bad_extension, check the desired extension\?",
1274+
):
1275+
encode_video_to_file(
1276+
frames=torch.randint(high=255, size=(10, 3, 60, 60), dtype=torch.uint8),
1277+
frame_rate=10,
1278+
filename="./file.bad_extension",
1279+
)
1280+
1281+
with pytest.raises(
1282+
RuntimeError,
1283+
match=r"avio_open failed. The destination file is ./bad/path.mp3, make sure it's a valid path\?",
1284+
):
1285+
encode_video_to_file(
1286+
frames=torch.randint(high=255, size=(10, 3, 60, 60), dtype=torch.uint8),
1287+
frame_rate=10,
1288+
filename="./bad/path.mp3",
1289+
)
1290+
12711291
def decode(self, file_path) -> torch.Tensor:
12721292
decoder = create_from_file(str(file_path), seek_mode="approximate")
12731293
add_video_stream(decoder)

0 commit comments

Comments
 (0)