[英]Android: Select audio track in video
I've got some .mp4 videos that have multiple audio tracks, each for a specific language. 我有一些.mp4视频,其中包含多个音轨,每个音轨都针对一种特定的语言。
I found this question on stackoverflow but the user didn't post his solution. 我在stackoverflow上发现了这个问题 ,但是用户没有发布他的解决方案。
I was wondering how to select one audio track from the .mp4 video and play it without hearing the other audio tracks at the same time? 我想知道如何从.mp4视频中选择一个音轨并播放而不会同时听到其他音轨?
I have no restraints as if it needs to be a VideoView or an Activity based on an Intent.ACTION_VIEW. 我没有任何限制,好像它需要是基于Intent.ACTION_VIEW的VideoView或Activity。
Use MediaPlayer.selectTrack(TrackIndex);
使用
MediaPlayer.selectTrack(TrackIndex);
to get track index use 获取轨道索引使用
findTrackIndexFor(TrackInfo.MEDIA_TRACK_TYPE_AUDIO, MediaPlayer.getTrackInfo());
private int findTrackIndexFor(int mediaTrackType, TrackInfo[] trackInfo) {
int index = -1;
for (int i = 0; i < trackInfo.length; i++) {
if (trackInfo[i].getTrackType() == mediaTrackType) {
return i;
}
}
return index;
}
can you please post that multi-track video files for me. 您能帮我发布该多轨视频文件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.