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

select first appropriate stream index by default #7

Merged
merged 3 commits into from
Dec 14, 2021

Conversation

agrathwohl
Copy link

@agrathwohl agrathwohl commented Dec 13, 2021

Closes #6

Please test out this new approach to AudioTrack.from. Once we are looking good I will merge & cut a new release.

Note: This is not a breaking change; the original way of AudioTrack.from(source, { streamIndex: 0}) should still work as expected. in order to select the correct streamIndex automatically (without specifying opts.streamIndex), you need to give the results of source.probe as an opts argument in AudioTrack.from(). See the following example:

const src = new Source('http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4')

src.probe((e, probe) => {
  const audioTrack = AudioTrack.from(src, { probe })
  console.log(audioTrack.properties.streamIndex) // 0
})

This particular source video file is unique in that it puts the audio track in index 0, while the video track lives in index 1. This is the opposite of what the standard suggests, so very few videos are authored in this manner. This makes it a good testing grounds. Even though AudioTrack.DEFAULT_STREAM_INDEX == 1, it still chooses the correct index.

@agrathwohl
Copy link
Author

@r-token I updated the issue text to clarify that this is not a breaking change. It's an improvement intended to make it more convenient to select the correct track without having to know its streamIndex first.

@agrathwohl agrathwohl merged commit 215e296 into master Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AudioTrack.from should select first audio track in Source by default
1 participant