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

Tracks mapping error #541

Closed
1 task
alesido opened this issue Dec 14, 2017 · 9 comments
Closed
1 task

Tracks mapping error #541

alesido opened this issue Dec 14, 2017 · 9 comments
Labels

Comments

@alesido
Copy link

alesido commented Dec 14, 2017

  • I have verified there are no duplicate active or recent bugs, questions, or requests
Include the following:
  • ExoMedia version: 4.1.0
  • Device OS version: ANY
  • Device Manufacturer: ANY
  • Device Name: ANY
Reproduction Steps

Call method com.devbrackets.android.exomedia.ui.widget.VideoView#getAvailableTracks().get(ExoMedia.RendererType.AUDIO)

Expected Result

List of AUDIO groups.

Actual Result

List of VIDEO groups like shown from the debugger output:

audioTracks = {TrackGroupArray@7470}
hashCode = 0
length = 1
trackGroups = {TrackGroup[1]@7471}
0 = {TrackGroup@7473}
formats = {Format[2]@7474}
0 = {Format@7476} "Format(0, null, video/avc, 1347080, null, [720, 396, -1.0], [-1, -1])"
1 = {Format@7477} "Format(1, null, video/avc, 2481150, null, [720, 396, -1.0], [-1, -1])"
hashCode = 0
length = 2
shadow$klass = {Class@5088} "class com.google.android.exoplayer2.source.TrackGroup"
shadow$monitor = -2078921867
shadow$klass = {Class@4650} "class com.google.android.exoplayer2.source.TrackGroupArray"
shadow$monitor = -2133677826

Solution:

Change line 270 @ com.devbrackets.android.exomedia.core.exoplayer.ExoMediaPlayer#getAvailableTracks():

        int exoPlayerTrackIndex = getExoPlayerTrackType(type);

to line:

        int exoPlayerTrackIndex = getExoPlayerTrackType(type) - 1;
@brianwernick
Copy link
Owner

This will be fixed in the next release (not sure if that will be a 4.1.1 or 4.2.0)

@httpdispatch
Copy link
Contributor

Faced the same issue. Got the test5.mkv from here https://www.matroska.org/downloads/test_w1.html
The code

VideoView videoView = new VideoView(mContext);
videoView.setOnPreparedListener(() -> {
    for (Map.Entry<ExoMedia.RendererType, TrackGroupArray> entry : videoView.getAvailableTracks().entrySet()) {
        Timber.d("onPrepared: rendererType: %s", entry.getKey());
        TrackGroupArray array = entry.getValue();
        for (int i = 0; i < array.length; i++) {
            TrackGroup group = array.get(i);
            for (int j = 0; j < group.length; j++) {
                Timber.d("Format: %s", group.getFormat(j));
            }
        }
    }
});
videoView.setVideoURI(uri);

prints

onPrepared: rendererType: CLOSED_CAPTION
Format: Format(1, null, video/avc, -1, null, [1024, 576, -1.0], [-1, -1])
onPrepared: rendererType: AUDIO
Format: Format(2, null, audio/mp4a-latm, -1, und, [-1, -1, -1.0], [2, 48000])
    Format: Format(10, null, audio/mp4a-latm, -1, eng, [-1, -1, -1.0], [1, 22050])
onPrepared: rendererType: VIDEO
    onPrepared: rendererType: METADATA
Format: Format(3, null, application/x-subrip, -1, eng, [-1, -1, -1.0], [-1, -1])
Format: Format(4, null, application/x-subrip, -1, hun, [-1, -1, -1.0], [-1, -1])
    Format: Format(5, null, application/x-subrip, -1, ger, [-1, -1, -1.0], [-1, -1])
    Format: Format(6, null, application/x-subrip, -1, fre, [-1, -1, -1.0], [-1, -1])
    Format: Format(8, null, application/x-subrip, -1, spa, [-1, -1, -1.0], [-1, -1])
    Format: Format(9, null, application/x-subrip, -1, ita, [-1, -1, -1.0], [-1, -1])
Format: Format(11, null, application/x-subrip, -1, jpn, [-1, -1, -1.0], [-1, -1])
    Format: Format(7, null, application/x-subrip, -1, und, [-1, -1, -1.0], [-1, -1])

When the exoplayer returns correct information for the same file

player.addListener(new Player.DefaultEventListener() {
	@Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
		super.onTracksChanged(trackGroups, trackSelections);
		MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
		if (mappedTrackInfo != null) {
			for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) {
				TrackGroupArray array = mappedTrackInfo.getTrackGroups(rendererIndex);
				Timber.d("onPrepared: rendererType: %s", mappedTrackInfo.getRendererType(rendererIndex));
				for (int i = 0; i < array.length; i++) {
					TrackGroup group = array.get(i);
					for (int j = 0; j < group.length; j++) {
						Timber.d("Format: %s", group.getFormat(j));
					}
				}
			}
		}
	}
});
onPrepared: rendererType: 2
Format: Format(1, null, video/avc, -1, null, [1024, 576, -1.0], [-1, -1])
onPrepared: rendererType: 1
onPrepared: rendererType: 1
Format: Format(2, null, audio/mp4a-latm, -1, und, [-1, -1, -1.0], [2, 48000])
    Format: Format(10, null, audio/mp4a-latm, -1, eng, [-1, -1, -1.0], [1, 22050])
onPrepared: rendererType: 3
Format: Format(3, null, application/x-subrip, -1, eng, [-1, -1, -1.0], [-1, -1])
Format: Format(4, null, application/x-subrip, -1, hun, [-1, -1, -1.0], [-1, -1])
    Format: Format(5, null, application/x-subrip, -1, ger, [-1, -1, -1.0], [-1, -1])
Format: Format(6, null, application/x-subrip, -1, fre, [-1, -1, -1.0], [-1, -1])
    Format: Format(8, null, application/x-subrip, -1, spa, [-1, -1, -1.0], [-1, -1])
    Format: Format(9, null, application/x-subrip, -1, ita, [-1, -1, -1.0], [-1, -1])
Format: Format(11, null, application/x-subrip, -1, jpn, [-1, -1, -1.0], [-1, -1])
    Format: Format(7, null, application/x-subrip, -1, und, [-1, -1, -1.0], [-1, -1])
onPrepared: rendererType: 4

@httpdispatch
Copy link
Contributor

Looks like problem is in this code, line 677. The ordinal starts from 0, while the ExoPlayer constants start from 1

protected int getExoPlayerTrackIndex(@NonNull RendererType type) {
switch (type) {
case AUDIO:
case VIDEO:
case CLOSED_CAPTION:
case METADATA:
return type.ordinal();
}
return C.INDEX_UNSET;
}

https://github.com/google/ExoPlayer/blob/f7ed789fc3841b2536f5629c6bb10f4cb4ee5130/library/core/src/main/java/com/google/android/exoplayer2/C.java#L512-L527

httpdispatch added a commit to httpdispatch/ExoMedia that referenced this issue Sep 17, 2018
@brianwernick
Copy link
Owner

@httpdispatch Have you verified that this is with the most recent version of ExoMedia as this was fixed in January?

@httpdispatch
Copy link
Contributor

@brianwernick in the master branch issue with the wrong mapping is still present. See #652

@httpdispatch
Copy link
Contributor

@brianwernick looks like i have some caching issues. Sorry, this issue is not valid

@httpdispatch
Copy link
Contributor

@brianwernick rechecked, issue is still there. Looks like you have 2 methdos getExoPlayerTrackIndex and getExoPlayerTrackType but use the one with the caclulation bug everywhere

httpdispatch added a commit to httpdispatch/ExoMedia that referenced this issue Sep 19, 2018
…with the getExoPlayerTrackType everywhere such as it contains bug in index calculation
httpdispatch added a commit to httpdispatch/ExoMedia that referenced this issue Sep 19, 2018
…edia renderer type such as it is not a constant value
@httpdispatch
Copy link
Contributor

@brianwernick the mentioned test5.mkv file has 2 audio track groups (one is empty) which makes exo player track index calculation code to produce invalid indexes. That is why i had subtitles inside metadata render type. I've created #653 to overcome this issue

@brianwernick
Copy link
Owner

Ah, Thanks. I'll look at it in a bit

brianwernick pushed a commit that referenced this issue Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants