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

Missing audio after calling read_video() with sec as unit #3779

Closed
prabhat00155 opened this issue May 5, 2021 · 0 comments · Fixed by #4064
Closed

Missing audio after calling read_video() with sec as unit #3779

prabhat00155 opened this issue May 5, 2021 · 0 comments · Fixed by #4064
Assignees

Comments

@prabhat00155
Copy link
Contributor

prabhat00155 commented May 5, 2021

🐛 Bug

Calling read_video() on a video file returns audio tensor with shape[1] as 0, when start_pts and end_pts is passed with sec as unit.

To Reproduce

With pts as unit:

visual, audio, info = read_video(video_path, start_pts=10010, end_pts=15015, pts_unit='pts')
print('Visual:', visual.shape, 'Audio:', audio.shape, info)
write_video(
    'foo.mp4', video_array=visual, fps=info['video_fps'], audio_array=audio, audio_fps=info['audio_fps'],
    audio_codec='aac')

Output:

Visual: torch.Size([6, 256, 340, 3]) Audio: torch.Size([1, 5192]) {'video_fps': 29.97002997002997, 'audio_fps': 48000}

With sec as unit:

visual, audio, info = read_video(video_path, start_pts=0.3337, end_pts=0.5005, pts_unit='sec')
print('Visual:', visual.shape, 'Audio:', audio.shape, info)
write_video(
    'bar.mp4', video_array=visual, fps=info['video_fps'], audio_array=audio, audio_fps=info['audio_fps'],
    audio_codec='aac')

Output:

Visual: torch.Size([6, 256, 340, 3]) Audio: torch.Size([1, 0]) {'video_fps': 29.97002997002997, 'audio_fps': 48000}

Expected behavior

Similar audio output as returned with pts unit.

Environment

PyTorch version: 1.9.0.dev20210429
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 11.3 (x86_64)
GCC version: Could not collect
Clang version: 12.0.5 (clang-1205.0.22.9)
CMake version: version 3.19.6

Python version: 3.9 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.20.2
[pip3] torch==1.9.0.dev20210429
[pip3] torchvision==0.10.0a0+730c5e1
[conda] Could not collect

Additional context

cc @bjuncek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant