-
Notifications
You must be signed in to change notification settings - Fork 171
Feature/muted audio fixes #51 #64
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
Conversation
Provides a silent audio track of the a specific duration. This class can be used to concatenate a DataSources that has a video track only with another that has both video and audio track.
Using addDataSource(dataSource) adds a muted audio track when necessary. This can be skipped by calling addDataSource(AUDIO, dataSource) and addDataSource(VIDEO, dataSource).
Thanks @mudar this is great! :-) I'll take a look at the source soon. The idea of adding it automatically to the Builder seems very good to me. Let's do this under the hood |
If you could just find a way to enable this only when needed that'd be great. Maybe at build() time? I mean now if I pass a single file that is video only, I expect the output to be video only, so we shouldn't add muted audio in this case. |
Fix the usage of the MutedAudioDataSource in the TranscoderOptions bu…
fixed, with the help of @cbernier2 :) |
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
applied PR suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small changes, thanks!
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
lib/src/main/java/com/otaliastudios/transcoder/source/MutedAudioDataSource.java
Outdated
Show resolved
Hide resolved
and removed unncessary check in canReadTrack()
ba7933e
to
573df81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks guys this is great. Great reference for a BlankVideo source as well, that seems quite easy now.
This source could be improved in readTrack(), because the last read will always give more data than it should (that is, durationUs is not an exact multiple of the period time). But we can address this later.
Hi Mattia,
This PR solves the problem I was facing when concatenating two dataSources where one would have audio+video tracks and the other would have a video track only (no audio track).
The new
MutedAudioDataSource
provides a silent sound track, which allows the concatenation to go on correctly.How would you prefer to do the check that triggers the use of this new DataSource? Initially I thought it could be an AudioStrategy, or a builder option. For now (wip), I've added it in
Builder.addDataSource(dataSource)
by default, and it can be skipped by usingBuilder.addDataSource(track, dataSource)
.I did many tests with the audio format values (bufferSize, periodSize, periodTime) and these values are the ones that worked for me 💯
thanks :)