Skip to content

Commit

Permalink
[torchcodec] Fix bug where we were not finding the best audio stream (#…
Browse files Browse the repository at this point in the history
…64)

Summary:
Pull Request resolved: #64

Previous we were using the best video stream for the best audio stream. This diff fixes that and updates the tests.

Reviewed By: NicolasHug

Differential Revision: D59460206

fbshipit-source-id: ac228029f25f7e525f0f1fdd1f25f3d1d0be9f34
  • Loading branch information
ahmadsharif1 authored and facebook-github-bot committed Jul 8, 2024
1 parent a0bb7d8 commit 85d8b79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/torchcodec/decoders/_core/VideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void VideoDecoder::initializeDecoder() {
if (bestVideoStream >= 0) {
containerMetadata_.bestVideoStreamIndex = bestVideoStream;
}
int bestAudioStream = getBestStreamIndex(AVMEDIA_TYPE_VIDEO);
int bestAudioStream = getBestStreamIndex(AVMEDIA_TYPE_AUDIO);
if (bestAudioStream >= 0) {
containerMetadata_.bestAudioStreamIndex = bestAudioStream;
}
Expand Down
2 changes: 1 addition & 1 deletion test/decoders/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_get_video_metadata():
metadata = get_video_metadata(decoder)
assert len(metadata.streams) == 6
assert metadata.best_video_stream_index == 3
assert metadata.best_audio_stream_index == 3
assert metadata.best_audio_stream_index == 4

with pytest.raises(NotImplementedError, match="TODO: decide on logic"):
metadata.duration_seconds
Expand Down

0 comments on commit 85d8b79

Please sign in to comment.