Mpeg-Ts stream with multiple audio tracks

Apr 3, 2015 at 8:12 AM

how can i choose a different audio track?

I use the MS Player Framework with the phonesm plugin.
The Player Framework has an option to choose the audio track, but it shows only one track.

Apr 11, 2015 at 1:04 AM
I wrote a long answer to this post about when Codeplex shut off posting and saw it vanish when I finally hit "Save" and wound up on the outage page. However, it did get me looking at the problem and it turned out that one could get it working on WinRT without too much trouble. I have not yet looked at what it would take to get this working on the Silverlight side of things nor what, if anything, one need do to get it working with Player Framework.

If you can, a PM with a sample TS segment or a test URL would be appreciated since I don't have all that many sample multi-audio TS streams to test with.

8c8d301e040f adds support for multiple audio streams, but the filter still blocks all but the first stream, I'm still working on extracting the language from the TS descriptors, and the HlsView's UI does not support changing the MediaElement.AudioStreamIndex.

The first limitation is simple enough to overcome:
        static readonly MediaManagerParameters MediaManagerParameters = new MediaManagerParameters { ProgramStreamsHandler = pss => { }};
            _mediaStreamFacade = MediaStreamFacadeSettings.Parameters.Create();

This will completely disable the stream filter. It would probably be safer to block all but the first video stream and all non-audio streams. The default implementation looks like this:
        static void DefaultProgramStreamsHandler(IProgramStreams pss)
            var hasAudio = false;
            var hasVideo = false;

            foreach (var stream in pss.Streams)
                switch (stream.StreamType.Contents)
                    case TsStreamType.StreamContents.Audio:
                        if (hasAudio)
                            stream.BlockStream = true;
                            hasAudio = true;
                    case TsStreamType.StreamContents.Video:
                        if (hasVideo)
                            stream.BlockStream = true;
                            hasVideo = true;
                        stream.BlockStream = true;
As another example, Background audio blocks all but the first audio stream with:
            _mediaManagerParameters = new MediaManagerParameters
                ProgramStreamsHandler =
                    streams =>
                        var firstAudio = streams.Streams.First(x => x.StreamType.Contents == TsStreamType.StreamContents.Audio);

                        var others = streams.Streams.Where(x => x.Pid != firstAudio.Pid);
                        foreach (
                            var programStream in others)
                            programStream.BlockStream = true;
Apr 11, 2015 at 12:57 PM

with the following changes I can select the audio stream in the player framework. Many thanks for that.
case TsStreamType.StreamContents.Audio:
                        //if (hasAudio)
                        //    stream.BlockStream = true;
                        //    hasAudio = true;
Here is an example file with two audio streams:

But the names of the streams will not be displayed.
It looks like this:
Apr 12, 2015 at 2:43 PM
You're welcome.

Getting the language tag all the way from the MPEG-2 transport stream to the UI turned out to be a bit of work. The SM.TsParser project has been merged into SM.Media, which was somewhat painful, but this lets the old TsParser code and the rest of SM.Media interact more cleanly (it was either that, or suffer the complexity of adding yet another project to hold code needed by both SM.TsParser and SM.Media). Hopefully, this change will not cause too much trouble.

The bit that turns the IAudioConfiguration into a Player Framework AudioStream is in AudioStreamFactory; it may warrant some per-application customization.

Could you give f35b9f4ea8be a try? With this change, the WinRT SamplePlayer shows the languages for the sample you provided (at least, it did when I tested it).

Apr 14, 2015 at 8:26 AM
Works fine.

Thanks for your great work!