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

[STOP OPENING DUPLICATES] Support multiple audio tracks #5854

Closed
3 tasks done
selurvedu opened this issue Mar 18, 2021 · 38 comments · Fixed by #9937
Closed
3 tasks done

[STOP OPENING DUPLICATES] Support multiple audio tracks #5854

selurvedu opened this issue Mar 18, 2021 · 38 comments · Fixed by #9937
Labels
feature request Issue is related to a feature in the app multiservice Issues related to multiple services player Issues related to any player (main, popup and background) requires extractor change This issue requires a change to the extractor

Comments

@selurvedu
Copy link

selurvedu commented Mar 18, 2021

Checklist

Describe the feature you want

I noticed that some videos on this channel are played with non-English audio track: https://www.youtube.com/channel/UCBSs9x2KzSLhyyA9IKyt4YA (look for the "Multi-Audio Clip" ones)

The same video is played in English on mobile YouTube website. Changing the UI language (Settings -> Account -> Language) also changes the audio track language.

Is your feature request related to a problem? Please describe it

Yes. Some videos get played in a language I don't understand, while mobile YouTube web plays them in English by default (at least on my phone, tested on Firefox Klar/Focus with cookies cleared).

Additional context

See the channel link above.

How will you/everyone benefit from this feature?

This feature will let our users select which language they prefer and watch a video with corresponding audio track. It will also fix the problem I described above.

Mod edit for search keywords: different other

@AudricV

This comment was marked as outdated.

@AudricV AudricV closed this as completed Mar 19, 2021
@AudricV AudricV added the template missing The bug/feature template is missing (e.g. the used app does not support issue templates) label Mar 19, 2021
@selurvedu

This comment was marked as outdated.

@AudricV AudricV removed the template missing The bug/feature template is missing (e.g. the used app does not support issue templates) label Mar 19, 2021
@AudricV AudricV reopened this Mar 19, 2021
@AudricV
Copy link
Member

AudricV commented Mar 19, 2021

Related: #1059

@AudricV AudricV added feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background) youtube Service, https://www.youtube.com/ labels Mar 19, 2021
@SameenAhnaf

This comment was marked as outdated.

@ChunkyProgrammer
Copy link

I think this would require an extractor change as well.
Here are some example videos that I was able to find:
Would You Sit In Snakes For $10,000? by Mr Beast
Assasin's Creed Valhalla: Story Trailer by Ubisoft North America

The setting is found here on the youtube desktop site:
image

@vinc3nz
Copy link

vinc3nz commented Nov 21, 2022

Any updates to this? Watching MrBeast in Spanish is really annoying and I have to use YouTube app for such videos.

@AudricV
Copy link
Member

AudricV commented Nov 21, 2022

Yes, an initial extractor support has been added. Support of getting whether an audio is descriptive needs to be added in the extractor, and the corresponding app part needs to be done.

@QL568A6

This comment was marked as abuse.

@QL568A6
Copy link

QL568A6 commented Mar 6, 2023

Does this code from the LibreTube repo help?

private fun getAudioStreamGroups(audioStreams: List<PipedStream>?): Map<String?, List<PipedStream>> {
        return audioStreams.orEmpty()
            .groupBy { it.audioTrackName }
    }

    override fun onAudioStreamClicked() {
        val audioGroups = getAudioStreamGroups(streams.audioStreams)
        val audioLanguages = audioGroups.map { it.key ?: getString(R.string.default_audio_track) }

        BaseBottomSheet()
            .setSimpleItems(audioLanguages) { index ->
                val audioStreams = audioGroups.values.elementAt(index)
                val lang = audioStreams.firstOrNull()?.audioTrackId?.substring(0, 2)
                trackSelector.updateParameters {
                    setPreferredAudioLanguage(lang)
                }
            }
            .show(childFragmentManager)
    }

https://github.com/libre-tube/LibreTube/blob/master/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt

@MoralCode
Copy link

MoralCode commented Mar 7, 2023

by my crude understanding, it seems like there may be some features missing in the underlying extractor that provides the raw data (such as streams.audioStreams in your example code) that would be needed to support this. I took a brief look at some of the linked issues and it seems partly there tho, the bulk of the remaining work seems to be UI/UX changes.

Your code does raise an interesting question though, it looks like that code is using string manipulation to detect the language. Where do the names of those tracks come from? are they defined by the uploader? or does youtube set them to something thats (mostly) consistent across the majority of youtube videos on the platform?

@AudricV
Copy link
Member

AudricV commented Mar 7, 2023

Does this code from the LibreTube repo help?

No, not at all, as LibreTube uses a different way to get audio language tags that we will be able to use, thanks to my changes and data is different between LibreTube which uses Piped's API which uses the extractor one and NewPipe which uses directly the extractor API.

Your code does raise an interesting question though, it looks like that code is using string manipulation to detect the language. Where do the names of those tracks come from? are they defined by the uploader? or does youtube set them to something thats (mostly) consistent across the majority of youtube videos on the platform?

That's what I said in my previous comment, we have to parse an audio track ID to get an audio language code (we could also use the stream URL). All of this is defined by YouTube.

To keep you updated, TeamNewPipe/NewPipeExtractor#1026, which contains the changes I talked above, has been opened and merged. There is only one mistake that I made on the DASH manifest role attribute for descriptive audios I need to fix and then the app implementation could start.

A similar implementation to the one of the subtitles could be the way to implement the audio switch UI, but I am not sure, as services such as MediaCCC use progressive media and ExoPlayer would probably have no information about what language an audio track would have.

For audio selection, the audio selection needs to be changed to return probably a list of audio streams with different languages and a specific quality (in ListHelper).

An external audio player stream dialog needs also to be implemented, which would allow language selection and probably quality selection like the video dialog one.

Note that @Theta-Dev showed on the NewPipe subreddit a preview of this feature, so they may share their implementation insights and/or their ideas.

@MoralCode
Copy link

MoralCode commented Mar 7, 2023

since this has been in demand for almost two years, would it be acceptable to implement the NewPipe frontend changes in 2 stages? i.e. stage 1 being a basic-but-imperfect implementation that just picks an audio track that matches the language setting device to reduce the number of disrupted viewing experiences, and stage 2 being the full UI implementation that lets the user pick their own language track if they want.

on one hand i see some benefit in doing this in two passes to deal with the problem for the majority of users, but also doing it this way seems like it might take a lot of the pressure off of this issue and could cause phase 2 to be de-prioritized in comparison to more important issues (i.e. "theres nothing more permanent than a temporary fix").

@ssaagamemer

This comment was marked as duplicate.

@ssaagamemer

This comment was marked as duplicate.

@lavara123

This comment was marked as spam.

@Theta-Dev
Copy link
Contributor

Theta-Dev commented Apr 2, 2023

I have the audio language selector implemented in #9937. You can download the test build and try it out yourself.

@AudricV AudricV changed the title Support multiple audio tracks [STOP OPENING DUPLICATES] Support multiple audio tracks Apr 4, 2023
@AudricV AudricV pinned this issue Apr 4, 2023
@papb

This comment was marked as off-topic.

@Theta-Dev

This comment was marked as off-topic.

@KugaNoir

This comment was marked as spam.

@KugaNoir

This comment was marked as spam.

@nefarius

This comment was marked as resolved.

@ashbackslash

This comment was marked as spam.

@TeamNewPipe TeamNewPipe locked and limited conversation to collaborators May 27, 2023
@TobiGr TobiGr unpinned this issue Aug 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Issue is related to a feature in the app multiservice Issues related to multiple services player Issues related to any player (main, popup and background) requires extractor change This issue requires a change to the extractor
Projects
None yet
Development

Successfully merging a pull request may close this issue.