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

MutedAudio strategy for media without audio track #51

Closed
mudar opened this issue Dec 20, 2019 · 6 comments
Closed

MutedAudio strategy for media without audio track #51

mudar opened this issue Dec 20, 2019 · 6 comments

Comments

@mudar
Copy link
Collaborator

mudar commented Dec 20, 2019

I'm trying to concatenate multiple videos where some would be missing the audio track. Is this a feature you're planning to add to the library?
I tried some code changes, and I was able to concatenate when all files are missing the audio track (result would not have an audio track). I was also able to mute audio if the track was available in the source.
However, I was not able to create the empty buffer manually. Do you have any hints that could guide me to find the right steps. I have looked around, and didn't find any solutions similar to this.

@natario1
Copy link
Member

I'm trying to concatenate multiple videos where some would be missing the audio track. Is this a feature you're planning to add to the library?

I feel like this should work already with the current library. What is the issue that you are having?

@mudar
Copy link
Collaborator Author

mudar commented Jan 7, 2020

I will provide more info here, now that TrimDataSource is completed. For now I need to do some tests with v0.7.4 before sending a PR.
Testing quickly, currently there's a simple bug selecting a null track

com.otaliastudios.transcoder.demo E/Transcoder: Fatal error while transcoding, this might be invalid format or bug in engine or Android.
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.otaliastudios.transcoder.source.DefaultDataSource.selectTrack(DefaultDataSource.java:63)
at com.otaliastudios.transcoder.engine.Engine.openCurrentStep(Engine.java:149)
at com.otaliastudios.transcoder.engine.Engine.getCurrentTrackTranscoder(Engine.java:219)
at com.otaliastudios.transcoder.engine.Engine.transcode(Engine.java:368)
at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:134)
at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:124)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)

Handling the null exception was not enough. For example if file-1 has a single track (video) and file-2 has both tracks, then the concatenation result should have an empty sound track until the timestamp of file-2. What used to happen was a shift of the audio track for file-2 starting at the beginning of file-1.

@TemMax
Copy link

TemMax commented Feb 5, 2020

I faced the same problem. But I tried to transcode one video without audio track.
Version: 0.8.0

@TemMax
Copy link

TemMax commented Feb 5, 2020

I found workaround for this case.
With MediaMetadataRetriever we can extract value METADATA_KEY_HAS_AUDIO and if our video doesn't have audio track we can use TranscoderOptions.Builder#addDataSource with type == TrackType.VIDEO only and don't set AudioStrategy.

@cbernier
Copy link
Contributor

cbernier commented Feb 17, 2020

@TemMax solution works but it is not an option if we try to concatenate 2 videos and one of them has an audio track: we want to keep the first audio track and extend it with a mute sound for the duration of the second video.

@cbernier
Copy link
Contributor

cbernier commented Feb 18, 2020

I submitted a pull request to solve @TemMax workaround: https://github.com/natario1/Transcoder/pull/61

@natario1 The next thing that we would like the library to handle is to optionally fill the missing track sources by a mute sound and maybe even a black image for the missing video sources.

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

No branches or pull requests

4 participants