AirenSoft / OvenMediaEngine

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

Help needed to add rtsp pull stream. #642

Closed anand-010 closed 2 years ago

anand-010 commented 2 years ago

I am new to oven media engine and i have followed this guide to add cctv rtsp stream to oven media engine. I have added

<VirtualHost>
            <Name>default</Name>

            <Domain>
                <Names>
                    <Name>*</Name>
                </Names>
            </Domain>

            <Origins>
                <Origin>
                    <Location>/app_name/rtsp_stream_name</Location>
                    <Pass>
                        <Scheme>rtsp</Scheme>
                        <Urls><Url>192.168.0.200:554/</Url></Urls>
                    </Pass>
                </Origin>
            </Origins>
        </VirtualHost>

to /var/lib/docker/volumes/ome-origin-conf/_data/Server.xml. And i have got error.

[2022-01-19 13:52:44.825] E [OvenMediaEngine:1] OvenMediaEngine | main.cpp:264  | An error occurred while load config: [Config] Unknown item found: Server.VirtualHosts.VirtualHost.Domain in origin_conf/Server.xml
[2022-01-19 13:52:47.576] I [OvenMediaEngine:1] Config | config_manager.cpp:273  | Trying to set logfile in directory... (/var/log/ovenmediaengine)
[2022-01-19 13:52:47.576] I [OvenMediaEngine:1] Config | config_manager.cpp:295  | Trying to load configurations... (origin_conf/Server.xml)
[2022-01-19 13:52:47.606] E [OvenMediaEngine:1] OvenMediaEngine | main.cpp:264  | An error occurred while load config: [Config] Unknown item found: Server.VirtualHosts.VirtualHost.Domain in origin_conf/Server.xml

I have tried to change name but the same result. Please help me i am tring to stream rtsp to webrtc.

getroot commented 2 years ago

Oh sorry, that's a setting that changed a long time ago. That part of the document has not been updated. So I just updated the documentation.

It is better to refer to the following file for setting examples.

https://github.com/AirenSoft/OvenMediaEngine/blob/master/misc/conf_examples/Server.xml

anand-010 commented 2 years ago

I have added new virtual host myhost, added rtsp origin urls like on the documentations. and copied the default applications session and changed name. Here is the new error that i have got.

[2022-01-19 17:08:04.678] E [SPRtcSig-T3333:11] Orchestrator | orchestrator.cpp:616  | Could not find Origin for the stream: [#default#cctv/stream]
[2022-01-19 17:08:04.678] E [SPRtcSig-T3333:11] WebRTC Publisher | webrtc_publisher.cpp:486  | Cannot find stream (#default#cctv/stream)
[2022-01-19 17:08:04.678] E [SPRtcSig-T3333:11] Signalling | rtc_signalling_server.cpp:323  | Cannot find stream [#default#cctv/stream]
[2022-01-19 17:08:04.680] I [SPRtcSig-T3333:11] Signalling | rtc_signalling_server.cpp:366  | Client is disconnected: <WebSocketClient: 0x7f8801f0d0, <ClientSocket: 0x7f900011a0, #22, Closed, TCP, Nonblocking, 192.168.1.20:49327>> (#default#cctv / stream, ufrag: local: (N/A), remote: (N/A))
getroot commented 2 years ago

Did you set /cctv/stream in <Origin><Location>? Did you make an application named cctv?

I recommend that you upload your entire Server.xml and ovenmediaengine.log files. And you need to tell us what you used as the webrtc play url. You need to provide as much information as possible so someone can help you.

anand-010 commented 2 years ago

location is the steam name. I am sorry i don't get that. I thought it's part of the url.

anand-010 commented 2 years ago

Here is my new Server.xml.

<VirtualHost>
    <Name>default</Name>
    <Origins>
        <Properties>
            <NoInputFailoverTimeout>3000</NoInputFailoverTimeout>
            <UnusedStreamDeletionTimeout>60000</UnusedStreamDeletionTimeout>
        </Properties>
        <Origin>
            <Location>/mycctv</Location>
            <Pass>
                <Scheme>rtsp</Scheme>
                <Urls>
                    <Url>username:pass192.168.1.x:554/Streaming/Channels/101/</Url>
                </Urls>
            </Pass>
        </Origin>
    </Origins>
            ......
    <Applications>
        <Application>
            <Name>cctv</Name>
            <!-- Application type (live/vod) -->
            <Type>live</Type>
            <OutputProfiles>
                <OutputProfile>
                    <Name>bypass_stream</Name>
                    <OutputStreamName>${OriginStreamName}</OutputStreamName>
                    <Encodes>
                        <Audio>
                            <Bypass>true</Bypass>
                        </Audio>
                        <Video>
                            <Bypass>true</Bypass>
                        </Video>
                        <Audio>
                            <Codec>opus</Codec>
                            <Bitrate>128000</Bitrate>
                            <Samplerate>48000</Samplerate>
                            <Channel>2</Channel>
                        </Audio>
                    </Encodes>
                </OutputProfile>
            </OutputProfiles>
            <Providers>
                <OVT />
                <WebRTC />
                <RTMP />
                <SRT />
                <RTSPPull />
                <MPEGTS>
                    <StreamMap>
                        <!--
                                    Set the stream name of the client connected to the port to "stream_${Port}"
                                    For example, if a client connets to port 4000, OME creates a "stream_4000" stream
                                    <Stream>
                                        <Name>stream_${Port}</Name>
                                        <Port>4000,4001-4004</Port>
                                    </Stream>
                                    <Stream>
                                        <Name>stream_4005</Name>
                                        <Port>4005</Port>
                                    </Stream>
                                -->
                        <Stream>
                            <Name>stream_${Port}</Name>
                            <Port>4000</Port>
                        </Stream>
                    </StreamMap>
                </MPEGTS>
            </Providers>
            <Publishers>
                <AppWorkerCount>1</AppWorkerCount>
                <StreamWorkerCount>8</StreamWorkerCount>
                <OVT />
                <WebRTC>
                    <Timeout>30000</Timeout>
                    <Rtx>false</Rtx>
                    <Ulpfec>false</Ulpfec>
                    <JitterBuffer>false</JitterBuffer>
                </WebRTC>
                <HLS>
                    <SegmentDuration>5</SegmentDuration>
                    <SegmentCount>3</SegmentCount>
                    <CrossDomains>
                        <Url>*</Url>
                    </CrossDomains>
                </HLS>
                <DASH>
                    <SegmentDuration>5</SegmentDuration>
                    <SegmentCount>3</SegmentCount>
                    <CrossDomains>
                        <Url>*</Url>
                    </CrossDomains>
                    <UTCTiming />
                </DASH>
                <LLDASH>
                    <SegmentDuration>5</SegmentDuration>
                    <CrossDomains>
                        <Url>*</Url>
                    </CrossDomains>
                    <UTCTiming />
                </LLDASH>
            </Publishers>
        </Application>
    </Applications>
</VirtualHost>

and i am tried to access it with ws://192.168.1.47:3333/cctv/mycctv. And i have got error.

[2022-01-20 03:19:50.454] E [SPRtcSig-T3333:11] Orchestrator | orchestrator.cpp:616  | Could not find Origin for the stream: [#default#cctv/mycctv]
[2022-01-20 03:19:50.454] E [SPRtcSig-T3333:11] WebRTC Publisher | webrtc_publisher.cpp:486  | Cannot find stream (#default#cctv/mycctv)
[2022-01-20 03:19:50.454] E [SPRtcSig-T3333:11] Signalling | rtc_signalling_server.cpp:323  | Cannot find stream [#default#cctv/mycctv]
[2022-01-20 03:19:50.455] I [SPRtcSig-T3333:11] Signalling | rtc_signalling_server.cpp:366  | Client is disconnected: <WebSocketClient: 0x7f9802fcb0, <ClientSocket: 0x7f98001130, #22, Closed, TCP, Nonblocking, 192.168.1.47:60650>> (#default#cctv / mycctv, ufrag: local: (N/A), remote: (N/A))

I am also tried to change location to /cctv/mycctv which has the same result.

getroot commented 2 years ago

Change

<Location>/mycctv</Location>

to

<Location>/cctv/mycctv</Location>

https://airensoft.gitbook.io/ovenmediaengine/origin-edge-clustering#edge

getroot commented 2 years ago

And your <VirtualHost> has not <Host><Names>

getroot commented 2 years ago

Again, please upload the entire Server.xml file. Your VirtualHost settings may be wrong.

anand-010 commented 2 years ago
/cctv/mycctv

same result I am only shared the relevent parts. Here is the complete server.xml

getroot commented 2 years ago

I tested it with the same settings as you and found it to work. What version of OvenMediaEnigne are you using? Did you restart the server after changing the settings?

If you upload the entire ovenmediaengine.log file, I will take a closer look.

anand-010 commented 2 years ago

I've build this repo for arm64 on an aws instance. I am build the master branch not the release branch may be tha's the problem. Yes i have restart it after every changes. where is ovenmediaengine.log located is it the container log ?.

getroot commented 2 years ago

There are logs in /var/log/ovenmedianengine/ of container

anand-010 commented 2 years ago

ovenmediaengine.log There is lots of [2022-01-19 12:42:50.795] W [Decaac:42] Transcoder | transcoder_filter.cpp:94 | Timestamp has changed abnormally. 185752 -> 208971

anand-010 commented 2 years ago

Here is the thing the username and password i have passed to the url not called. Rtsp server(rtsp://192.168.1.64:554/Streaming/Channels/101/) rejected the describe request : 401(Unauthorized)

getroot commented 2 years ago

ovenmediaengine.log There is lots of [2022-01-19 12:42:50.795] W [Decaac:42] Transcoder | transcoder_filter.cpp:94 | Timestamp has changed abnormally. 185752 -> 208971

What encoder do you use for RTMP transmission? It seems the encoder timestamp is wrong.

/cctv/mycctv same result I am only shared the relevent parts. Here is the complete server.xml

Here is the thing the username and password i have passed to the url not called. Rtsp server(rtsp://192.168.1.64:554/Streaming/Channels/101/) rejected the describe request : 401(Unauthorized)

You said /cctv/mycctv same result. So I was confused and asked if you tried to restart the server. Anyway OME doesn't support rtsp auth yet.

https://github.com/AirenSoft/OvenMediaEngine/issues/443

Try turning off the auth of the RTSP server.

anand-010 commented 2 years ago

after turned of authentication i have get this error.

[2022-01-20 05:23:43.139] E [OvenMediaEngine:1] MpegtsProvider | mpegts_provider.cpp:179  | The #default#cctv application could not be created in MPEGTSProvider provider because port 4000 requested to be assigned to mpegts is not available.
[2022-01-20 05:23:43.139] I [OvenMediaEngine:1] Provider | application.cpp:46   | SrtProvider has created [#default#cctv] application
[2022-01-20 05:23:43.139] I [OvenMediaEngine:1] Provider | application.cpp:46   | RTMPProvider has created [#default#cctv] application
[2022-01-20 05:23:43.140] I [OvenMediaEngine:1] Provider | application.cpp:46   | OVTProvider has created [#default#cctv] application
[2022-01-20 05:23:43.140] I [OvenMediaEngine:1] Provider | application.cpp:46   | RTSPCProvider has created [#default#cctv] application
[2022-01-20 05:23:43.141] I [OvenMediaEngine:1] APIServer | api_server.cpp:226  | API Server is disabled
[2022-01-20 05:23:44.080] I [SPRtcSig-T3333:11] Signalling | rtc_signalling_server.cpp:232  | New client is connected: <ClientSocket: 0x7fa4001130, #22, Connected, TCP, Nonblocking, 192.168.1.47:48948>
[2022-01-20 05:23:44.135] I [SPRtcSig-T3333:11] Orchestrator | orchestrator.cpp:682  | Trying to pull stream [#default#cctv/mycctv] from provider using origin map: PullProvider
[2022-01-20 05:23:44.158] C [SPRtcSig-T3333:11] OvenMediaEngine | signals.cpp:114  | OME received signal 11 (SIGSEGV), interrupt.

ovenmediaengine.log It's not working yet.

getroot commented 2 years ago

It looks like OME has a compatibility issue with your RTSP server. Can you provide the public IP address of your RTSP server? support@airensoft.com

anand-010 commented 2 years ago

I have also tried to use the wowza link.

wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4

it looks live timeout error.

[2022-01-20 06:49:56.486] W [StreamCollector:50] Provider | application.cpp:93   | #default#cctv/mycctv(100) stream will be deleted because it hasn't been used for 60561 milliseconds
[2022-01-20 06:49:56.486] I [StreamCollector:50] Provider | stream_motor.cpp:165  | #default#cctv/mycctv(100) stream has deleted from 0 StreamMotor
[2022-01-20 06:49:59.487] E [StreamCollector:50] RtspcStream | rtspc_stream.cpp:587  | No response(CSeq : 4) was received from the rtsp server(rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4)
[2022-01-20 06:49:59.487] I [StreamCollector:50] Provider | stream.cpp:60   | #default#cctv/mycctv(100) has been stopped playing stream
[2022-01-20 06:49:59.550] I [StreamCollector:50] Provider | application.cpp:172  | #default#cctv application has deleted 0 stream motor
[2022-01-20 06:49:59.550] I [StreamCollector:50] MediaRouter | mediarouter_application.cpp:466  | Trying to delete a stream: [#default#cctv/mycctv(100)]
[2022-01-20 06:49:59.550] I [StreamCollector:50] Monitor | application_metrics.cpp:69   | Delete StreamMetrics(mycctv/a37cca3f-061b-4210-ae7b-3bb741a6ee53/default/#default#cctv/mycctv/i) for monitoring
[2022-01-20 06:49:59.550] I [StreamCollector:50] Monitor | stream_metrics.cpp:31   | 
[Stream Info]
id(100), msid(0), output(mycctv), SourceType(RtspPull), Created Time (Thu Jan 20 06:48:54 2022) UUID(a37cca3f-061b-4210-ae7b-3bb741a6ee53/default/#default#cctv/mycctv/i)

    Audio Track #0: Bypass(false) Bitrate(0b) codec(6, AAC) samplerate(0) format(none, 0) channel(stereo, 2) timebase(1/12000)
    Video Track #2: Bypass(false) Bitrate(0b) codec(1, H264) resolution(0x0) framerate(0.00fps) timebase(1/90000)
    Elapsed time to connect to origin server : 0 ms
    Elapsed time to subscribe to origin server : 0 ms

    >> Statistics
    Last update time : Thu Jan 20 06:49:59 2022, Last sent time : Thu Jan 20 06:48:55 2022
    Bytes in : 792.67KB, Bytes out : 0B, Concurrent connections : 0, Max connections : 0 (Thu Jan 20 06:48:55 2022)

        >>>> By publisher
        - Unknown : Bytes out(0B) Concurrent Connections (0)
        - WebRTC : Bytes out(0B) Concurrent Connections (0)
        - RTMP : Bytes out(0B) Concurrent Connections (0)
        - RTMPPush : Bytes out(0B) Concurrent Connections (0)
        - HLS : Bytes out(0B) Concurrent Connections (0)
        - DASH : Bytes out(0B) Concurrent Connections (0)
        - LLDASH : Bytes out(0B) Concurrent Connections (0)
        - OVT : Bytes out(0B) Concurrent Connections (0)
        - File : Bytes out(0B) Concurrent Connections (0)
        - Thumbnail : Bytes out(0B) Concurrent Connections (0)

[2022-01-20 06:49:59.551] I [StreamCollector:50] Transcoder | transcoder_stream.cpp:1377 | [#default#cctv/mycctv(100)] -> [#default#cctv/mycctv(424645664)] Transcoder output stream has been deleted.
[2022-01-20 06:49:59.551] I [StreamCollector:50] MediaRouter | mediarouter_application.cpp:466  | Trying to delete a stream: [#default#cctv/mycctv(424645664)]
[2022-01-20 06:49:59.551] I [StreamCollector:50] Monitor | application_metrics.cpp:69   | Delete StreamMetrics(mycctv/a37cca3f-061b-4210-ae7b-3bb741a6ee53/default/#default#cctv/mycctv/o) for monitoring
[2022-01-20 06:49:59.551] I [StreamCollector:50] Monitor | stream_metrics.cpp:31   | 
[Stream Info]
id(424645664), msid(0), output(mycctv), SourceType(Transcoder), Created Time (Thu Jan 20 06:48:55 2022) UUID(a37cca3f-061b-4210-ae7b-3bb741a6ee53/default/#default#cctv/mycctv/o)
    >> Origin Stream Info
    id(100), output(mycctv), SourceType(RtspPull), Created Time (Thu Jan 20 06:48:54 2022)

    Audio Track #0: Bypass(true) Bitrate(0b) codec(6, AAC) samplerate(12.0K) format(none, 0) channel(stereo, 2) timebase(1/12000)
    Audio Track #1: Bypass(false) Bitrate(128.00Kb) codec(8, OPUS) samplerate(48.0K) format(none, 0) channel(stereo, 2) timebase(1/48000)
    Video Track #2: Bypass(true) Bitrate(0b) codec(1, H264) resolution(0x0) framerate(0.00fps) timebase(1/90000)

    >> Statistics
    Last update time : Thu Jan 20 06:48:55 2022, Last sent time : Thu Jan 20 06:48:55 2022
    Bytes in : 0B, Bytes out : 0B, Concurrent connections : 0, Max connections : 0 (Thu Jan 20 06:48:55 2022)

        >>>> By publisher
        - Unknown : Bytes out(0B) Concurrent Connections (0)
        - WebRTC : Bytes out(0B) Concurrent Connections (0)
        - RTMP : Bytes out(0B) Concurrent Connections (0)
        - RTMPPush : Bytes out(0B) Concurrent Connections (0)
        - HLS : Bytes out(0B) Concurrent Connections (0)
        - DASH : Bytes out(0B) Concurrent Connections (0)
        - LLDASH : Bytes out(0B) Concurrent Connections (0)
        - OVT : Bytes out(0B) Concurrent Connections (0)
        - File : Bytes out(0B) Concurrent Connections (0)
        - Thumbnail : Bytes out(0B) Concurrent Connections (0)
getroot commented 2 years ago

This isn't a bug, it's a feature that automatically deletes a stream if no player is playing that stream. And don't pull VoD (I haven't tested this), try RTSP Live on Wowza.

getroot commented 2 years ago

https://airensoft.gitbook.io/ovenmediaengine/origin-edge-clustering#less-than-properties-greater-than

See theUnusedStreamDeletionTimeoutoption

anand-010 commented 2 years ago

I have used this android application to create rtsp stream. And it worked.

anand-010 commented 2 years ago

My device has no power to transcode the live streams is it possible to stream the same input without transcoding.

getroot commented 2 years ago

https://airensoft.gitbook.io/ovenmediaengine/transcoding#bypass-without-transcoding

anand-010 commented 2 years ago

My rtsp stream working without frame drops in vlc. but while using oven media engine , oven media player with webrtc framerate is 1 in 5 sec. According to the above link it doen't usess a transcoder. Why it has too much framedrop. While using rtmp push no framedrop happens. Here is my Server.xml. Server.txt

Keukhan commented 2 years ago

@anand-010

Perhaps your rtsp stream contains b-frame. In a web browser, Webrtc players do not support streams containing b-frame. The solution is to remove the b-frame option from your rtsp stream or use live transcoding in OME.

Thanks.

anand-010 commented 2 years ago

This is a good repo with superfast responses. Thank you for creating it. Hoping that rtsp pull authentication problem solve soon.

getroot commented 2 years ago

I have implemented the RTSP Auth (Basic, Digest) function. https://github.com/AirenSoft/OvenMediaEngine/commit/ea0f64df618c0955550301e1d862e270066db71f

This function can be used as below.

<Origins>
    <Properties>
        <NoInputFailoverTimeout>3000</NoInputFailoverTimeout>
        <UnusedStreamDeletionTimeout>3000</UnusedStreamDeletionTimeout>
    </Properties>
    <Origin>
        <Location>/app/stream</Location>
        <Pass>
            <Scheme>rtsp</Scheme>
            <Urls>
                <Url>airen:airen@192.168.0.160:8554/app/stream</Url>
            </Urls>
        </Pass>
    </Origin>
</Origins>

Please check if it works well, and let me know if there are any problems!