AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://OvenMediaEngine.com/ome
GNU Affero General Public License v3.0
2.53k stars 1.06k forks source link

[LLHLS] When the stream is longer than 3 hours the browser won't play the playlist #1358

Closed p4xx07 closed 1 year ago

p4xx07 commented 1 year ago

Describe the bug When the stream is longer than 3 hours the browser won't play the playlist

To Reproduce I'm using docker run oven media engine Steps to reproduce the behavior:

  1. Set Server.xml as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <Server version="8">
    <Name>OvenMediaEngine</Name>
    <Type>origin</Type>
    <IP>*</IP>
    <PrivacyProtection>false</PrivacyProtection>
    <StunServer>stun.ovenmediaengine.com:13478</StunServer>
    
    <Modules>
        <HTTP2>
            <Enable>true</Enable>
        </HTTP2>
    
        <LLHLS>
            <Enable>true</Enable>
        </LLHLS>
        <P2P>
            <Enable>false</Enable>
            <MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
        </P2P>
    </Modules>
    
    <Bind>
        <Managers>
            <API>
                <Port>8083</Port>
                <WorkerCount>1</WorkerCount>
            </API>
        </Managers>
    
        <Providers>
            <RTSPC>
                <WorkerCount>1</WorkerCount>
            </RTSPC>
            <OVT>
                <WorkerCount>1</WorkerCount>
            </OVT>
            <RTMP>
                <Port>1935</Port>
                <WorkerCount>1</WorkerCount>
            </RTMP>
            <SRT>
                <Port>9999</Port>
                <WorkerCount>1</WorkerCount>
            </SRT>
            <MPEGTS>
                <Port>4000/udp</Port>
            </MPEGTS>
            <WebRTC>
                <Signalling>
                    <Port>3333</Port>
                    <WorkerCount>1</WorkerCount>
                </Signalling>
    
                <IceCandidates>
                    <IceCandidate>*:10000-10005/udp</IceCandidate>
                    <TcpRelay>*:3478</TcpRelay>
                    <TcpForce>true</TcpForce>
                    <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                </IceCandidates>
            </WebRTC>
        </Providers>
    
        <Publishers>
            <OVT>
                <Port>9000</Port>
                <WorkerCount>1</WorkerCount>
            </OVT>
            <LLHLS>
                <Port>31060</Port>
                <WorkerCount>1</WorkerCount>
            </LLHLS>
            <WebRTC>
                <Signalling>
                    <Port>3333</Port>
                    <WorkerCount>1</WorkerCount>
                </Signalling>
                <IceCandidates>
                    <IceCandidate>*:10000-10005/udp</IceCandidate>
                    <TcpRelay>*:3478</TcpRelay>
                    <TcpForce>true</TcpForce>
                    <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                </IceCandidates>
            </WebRTC>
            <Thumbnail>
                <Port>20080</Port>
            </Thumbnail>
        </Publishers>
    </Bind>
    
    <Managers>
        <Host>
            <Names>
                <Name>*</Name>
            </Names>
        </Host>
        <API>
            <AccessToken>ome-access-token</AccessToken>
    
            <CrossDomains>
                <Url>*</Url>
            </CrossDomains>
        </API>
    </Managers>
    
    <VirtualHosts>
        <VirtualHost include="VHost*.xml" />
        <VirtualHost>
            <Name>default</Name>
            <Distribution>ovenmediaengine.com</Distribution>
            <Host>
                <Names>
                    <Name>*</Name>
                </Names>
            </Host>
            <Applications>
                <Application>
                    <Name>app</Name>
                    <Type>live</Type>
                    <OutputProfiles>
                        <HardwareAcceleration>true</HardwareAcceleration>
                        <OutputProfile>
                            <Name>bypass_stream</Name>
                            <OutputStreamName>${OriginStreamName}</OutputStreamName>
                            <Encodes>
                                <Audio>
                                    <Name>bypass_audio</Name>
                                    <Bypass>true</Bypass>
                                </Audio>
                                <Video>
                                    <Name>bypass_video</Name>
                                    <Bypass>true</Bypass>
                                </Video>
                            </Encodes>
                        </OutputProfile>
                    </OutputProfiles>
                    <Providers>
                        <OVT />
                        <WebRTC />
                        <RTMP />
                        <SRT />
                        <MPEGTS>
                            <StreamMap>
                                <Stream>
                                    <Name>stream_${Port}</Name>
                                    <Port>4000</Port>
                                </Stream>
                            </StreamMap>
                        </MPEGTS>
                        <RTSPPull />
                        <WebRTC>
                            <Timeout>30000</Timeout>
                        </WebRTC>
                    </Providers>
                    <Publishers>
                        <AppWorkerCount>1</AppWorkerCount>
                        <StreamWorkerCount>8</StreamWorkerCount>
                        <OVT />
                        <WebRTC>
                            <Timeout>30000</Timeout>
                            <Rtx>false</Rtx>
                            <Ulpfec>false</Ulpfec>
                            <JitterBuffer>false</JitterBuffer>
                        </WebRTC>
                        <LLHLS>
                            <ChunkDuration>0.5</ChunkDuration>
                            <PartHoldBack>1.5</PartHoldBack>
                            <SegmentDuration>2</SegmentDuration>
                            <SegmentCount>10</SegmentCount>
                            <CrossDomains>
                                <Url>*</Url>
                            </CrossDomains>
                            <DVR>
                                <Enable>true</Enable>
                                <TempStoragePath>/data/liveclip/tmp/ome_dvr/</TempStoragePath>
                                <MaxDuration>54000</MaxDuration>
                            </DVR>
                        </LLHLS>
                        <RTMPPush>
                        </RTMPPush>
                        <FILE>
                            <RootPath>/data/liveclip</RootPath>
                            <FilePath>/${VirtualHost}/${Application}/${Stream}/${StartTime:YYYYMMDDhhmmss}_${EndTime:YYYYMMDDhhmmss}.ts</FilePath>
                            <InfoPath>/${VirtualHost}/${Application}/${Stream}.xml</InfoPath>
                        </FILE>
                        <Thumbnail>
                            <CrossDomains>
                                <Url>*</Url>
                            </CrossDomains>
                        </Thumbnail>
                    </Publishers>
                </Application>
            </Applications>
        </VirtualHost>
    </VirtualHosts>
    </Server>
  2. With Encoder ffmpeg simple rtmp stream command

  3. See error

Expected behavior Player on the frontend, such as theoplayer being able to reproduce the playlist (with ffplay it works)

Logs [2023-08-29 09:59:01.196] W [AW-LLHLS0:45] FMP4 Packager | fmp4_storage.cpp:308 | LLHLS stream (reserved) / track (0) - a longer-than-expected (2761.0 | expected : 2000) segment has created. This may be due to very long keyframe intervals.

Player (please complete the following information):

Additional context Is there any possible alternative solution to view the llhls? Or parameters I can tune better for the frontend?

thanks!

Allan-Nava commented 1 year ago

I have the same problem! +1

dimiden commented 1 year ago

@Paxx-RnD @Allan-Nava This may be related to the keyframe interval of the input source. What is the keyframe interval of the encoder you used set to? If it is set to auto or a non-integer value, please set it to 1 or 2 seconds and try again.

Allan-Nava commented 1 year ago

Ok i will try

p4xx07 commented 1 year ago

thanks for the suggestion @dimiden but our stream is already configured with the keyframe interval to 2. Ffplay and vlc work without an issue. It's only on the frontend. I'm also open to consider other solutions.

naanlizard commented 1 year ago

Dvr has been playing back fine for me, more or less, even up to twelve hours. I am using ovenplayer admittedly so maybe try that to see if it’s just theoplayer?

dimiden commented 1 year ago

@Paxx-RnD That log is presumed to have occurred because the m4s file could not be created exactly in 2000 milliseconds. If you encode with libx264, check if the scenecut is used. If the scenecut is not used, the interval you set may not be applied.

Allan-Nava commented 1 year ago

Dvr has been playing back fine for me, more or less, even up to twelve hours. I am using ovenplayer admittedly so maybe try that to see if it’s just theoplayer?

I'm using theoplayer and is downloading the files but is not showing nothing

dimiden commented 1 year ago

@Allan-Nava Could you try to play that URL using OvenPlayer?

Allan-Nava commented 1 year ago

@Allan-Nava Could you try to play that URL using OvenPlayer?

I have problem with CORS, is not enabled this domain

Allan-Nava commented 1 year ago

@Allan-Nava Could you try to play that URL using OvenPlayer?

I have problem with CORS, is not enabled this domain

Is it working enabled the CORS, but very very slow to load the video

getroot commented 1 year ago

@Paxx-RnD The cause of your problem appears to be in THEO. Maybe the player can't handle too many segments list. Your OME log is just a warning and there is no problem playing the stream.

You set the SegmentDuration to 2 seconds, so the list of too many segments might be too long. Try changing it to 10 seconds. In LLHLS, ChunkDuration affects delay, segment length does not. <SegmentDuration>2</SegmentDuration>

getroot commented 1 year ago

@Allan-Nava

Your problem may be something else. If the video is slow to load, you should check several sections.

Encoder -> OME section Transcoding section of OME Network bandwidth of OME and Player