This project has moved. For the latest updates, please go here.

Image errors and stutters with SamplePlayer.WP81! With SamplePlayer.WP8 stream works fine.

Oct 5, 2014 at 4:14 PM
Hi,
i have problems with the SamplePlayer.WP81 with the following Live-Stream.

http://s51.org:8080/flashstream/stream.ts?Preset=1&aspect=16:9&ffPreset=medium&maxwidth=&maxheight=&chid=1

I get image errors and stutters. Audio works fine.
The same Stream works without any problems with the SamplePlayer.WP8
Any idears?

Thanks.
Coordinator
Oct 6, 2014 at 6:40 PM
Which version of phonesm are you using? Are you seeing this on an emulator or a real device? Do you need to play for a while for it to start stuttering or does it happen immediately?

I did not see anything odd when I played the stream on a Lumia 920 with the latest source code (roughly, 96c41bd5251b).

Thanks.
Oct 7, 2014 at 8:03 AM
Hi,
I use version 96c41bd5251b. I am seeing this on emulator and device (Lumia 930). Looks like that the problem only exists in Landscape and fullscreen mode.

Thanks
Coordinator
Oct 7, 2014 at 4:13 PM
Do you see anything odd in the Debug Output window (with a debug build and the debugger attached)? Which version of WP are you running on that 930?
Oct 7, 2014 at 4:47 PM
No, debug output looks fine. Somesthing about buffering at the beginning, then nothing.

WP Version is 8.10.12397.895
Coordinator
Oct 8, 2014 at 8:10 PM
Is it detecting the streams like this?
Configuration H.264 "Baseline" profile, level 3 704x396
Configuration MP3 Frame: MPEG Version 1 (ISO/IEC 11172-3), Layer III sample 44.1kHz bitrate 96kHz channel mode 1
Does it stutter in Release mode (if there is enough debug spew, then things can get a bit slow)?

Could you give it a try with "Emulator 8.1 U1 WVGA 4 inch 512MB" and see if it behaves the same?

Do you see any difference between HlsView.WP81 and SamplePlayer.WP81?

Thanks.
Oct 9, 2014 at 1:57 PM
I'm having the same issue with the SamplePlayer in WP8.1

Whenever the player tries to load another TS file, sometimes the video stutters and then the audio is out of sync.

I noticed in the debug output, when the video stutters and the audio gets out of sync, I see the following message:
AudioStreamHandler.GetDuration() unable to find frame, skipping x bytes where x could be any number

I tried to run the HLSView but when I put the m3u8 file into the source property on the MediaElement, I got an error about the media load failing.
Oct 9, 2014 at 3:05 PM
I also noticed the out of sync issue with SamplePlayer for Windows 8.1. With either SamplePlayer, I am attempting to run in Release mode and the sync issue is still present.
Coordinator
Oct 9, 2014 at 5:48 PM
johnmurphy01 wrote:
I also noticed the out of sync issue with SamplePlayer for Windows 8.1. With either SamplePlayer, I am attempting to run in Release mode and the sync issue is still present.
Are you seeing the same "AudioStreamHandler.GetDuration() unable to find frame, skipping x bytes" errors on Windows 8.1 as well? Could you PM the stream or some segments from the stream so that I could take a look?

Thanks.
Coordinator
Oct 9, 2014 at 5:54 PM
Edited Oct 9, 2014 at 5:56 PM
johnmurphy01 wrote:
I tried to run the HLSView but when I put the m3u8 file into the source property on the MediaElement, I got an error about the media load failing.
Could you double check the URL in the output window? (I've shot myself in the foot a few times since a URL on an XAML page needs "&"s where the URL string in HlsView would just want "&".)

The code that actually reads the streams is the same for HlsView and SamplePlayer. The former uses MediaElement directly and the latter uses a Player Framework plugin. That's why I usually try to simplify things by using HlsView when something is going wrong.
Oct 9, 2014 at 5:56 PM
Sent you PM, henric. Thanks!
Oct 10, 2014 at 1:43 PM
henric wrote:
Is it detecting the streams like this?
Configuration H.264 "Baseline" profile, level 3 704x396
Configuration MP3 Frame: MPEG Version 1 (ISO/IEC 11172-3), Layer III sample 44.1kHz bitrate 96kHz channel mode 1
Does it stutter in Release mode (if there is enough debug spew, then things can get a bit slow)?

Could you give it a try with "Emulator 8.1 U1 WVGA 4 inch 512MB" and see if it behaves the same?

Do you see any difference between HlsView.WP81 and SamplePlayer.WP81?

Thanks.
It stutter on all Emulators also in Release mode. On device i have periodically image errors (in Landscape Mode) and it makes no difference if i use the HlsView.WP81 or SamplePlayer.WP81
Coordinator
Oct 10, 2014 at 11:23 PM
Could you try forcing the frame rate to 25 Hz?

In WinRtMediaStreamSource, change CreateVideoDescriptor to look like this:
        IMediaStreamDescriptor CreateVideoDescriptor(IVideoConfigurationSource configurationSource)
        {
            var encodingProperties = GetVideoEncodingProperties(configurationSource);

            if (null == encodingProperties)
                throw new ArgumentOutOfRangeException();

            if (configurationSource.Height.HasValue)
                encodingProperties.Height = (uint)configurationSource.Height.Value;

            if (configurationSource.Width.HasValue)
                encodingProperties.Width = (uint)configurationSource.Width.Value;

            encodingProperties.FrameRate.Numerator = 25;
            encodingProperties.FrameRate.Denominator = 1;

            var descriptor = new VideoStreamDescriptor(encodingProperties);

            if (string.IsNullOrEmpty(descriptor.Name))
                descriptor.Name = configurationSource.Name;

            return descriptor;
        }
Thanks.
Oct 12, 2014 at 12:45 AM
That didn't do anything to fix the issue I'm seeing. I'm on a different wireless connection and it's actually worse. The syncing issue occurs sooner than it did when I was testing it at a location with better internet speeds.
Coordinator
Oct 12, 2014 at 2:05 PM
@johnmurphy01: sorry for not being clear. Setting the frame rate was to see if it helped with @nanohcv's problem. If one sets it to 25 Hz for a video that is not 25 Hz, then things will get out of sync very quickly. If you want to try forcing the frame rate on the stream you PM'ed, then try 24000/1001 (23.9760 fps). I have some experimental code that digs out the H.264 stream's frame rate, but it is ugly (having to dig out stuff from the pic_timing SEI).

Unless you are seeing buffering messages while it is getting out-of-sync, then the network bandwidth should not be an issue.

Note that as of a3474063775c, seriously out-of-sync streams should get re-synced when playback is restarted after a pause. This could possibly be modified to lower the threshold that triggers this behavior and to check during playback, but it would be better to figure out what is going wrong. Per my earlier email, you may need to set "AacSettings.Parameters.UseParser = true" since audio frames are getting split into multiple PES packets.
Oct 12, 2014 at 2:49 PM
AacDecoderSettings.Parameters.UserParser = true seemed to resolve the sync issue for me! I'm about 4 minutes into the video and audio is synced perfectly with the video with no stuttering.

My question now is, can this always be set to true or will I have to write some logic to determine if this needs to be enabled?

Thanks.
Coordinator
Oct 12, 2014 at 9:27 PM
Edited Oct 13, 2014 at 7:16 AM
You're welcome. Good to hear that the UseParser seems to have resolved things for you.

johnmurphy01 wrote:
My question now is, can this always be set to true or will I have to write some logic to determine if this needs to be enabled?
It should be fine to have it on all the time. Theoretically, it will use a few more CPU cycles to find the AAC frames and feed them individually through the pipeline than only measuring the duration of a few packets around when there is a segment change (done by TsTimestamp). I don't recall if MediaElement cares about frames split between samples and that might change in the future anyway. Besides, what duration should one use for a media sample (an individual chunk fed to the MediaElement) that contains a partial audio frame?

If you have other streams with MP3 audio that have the same problem, then you will need to modify the Mp3StreamHandler.UseParser constant (sorry, no runtime knob for that one).

Come to think of it, if people are seeing MPEG-2 Transport Streams like this in the wild, I should probably change the defaults to "true". It will have no effect on MP3 or AAC streams since they already split things into individual, whole frames. In fact, the effect of turning on those "UseParser" options is to pass the data in the TS' PES packets through the same code that handles raw MP3 or AAC streams before feeding them to the MediaElement (instead of feeding the data in the PES packets directly to the MediaElement).

Yes, I think I will change the defaults...
Oct 21, 2014 at 8:10 AM
Forcing the frame rate to 25 Hz did not solve the problem.
But today i get the Lumia Cyan Update. That update solve the problem.

Thanks a lot for your great library and work!