Skip to content

Commit 09077a8

Browse files
authored
Fix test_write_video_with_audio.. again (#8558)
1 parent 478c670 commit 09077a8

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

test/test_io.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,14 @@ def test_write_video_with_audio(self, device, tmpdir):
260260
f_name = os.path.join(VIDEO_DIR, "R6llTwEh07w.mp4")
261261
video_tensor, audio_tensor, info = io.read_video(f_name, pts_unit="sec")
262262

263-
video_tensor = video_tensor.to(device)
264-
audio_tensor = audio_tensor.to(device)
265-
266263
out_f_name = os.path.join(tmpdir, "testing.mp4")
267264
io.video.write_video(
268265
out_f_name,
269-
video_tensor,
266+
video_tensor.to(device),
270267
round(info["video_fps"]),
271268
video_codec="libx264rgb",
272269
options={"crf": "0"},
273-
audio_array=audio_tensor,
270+
audio_array=audio_tensor.to(device),
274271
audio_fps=info["audio_fps"],
275272
audio_codec="aac",
276273
)

torchvision/datasets/kinetics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .vision import VisionDataset
1717

1818

19-
def _dl_wrap(tarpath: Union[str, Path], videopath: Union[str, Path], line: str) -> None:
19+
def _dl_wrap(tarpath: Union[str, Path], videopath: Union[str, Path], line: str) -> None:
2020
download_and_extract_archive(line, tarpath, videopath)
2121

2222

torchvision/io/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def write_video(
115115
audio_sample_fmt = container.streams.audio[0].format.name
116116

117117
format_dtype = np.dtype(audio_format_dtypes[audio_sample_fmt])
118-
audio_array = torch.as_tensor(audio_array).numpy().astype(format_dtype)
118+
audio_array = torch.as_tensor(audio_array).numpy(force=True).astype(format_dtype)
119119

120120
frame = av.AudioFrame.from_ndarray(audio_array, format=audio_sample_fmt, layout=audio_layout)
121121

0 commit comments

Comments
 (0)