none
Live Streaming with Low Latency settings -- where am I going wrong? RRS feed

  • Question

  • Hi:

    EDIT/PREFACE: GAAAAAH i just typed up this huge post with nice images and links only to be told upon posting, "Body text cannot contain images or links until we are able to verify your account." -- Anyway, I had to remove all the links. Maybe warn us this will happen before we create a huge post with all the things?

    -------anyhoo------

    I've been banging my head against the wall for a couple of days now trying to get low-latency live streaming working. I want to get under 10s. (Under 5s would be dreamy, though!) I've been following this tutorial (EDIT: Link removed because GAAAAH, but it's a Microsoft doc with the title Tutorial: Stream live with Media Services), but to no avail. I'm still seeing latencies of 30s. Some notes about my environment:

    • The one thing I've changed in the code sample is to change from LiveEncodingType.None to LiveEncodingType.Standard, so that I can enable multi-bitrate video. Relevant code block:
                        encoding: new LiveEventEncoding(
                                    // When encodingType is None, the service simply passes through the incoming video and audio layer(s) to the output
                                    // When the encodingType is set to Standard or Premium1080p, a live encoder is used to transcode the incoming stream
                                    // into multiple bit rates or layers. See https://go.microsoft.com/fwlink/?linkid=2095101 for more information
                                    encodingType: LiveEventEncodingType.Standard,
                                    presetName: null
                                )
    • StreamOptionsFlag.LowLatency is set.
    • Using Azure Media Player v2.3.0 with following settings:
            var myOptions = {
                traceConfig: {
                    TraceTargets: [{ target: 'console' }],
                    maxLogLevel: 2
                },
                autoplay: true,
                heuristicProfile: "LowLatency",
                "logo": { "enabled": false },
                autoplay: true,
                controls: false,
                fluid: true,
                poster: ""
            };
    • I'm using OBS with NVEnc in low-latency mode. I'm also enabling the OBS new networking code with low-latency turned on.
    • Using my current OBS settings and streaming to my Twtch gives me latencies <4s, so I know the latency isn't occurring in OBS.
    • Encoder settings: (Edit: Images removed because GAAAAAH so will just give summary (seriously so bloody frustrating, sorry)) Summary: NVENC (new) encoder, CBR, 2500Kbps, Low-latency Quality preset, Keyframes 0 (auto), Max B-Frames 2; video output scaled resolution 1280x720 FPS 30.
    • My Media Service resource is using the default settings as described in the tutorial above. So, that's with CDN enabled and using the S1 encoders.

    As I said, getting like 20s-30s latency on viewing. Questions:

    1. What are the optimal settings for the Media Service resource? CDN on or off? S1/S2 etc, does it matter? In my testing it does not appear.
    2. How do i interrogate Media Services (backend and player) to ensure low latency mode is enabled? I suspect it may not be. The player's property shows it is set.
    3. Does Low Latency mode work with encoding live streams? Or just with passthrough?
    4. What other diagnostic steps can I take? Are there any steps I'm missing?

    Thanks for your help.


    • Edited by boojit Friday, July 19, 2019 7:43 PM made it less angry
    Friday, July 19, 2019 7:40 PM

All replies

  • Hi, 

    Let me see if I can sort this out for you.  You appear to be doing everything correctly on the setup of the AMP player. 
    But I think you may have misunderstood the docs a bit.  The live Transcoding channel does add more latency.  We typically see between 14-18 seconds when using 2-second GOPS on the encoder (sometimes set as 60 frame keyframes for 30fps content). 

    See the table here for pass through vs. live encoder -https://docs.microsoft.com/en-us/azure/media-services/latest/live-event-latency

    In addition as the table notes, the behavior is different on iOS vs. AMP in a web page on Chrome or Edge browsers for example. iOS tends to add more latency. 

    Some things you can test out. Start with Pass-through only, and set to 2-second GOPs first, and view the playback in AMP with Chrome or Edge browser to see if you are getting closer to our guideline.  At that point you could also choose to switch to 1-second GOP, and see if it negatively impacts your picture quality. It should reduce the latency further on pass-through with some quality degradation on the content.  Let me know how that works out first. 

    Answering you questions more directly as well:

    1. What are the optimal settings for the Media Service resource? CDN on or off? 
      CDN can add caching latency of 1-2 segments. Depending on which CDN and cache fill logic.  Start a second Streaming Endpoint with CDN off and compare. 
    2. S1/S2 etc, does it matter? In my testing it does not appear.
      Does not matter. Has nothing to do with it. 
    3. How do i interrogate Media Services (backend and player) to ensure low latency mode is enabled? I suspect it may not be. The player's property shows it is set.
      If you created the LiveEvent with the low latency flag - the easiest thing is to just query the API for the LIveEvent and make sure that the flag is actually set still. I normally do this via the POSTMAN tool through the REST API and just check for this:
    "properties": {
    "streamOptions": [
    "LowLatency"

    ]

    4. Does Low Latency mode work with encoding live streams? Or just with passthrough?
    YES, it helps. but it does not reduce the latency as far as pass-through can.

    Friday, July 19, 2019 8:06 PM
  • Hi John:

    Thank you so much for this detailed reply. I actually remember reading this document before now that you bring it up again -- so I was hoping for 14s I guess.

    The GOP thing is another whole thing. In OBS, the NVEnc (that uses the hardware encoder on my NVidia graphics card) settings don't have a specific GOP setting but they do have a max keyframes setting. Let's see if I can post the image now:

    (GAAAAH nope no images yet...the setting is "Keyframe Interval (seconds, 0=auto)" and I currently have it set to 0. Integer values only; Max value is 10.)

    So I guess I should set the keyframe interval to 1? Is that the same thing?

    Gonna try this now and see what's shakin'.

    Thanks again for your help.

    Friday, July 19, 2019 8:22 PM
  • My OBS Studio does not show the NVENC option - only the Intel QuickSync option, but under Advanced settings it lists it as "KeyFrame Interval" - which appears to be in seconds.  So a value of 1 or 2 would work there. 

    I have mine set to 1 right now. FYI. 

    Friday, July 19, 2019 8:27 PM
  • UPDATE HOLY CRISPY COCO PUFFS IT'S LIKE 11S NOW.

    Cool.

    John, so I guess if I want to drop that even more and use multi-bitrate, then i want to get myself a proper dedicated encoder that can produce a multi bitrate stream and send that up to Azure and then passthru that, right?

    Another couple of related questions if you don't mind:

    1. Rather than create the live stream in code, I can do this manually from the Azure Portal. There's a setting in there to enable low latency when I do so. Is that the same as setting StreamOptionsFlag.LowLatency in code? (is setting up the channel in the portal the same as doing it in code?)
    2. When I use the code to create the live stream, the thing doesn't show up in my Portal. Is that by design? Seems kind of weird to me, I have a resource that is being billed but I can't see it anywhere (that I can find) in the Portal. It's just sort of a ghost out there.

    Thanks again! I'm pretty jazzed about this.

    Friday, July 19, 2019 8:34 PM
  • My OBS Studio does not show the NVENC option - only the Intel QuickSync option, but under Advanced settings it lists it as "KeyFrame Interval" - which appears to be in seconds.  So a value of 1 or 2 would work there. 

    I have mine set to 1 right now. FYI. 

    Yeah you'll only see NVEnc if you have an Nvidia card -- it's for the video encoders on those cards only.
    Friday, July 19, 2019 8:35 PM
  • Awesome-ness.  

    I think you should ping me on the amshelp@microsoft.com alias and I will intro you to some folks that are designing our portal.  I think we have some stuff to show and get your feedback on. 

    Thanks for using Azure Media Services!

    -John 

    Friday, July 19, 2019 9:22 PM