change the dubbing sound of the video while playing a video
See original GitHub issueDescription
Hi I have 1 video (.mp4), 2 audio files (.aac/.mp3) and 3 subtitle files (.vtt).
What do i want ? for example, the default language of the video is English. When I change the sound the video should resume and the sound of the video dubbing should be in French. As in netflix application.
I am trying to do this with the following code.
Format format_audio_en = Format.createAudioSampleFormat("en", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, Format.NO_VALUE, 44100, null, null, C.SELECTION_FLAG_DEFAULT, "en");
Format format_audio_de = Format.createAudioSampleFormat("de", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, Format.NO_VALUE, 44100, null, null, 0, "de");
SingleSampleMediaSource audio_source_de = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse("http://*******/sound_de.aac"), format_audio_de, C.TIME_UNSET);
SingleSampleMediaSource audio_source_en = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse("http://*******/sound_en.aac"), format_audio_en, C.TIME_UNSET);
MediaSource videoSource = buildMediaSource(uri, dataSourceFactory);
MediaSource[] mediaSourceList = new MediaSource[3];
mediaSourceList[0] = videoSource;
mediaSourceList[1] = audio_source_en ;
mediaSourceList[2] = audio_source_de ;
MergingMediaSource mergingMediaSource = new MergingMediaSource(mediaSourceList);
player.setPlayWhenReady(playWhenReady);
player.seekTo(playbackPosition);
player.prepare(mergingMediaSource, false, false);
But when I use it this way, I get an error.
E/ExoPlayerImplInternal: Internal runtime error.
java.lang.IllegalStateException: Buffer too small (524288 < 2241155)
at com.google.android.exoplayer2.decoder.DecoderInputBuffer.createReplacementByteBuffer(DecoderInputBuffer.java:167)
at com.google.android.exoplayer2.decoder.DecoderInputBuffer.ensureSpaceForWrite(DecoderInputBuffer.java:117)
at com.google.android.exoplayer2.source.SingleSampleMediaPeriod$SampleStreamImpl.readData(SingleSampleMediaPeriod.java:334)
at com.google.android.exoplayer2.BaseRenderer.readSource(BaseRenderer.java:308)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1028)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:658)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:575)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:326)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:146)
at android.os.HandlerThread.run(HandlerThread.java:61)
I do this with HLS. Elephants Dream Hls Video have two sound (english and spanish) I can easily change the dubbing sound when I use the following code. However, I have mp4 (video) and mp3 / aac (audio) files.
trackSelector.setParameters(trackSelector.getParameters().buildUpon().setMaxVideoSizeSd()
.setPreferredTextLanguage(subTextLanguage)
.setPreferredAudioLanguage("<en or es>").build());
I looked at these
How can I do what I want using mp4 (video) and mp3 (audio) files?
I hope you can help, thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How To Add Dubbing Voice Over to Videos in 4 Steps
Learn how to add voice over to video, dubbing the audio into another language. Understand localized translation and lip-syncing.
Read more >Replace Your Voice! - How To Make A Dubbing Video
Have you wanted to learn how to making a dubbing video and replace your voice? Today I'll teach you how to replace the...
Read more >How to change voice in a video - YouTube
Get Movavi Video Editor Plus and the Vlogger Essentials effects bundle at 15% off! https://www.movavi.com/buy-videoeditorplusyear ...
Read more >Adding Sound to a Movie: How to Dub Audio Over Video
Open the audio mixer by pressing the "M" key and adjust the volume of all the audio tracks. Be sure to check the...
Read more >Video Voice Dubbing Changer - - Apps on Google Play
Video Voice Dubbing Changer - Audio Video Mixerwith you can now easily replace a video with bad quality sound with your own voice...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Glad you got it working!
thank you so much @ojw28
I got what I wanted.
First of all, I added language information to my audio files with this program. and then I edited the code like this;
for english voice
for turkish voice
the issue can be closed, thanks