Jump to content

Audio Transcoding during playback


SamES

Recommended Posts

SamES

Hi @@chessdragon136, I've noticed a few files that are transcoding audio during playback.

 

I've added a sample to the onedrive folder.  Notice that it has two audio tracks.  Both are AAC, one 5.1, the other stereo.

 

Initial playback I suspect starts with the 5.1 and I can see transcoding in the server logs and transcoding-temp folder.

 

If I switch audio tracks during playback (with the tools menu) the transcoding stops.  If I switch back again, the transcoding starts again.

 

I'm not sure that this should be transcoding at all, Model is ES8000.

 

Thanks.

Link to comment
Share on other sites

chessdragon136

Can you clear the newly implemented log, then play the file, then report to me the log details please

Link to comment
Share on other sites

chessdragon136

Ok pushed out v0.570a - may fix this, not sure - can you repeat the process please

Link to comment
Share on other sites

chessdragon136

Ok actually my fix is wrong - the issue is that because the selected audio track is not the first one in the file, I have to stream copy the video and audio elements so the correct audio is played. 

Link to comment
Share on other sites

chessdragon136

I've added more settings and reversed my fix - let me know the log details of the file and i can then try tell you why it plays the second track by default

Link to comment
Share on other sites

SamES

I've added more settings and reversed my fix - let me know the log details of the file and i can then try tell you why it plays the second track by default

 

OK, doesn't play at all now, reports connection error.  Both tracks play fine via DLNA from the MB3 server

 

54fc06cd3f4d1_WP_001020.jpg54fc06f8f2dce_WP_001022.jpg

Edited by SamES
Link to comment
Share on other sites

chessdragon136

Ok sorry - Fixed. 

 

Basically what is happening is that in this file, the default audio track is not the first one, so it has to stream copy the audio & video and pass it through like that, otherwise the samsung player will just play the first track it finds. So theres not much I can do, its a limitation of the Samsung player in regards to multiple audio track files, I have to do it server side as they don't let developers code it client side

 

In the server, if you uncheck "play default audio track" then it will probably just select the first one by default and play that, thus you don't get stream copy. 

Link to comment
Share on other sites

SamES

Ok sorry - Fixed. 

 

Basically what is happening is that in this file, the default audio track is not the first one, so it has to stream copy the audio & video and pass it through like that, otherwise the samsung player will just play the first track it finds. So theres not much I can do, its a limitation of the Samsung player in regards to multiple audio track files, I have to do it server side as they don't let developers code it client side

 

In the server, if you uncheck "play default audio track" then it will probably just select the first one by default and play that, thus you don't get stream copy. 

 

OK, so I'm getting a clearer idea of what's going on.

 

BTW, it is hard to know which audio track it is playing from the tools->Audio menu as they both say 'aac - eng'.  This may be a stretch, but is it possible to add the number of channels for AAC (ie: 2 ch, 5.1, etc). 

 

From a MediaInfo dump and looking at the transcode log, track 1 is 5.1, track 2 is 2 ch.  I can understand the process of transcoding to switch the audio tracks (although DLNA does this fine without transcoding, maybe this is a Samsung API limitation?)

 

My question is, why is the second track (2 ch audio) the default track that is being played.  My preference would be to pick up the first track (which would direct play as you mention), and then it would only need to do the transcode thing if the user switches manually to the second track.  I would have expected 5.1 audio to be the preference anyway.  

 

By what logic is it currently 'defaulting' to audio track 2?

 

FYI, I noticed that you have updated the labels on the Tools->Audio menu to specify 'Transcode', but it now shows that for both tracks, but in reality, the first track does play by DirectPlay, no transcoding/track swapping required.

 

I suppose to 'fix' this, I would expect it to always start playing with the first track (at least for MP4 container as I believe it doesn't have a default track flag), and this would reduce the need to transcode.

 

With MKV's, this seems to work fine as it is honouring the 'default track' flag but for MP4's, it seems to be taking the last? audio track as the default.

 

For MP4 (which does not have default or forced track support) the first audio track should always be the default track.

Edited by SamES
Link to comment
Share on other sites

chessdragon136

Well from the logs above i can say that the server has deemed the second audio track in the file as the default. I don't know how the server has decided this but I'd be surprised if mp4 does not have a default flag on tracks.. 

 

Regarding the audio menu - i'm sure i can add info and correct the text. 

 

It is an api limitation. I have a working example of audio switching client side using a different samsing player api - the problem with it though is that that api does not allow me to define a start time in the video, which is more of a problem than this one. 

Edited by chessdragon136
Link to comment
Share on other sites

SamES

Well from the logs above i can say that the server has deemed the second audio track in the file as the default. I don't know how the server has decided this but I'd be surprised if mp4 does not have a default flag on tracks.. 

 

Regarding the audio menu - i'm sure i can add info and correct the text. 

 

It is an api limitation. I have a working example of audio switching client side using a different samsing player api - the problem with it though is that that api does not allow me to define a start time in the video, which is more of a problem than this one. 

 

From the best of my Googling, by all reports the MP4 container does not support a default track flag.

 

http://forum.videohelp.com/threads/368436-ffmpeg-force-default-audio-track-in-mp4-container?p=2357036&viewfull=1#post2357036

 

 However, the ffprobe-video results from the server reports that both tracks are default for all my MP4's.  I believe this is not actually the case.  The server then seems to reflect this result.

 

54fd2fcf9d0a1_ffprobe.png

 

As a result, your code in GuiPlayer_Versions.js always takes the last 'default' track and uses it.  I propose a modification that would force it to only use the first 'default' track.  I'm sure this would be logical in all cases anyway and I can't really see it breaking anything.

 

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 (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);

                }

            }

        }

    }

 

 

Let me know your thoughts as I think this would make the player more robust for these cases.

  • Like 1
Link to comment
Share on other sites

chessdragon136

Ok you're right on the mark on all of that, even the code changes would work, but I'm just going to add a break after the file log lines so it stops searching (escapes the for loop) it's a touch more efficient.

 

I'm definitely surprised about both MP4 not having a default flag (must just use language instead) and that ffprobe marks hem all as default, but I'm sure there is reasoning behind it!

 

I'll implement this at home tonight - thank you

  • Like 1
Link to comment
Share on other sites

SamES

Ok you're right on the mark on all of that, even the code changes would work, but I'm just going to add a break after the file log lines so it stops searching (escapes the for loop) it's a touch more efficient.

 

I'm definitely surprised about both MP4 not having a default flag (must just use language instead) and that ffprobe marks hem all as default, but I'm sure there is reasoning behind it!

 

I'll implement this at home tonight - thank you

 

Thanks, the only reason I didn't consider using a break was due to you seeking for default video and audio in the same for loop.

 

A break will exit when either default is found, and one will always be missed (probably audio if video is always stream 0)

Link to comment
Share on other sites

SamES

Again you make a good point! Just pushed v0.572

 

All good now, thanks

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...