Jump to content

Audio switching 0.585


fuzzthekingoftrees

Recommended Posts

fuzzthekingoftrees

My studio Ghibli is all ripped from blu-ray into mkv. Video is h.264, then there is usually two audio tracks 1st one is Japanese, second one is English. On the web client and in kodi I can choose the second audio track. I can also set my user preferences to always play english if available and that works.

On the Samsung app I get the Japanese track 1 regardless of the preferences. When I try to change audio tracks using the tools button on the remote the sub menu for audio doesn't appear.

 

Is audio switching supposed to be working in this version?

"MediaStreams":[
{"Codec":"h264","Language":"eng","IsInterlaced":false,"BitRate":8230919,"BitDepth":8,"RefFrames":16,"IsDefault":true,"IsForced":false,"Height":1040,"Width":1920,"AverageFrameRate":23.97602,"RealFrameRate":23.97602,"Profile":"High","Type":"Video","AspectRatio":"1.85:1","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p","Level":51,"IsAnamorphic":false,"IsCabac":true},
{"Codec":"dca","Language":"jpn","IsInterlaced":false,"ChannelLayout":"stereo","BitRate":768000,"Channels":2,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Profile":"DTS-HD MA","Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0},
{"Codec":"dca","Language":"eng","IsInterlaced":false,"ChannelLayout":"stereo","BitRate":768000,"Channels":2,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Profile":"DTS-HD MA","Type":"Audio","Index":2,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0},
{"Codec":"srt","Language":"eng","IsInterlaced":false,"IsDefault":true,"IsForced":false,"Type":"Subtitle","Index":3,"IsExternal":false,"IsTextSubtitleStream":true,"SupportsExternalStream":true,"Level":0}
]
Link to comment
Share on other sites

fuzzthekingoftrees

I've been looking at the code behind this. I'm not much of a programmer so it's taking me a little while to get my head around. There seems to be two issues. The first is around chosing the default audio track and I can fix that succesfully but I don't know how or if you want my diff.

 

The second one is when GuiPlayer_Display.updateDisplayedItemsSub() calls GuiPlayer_Transcoding.start() GuiPLayer_Display.playingVideoIndex is undefined. I fixed this by default the video index to 0 if it's undefined, that fixes the audio menu.

Then it tries to call GuiPlayer_Display.stopPlayback() rather than GuiPlayer.stopPlayback().

Then there is an issue starting the playback again with the chosen audio track the error is

TypeError: 'undefined' is not an object (evaluating 'this.playingMediaSource.Name')

I guess this is when calling GuiPlayer_Display.setDisplay() but I don't know enough about GuiPlayer.PlayerData.MediaSources[] to know why it is undefined at this point.

Link to comment
Share on other sites

fuzzthekingoftrees

I can see where the problem is, there are some variables that aren't initalised in the current scope. I'll need some input from @@chessdragon136 to see where and how they should be set.

  • Like 1
Link to comment
Share on other sites

chessdragon136

If possible, can you upload a sample video (short & small!) to my onedrive (instructions in the reporting issues thread)

 

Thanks for your efforts!

Link to comment
Share on other sites

fuzzthekingoftrees

I uploaded an mkv for you.

When I was looking at the code for handling subtitles I noticed there didn't seem to be any logic for handling the default subtitle setting so when I got the English audio working I was still seeing the subtitles which shouldn't be the case if you have subtitle mode set to default.

Link to comment
Share on other sites

chessdragon136

Ok I see what I've messed up - basically a while back to try tidy my code i split the GuiPlayer class into GuiPlayer & GuiPlayer_Display, with the display element to handle graphical bits and player to handle the playback elements - it looks like i failed to pass through the playingIndexes in the setDisplay

 

@@fuzzthekingoftrees - Thank you! You have saved sime time - Can you post the default audio selection code, i'd like to see what logic you use. I assume you've seen mine in the versions file. The problem is, unless the audio is the first track i have to transcode it (stream copy actually)

 

As for the subtitle on audio change, no i don't change that currently. Maybe i should.

 

I'll push out a new build in the next 20 mins - i cannot test but im pretty sure im on the mark

Link to comment
Share on other sites

fuzzthekingoftrees

I'm afraid that doesn't fix it the problem is that when you call GuiPlayer_Transcoding.start() in GuiPlayer_Display.js those indexes are all null so the tools sub options menu for audio doesn't get built.

 

Here's the section of GuiPlayer_Versions.js from line 172, the changes are on 174, then I've just changed the != to == on 200,208 and 213

	
	var AudioLanguagePreferenece = (UserData.Configuration.AudioLanguagePreference !== undefined) ? UserData.Configuration.AudioLanguagePreference : "none";
	var PlayDefaultAudioTrack = (UserData.Configuration.PlayDefaultAudioTrack !== undefined) ? UserData.Configuration.PlayDefaultAudioTrack: false;
	
	var SubtitlePreference = (UserData.Configuration.SubtitleMode !== undefined) ? UserData.Configuration.SubtitleMode : "Default";
	var SubtitleLanguage = (UserData.Configuration.SubtitleLanguagePreference !== undefined) ? UserData.Configuration.SubtitleLanguagePreference : "eng";
	
	FileLog.write("Video : Audio Play Default Track Setting: " + PlayDefaultAudioTrack);
	FileLog.write("Video : Audio Language Preference Setting: " + AudioLanguagePreferenece);
	FileLog.write("Video : Subtitle Preference: " + SubtitlePreference);
	FileLog.write("Video : Subtitle Language: " + SubtitleLanguage);
	
	var MediaStreams = MediaSource.MediaStreams;
	//---------------------------------------------------------------------------
	//Find 1st Audio Stream
	for (var index = 0;index < MediaStreams.length;index++) {
		var Stream = MediaStreams[index];
		if (Stream.Type == "Audio") {
			indexOfFirstAudio = index;
			FileLog.write("Video : First Audio Index : " + indexOfFirstAudio);
			break;
		} 
	}
	
	for (var index = 0;index < MediaStreams.length;index++) {
		var Stream = MediaStreams[index];
		if (Stream.Type == "Video") {
			videoStreamIfNoDefault = (videoStreamIfNoDefault == 0) ? index : videoStreamIfNoDefault;
			if (videoIndex == -1 && Stream.IsDefault == true) {
				videoIndex = index;
				FileLog.write("Video : Default Video Index Found : " + videoIndex);
			}
		} 
		
		if (Stream.Type == "Audio") {
			if (PlayDefaultAudioTrack == false) {
				if (audioIndex == -1 && Stream.Language == AudioLanguagePreferenece) {
					audioIndex = index;
					FileLog.write("Video : Audio Language Preference Found : " + audioIndex);
				}
			} else {
				if (audioIndex == -1 && Stream.IsDefault == true) {
					audioIndex = index;
					FileLog.write("Video : Default Audio Track Found : " + audioIndex);
				}
			}
		}
	}
Link to comment
Share on other sites

chessdragon136

Yup my bad - my GuiPlayer_Display hasn't synced properly

 

As for the default audio, i get the change on 174 but the others looks the same as it already is in my code...

Edited by chessdragon136
Link to comment
Share on other sites

fuzzthekingoftrees

OK, this is close. I now get the sub tools menu and I can choose the English track. Playback is stopped the log shows

Playback : Stopping
Video : Video File Analysis Results
Video : Codec Compatibility: true : h264
Video : Container Compatibility: true : mkv
Video : Resolution Compatibility: true : 1920x1040
Video : BitRate Compatibility: true : 8230919 : 8230919
Video : FrameRate Compatibility: true : 23.97602
Video : Level Compatibility: true : 51
Video : Profile Compatibility: true : High
Video : Audio File Analysis Results
Video : Codec Compatibility: true : dca
Video : Container Compatibility: true : mkv
Video : Channel Compatibility: true : 2
Video : Transcode Status : Stream Copy - Audio Not First Track
Video : URL : http://192.168.69.124:8096/mediabrowser/Videos/1fa4cf133bb130cd82d98ae4c52ef719/Stream.ts?VideoStreamIndex=0&AudioStreamIndex=2&VideoCodec=copy&AudioCodec=copy&MediaSourceId=1fa4cf133bb130cd82d98ae4c52ef719&api_key=c0cebf9d7bb74a6f8416d76321d6c737&DeviceId=BDCAAKYFDB4FQ
Playback : Player Initialised
Common.API.Plugin.setOffScreenSaver() id: Emby
TypeError: 'undefined' is not an object (evaluating 'this.playingMediaSource.Name')

it looks like when GuiPlayer_Transcoding.start() is called GuiPlayer_Display.playingMediaSourceIndex has no value

 

The other patch is working fine though, you can see the default video and audio tracks are being found

Video : Audio Play Default Track Setting: true
Video : Audio Language Preference Setting: eng
Video : Subtitle Preference: Default
Video : Subtitle Language: eng
Video : First Audio Index : 1
Video : Default Video Index Found : 0
Video : Default Audio Track Found : 1
Link to comment
Share on other sites

chessdragon136

ok when I get to a computer tonight I'll rework the code so it calls a function back in guiplayer as opposed to passing all these indexes through - that was the plan originally I think I just forgot and enables the tools menu before checking! Sorry

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...