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

Super basic audio decoding POC #488

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NicolasHug
Copy link
Member

This is a very basic audio decoding POC.

Its purpose is to gauge how much of the codebase we would need to change in order to support audio decoding, and where.

This PR currently breaks all video decoding, and only partially works: I successfully get some audio that I can listen to, but something wrong with it (it's noisy and probably not sampled at the correct rate).

import torch
from torchcodec.decoders import VideoDecoder

decoder = VideoDecoder("./test/resources/nasa_13013.mp4", stream_index=1)
print(decoder.metadata)

audio_samples = torch.cat([frame.data for frame in decoder], dim=1)
print(audio_samples.shape)

import soundfile as sf
print(sf.available_formats())
np_samples = audio_samples.numpy().T

sf.write("out.mp3", np_samples, samplerate=8000)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants