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

not able to override audio tracks for each media inside concatenating media source!! #4698

Closed
robindanielk opened this issue Aug 21, 2018 · 5 comments
Assignees
Labels

Comments

@robindanielk
Copy link

robindanielk commented Aug 21, 2018

Hi , i am trying to set different audio tracks for each media source inside concatenating media source .
Media source contain four audio tracks.
I have tried this on 2 cases:
As per the docs ->

 private PlayerEventListener(ExoPlayer mExoPlayer, DefaultTrackSelector trackSelector,
                                VideoResponse videoResponse, LinearLayout rootLayout, TextView nowPlaying,
                                Activity activity, boolean isAdd, CountdownView countdownView,long totalAddDuration) {
        this.mExoPlayer = mExoPlayer;
        this.trackSelector = trackSelector;
        videoFiles = videoResponse.getFiles();
     }

 @Override
    public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
         Log.d(TAG, "++=================onTracksChanged=======================++ ");
        trackSelector.setParameters(trackSelector.buildUponParameters()
                .setPreferredAudioLanguage("tam"));
}

As per the demo ->

 @Override
    public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
   MappingTrackSelector.MappedTrackInfo trackInfo = trackSelector.getCurrentMappedTrackInfo();
   TrackGroupArray audioTrackGroups = trackInfo.getTrackGroups(C.TRACK_TYPE_AUDIO);
    DefaultTrackSelector.SelectionOverride selectionOverride =  new 
                                 MappingTrackSelector.SelectionOverride(1, 0);
   DefaultTrackSelector.ParametersBuilder parametersBuilder = trackSelector.buildUponParameters();
   parametersBuilder.
                  setSelectionOverride(C.TRACK_TYPE_AUDIO,audioTrackGroups,selectionOverride);
   trackSelector.setParameters(parametersBuilder);
}

the trackInfo.getTrackGroups(C.TRACK_TYPE_AUDIO) is not getting all the audio track group..
Both the cases are not working for switching the audio tracks..Kindly help!

@ojw28
Copy link
Contributor

ojw28 commented Aug 21, 2018

Please can you provide reproduction steps, including sample media and details of exactly which of the tracks you're trying to select. The above information isn't sufficient to allow us to recreate what you're doing, or fully understand your problem.

@ojw28 ojw28 self-assigned this Aug 21, 2018
@robindanielk
Copy link
Author

robindanielk commented Aug 21, 2018

@ojw28 Hi...since the sample media is available only locally i ll try to explain.

  • I have created a concatenatingMediaSource.
  • In one of the media sources inside concatenating media source, I want to change the audio track.
  • The specific media source contains [(1)Video and (4)audio tracks (1)SubRip]
  • So i am using OnTrackChangeListener event of the PlayerListener like both the below cases when next media sources are played,

From the Demo App

@Override
   public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
  MappingTrackSelector.MappedTrackInfo trackInfo = trackSelector.getCurrentMappedTrackInfo();
  
> TrackGroupArray audioTrackGroups = trackInfo.getTrackGroups(C.TRACK_TYPE_AUDIO);

   DefaultTrackSelector.SelectionOverride selectionOverride =  new 
                                MappingTrackSelector.SelectionOverride(1, 0);
  DefaultTrackSelector.ParametersBuilder parametersBuilder = trackSelector.buildUponParameters();
  parametersBuilder.
                 setSelectionOverride(C.TRACK_TYPE_AUDIO,audioTrackGroups,selectionOverride);
  trackSelector.setParameters(parametersBuilder);
}

and,

From Documentation

 @Override
    public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
         Log.d(TAG, "++=================onTracksChanged=======================++ ");
        trackSelector.setParameters(trackSelector.buildUponParameters()
                .setPreferredAudioLanguage("tam"));
}
  • I pass the defaultTrackSelector to playerEventListener like below,
private PlayerEventListener(ExoPlayer mExoPlayer, DefaultTrackSelector trackSelector,
                               VideoResponse videoResponse, LinearLayout rootLayout, TextView nowPlaying,
                               Activity activity, boolean isAdd, CountdownView countdownView,long totalAddDuration) {
       this.mExoPlayer = mExoPlayer;
       this.trackSelector = trackSelector;
       videoFiles = videoResponse.getFiles();
    }
  • Problem is i am not able to override any of the audio tracks by the above methods.
  • In Exoplayer Demo Application , audio tracks of the sample media could be changed!
  • I noted that the all the audio tracks are not being retrieved from the below line
    TrackGroupArray audioTrackGroups = trackInfo.getTrackGroups(C.TRACK_TYPE_AUDIO); ,

In DemoApplication , audioTrackGroups shows 4 tracks
In MyApplication , audioTrackGroups shows only 1 track and that too it is a video track.
So I am not able to override the correct audio...I hope i have explained correctly..Kindly help !!

##Edit:
Media Info of the sample media!
issueGit.txt

From the sample media source EventLogger

 Renderer:1 [
08-22 11:26:01.363 21217-21217/com.example.ridsys_001.AsterTest D/EventLogger:     Group:0, adaptive_supported=N/A [
          [X] Track:0, id=1, mimeType=video/avc, res=1280x532, supported=YES
        ]
      ]
      Renderer:2 [
        Group:0, adaptive_supported=N/A [
          [X] Track:0, id=5, mimeType=audio/mp4a-latm, channels=2, sample_rate=24000, language=eng, supported=YES
        ]
      ]
      Renderer:3 [
        Group:0, adaptive_supported=N/A [
          [ ] Track:0, id=2, mimeType=audio/mpeg, channels=2, sample_rate=48000, language=tam, supported=YES
        ]
08-22 11:26:01.364 21217-21217/com.example.ridsys_001.AsterTest D/EventLogger:     Group:1, adaptive_supported=N/A [
          [ ] Track:0, id=3, mimeType=audio/mpeg, channels=2, sample_rate=48000, language=tel, supported=YES
        ]
        Group:2, adaptive_supported=N/A [
          [ ] Track:0, id=4, mimeType=audio/mpeg, channels=2, sample_rate=48000, language=hin, supported=YES
        ]
      ]
      Renderer:4 [
        Group:0, adaptive_supported=N/A [
          [X] Track:0, id=6, mimeType=application/x-subrip, language=eng, supported=YES
        ]
      ]
    ]

@ojw28
Copy link
Contributor

ojw28 commented Aug 22, 2018

From the Demo App

I don't think the demo app contains this code. Furthermore, this line looks wrong. You should be passing a renderer index, not a track type:

TrackGroupArray audioTrackGroups = trackInfo.getTrackGroups(C.TRACK_TYPE_AUDIO);

Please take a more careful look at exactly what the demo app is doing.

As an extra hint, I think the extra complexity in your case is that you're also using the Ffmpeg extension. If you look at the logging at the bottom of your post above, you can see there are two audio renderers (renderer 2 and renderer 3), and some of the audio tracks have been mapped to each of them. Hence to ensure the correct audio track gets selected using selection overrides, you'll probably have to set an override for both of them.

When using constraints (e.g. setPreferredAudioLanguage) I think there's a bug in our logic where we'll always prefer to use the first audio renderer, if at least one track is mapped to it. I've filed #4711 to track that issue.

@robindanielk
Copy link
Author

robindanielk commented Aug 23, 2018

@ojw28 .. Hi..thanks for the hint....Now instead of using EXTENSION_MODE_PREFER, i have changed the renderer extension to be alwaysEXTENSION_MODE_ON.
Now all the audio tracks are grouped under one renderer.
Will setting EXTENSION_MODE_ON as default cause any issues since i am using FFMPEG extension?..
Also i have used..

//returns correct index
int audioRendererIndex = mExoPlayer.getRendererType(C.TRACK_TYPE_AUDIO);

//not returning correct index
int subRendererIndex = mExoPlayer.getRendererType(C.TRACK_TYPE_TEXT);

the subtitleRender Index is returning a wrong index of 1

RendererLog:

      Renderer:0 [
08-23 11:13:27.117 20953-20953/com.example.ridsys_001.AsterTest D/EventLogger:     Group:0, adaptive_supported=N/A [
          [X] Track:0, id=1, mimeType=video/avc, res=1280x532, supported=YES
        ]
      ]
      Renderer:2 [
        Group:0, adaptive_supported=N/A [
          [ ] Track:0, id=2, mimeType=audio/mpeg, channels=2, sample_rate=48000, language=tam, supported=YES
        ]
        Group:1, adaptive_supported=N/A [
          [X] Track:0, id=3, mimeType=audio/mpeg, channels=2, sample_rate=48000, language=tel, supported=YES
        ]
        Group:2, adaptive_supported=N/A [
08-23 11:13:27.119 20953-20953/com.example.ridsys_001.AsterTest D/EventLogger:     Group:3, adaptive_supported=N/A [
          [ ] Track:0, id=5, mimeType=audio/mp4a-latm, channels=2, sample_rate=24000, language=eng, supported=YES
        ]
      ]
      Renderer:4 [
        Group:0, adaptive_supported=N/A [
          [X] Track:0, id=6, mimeType=application/x-subrip, language=eng, supported=YES
        ]
      ]
    ]

@ojw28
Copy link
Contributor

ojw28 commented Aug 23, 2018

Will setting EXTENSION_MODE_ON as default cause any issues since i am using FFMPEG extension?

I don't really understand the question. Why would you expect that it might?

As for the following:

//returns correct index
int audioRendererIndex = mExoPlayer.getRendererType(C.TRACK_TYPE_AUDIO);

//not returning correct index
int subRendererIndex = mExoPlayer.getRendererType(C.TRACK_TYPE_TEXT);

This is not correct code, so it's unsurprising that it doesn't work. getRendererType does not accept a type argument and does not return an index, so your usage is incorrect. Please consult the documentation for this method.

@ojw28 ojw28 closed this as completed Aug 23, 2018
@google google locked and limited conversation to collaborators Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants