ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.27k stars 628 forks source link

HLS stream not found #1973

Closed iamareebjamal closed 4 years ago

iamareebjamal commented 4 years ago

Describe the bug HLS stream does not start playing because the server throws 404 Not Found for it

To Reproduce Steps to reproduce the behavior:

  1. Go to LiveApp
  2. Click on 'Create new stream'
  3. Start publishing to the stream using RTMP
  4. See Broadcasting status as Broadcasting 1.05x
  5. Click on play button or use the embed code
  6. Observe it says Stream will start playing automatically when it is live
  7. It never starts playing. After debugging, the stream GET requests for all resource options of stream fail with 404 Not Found - m3u8, mp4, adaptive_m3u8
Type Status Report

Message /WebRTCApp/streams/248475541525053093655513.m3u8

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Expected behavior The stream should start playing and server should not throw 404

Additional context

Not sure if it'll help but here are the logs. They clearly mention receiving the stream for the stream ID:

2020-03-23 22:43:10,258 [http-nio2-0.0.0.0-5080-exec-8] INFO  i.a.e.s.WebSocketLocalHandler - Web Socket opened
2020-03-23 22:43:33,417 [Red5_Scheduler_Worker-10] WARN  io.antmedia.muxer.MuxAdaptor - Stream: 405962443156146838883691 does not get packet for 250 ms
2020-03-23 22:43:33,674 [Red5_Scheduler_Worker-10] WARN  io.antmedia.muxer.MuxAdaptor - Stream: 405962443156146838883691 does not get packet for 500 ms
2020-03-23 22:43:33,930 [Red5_Scheduler_Worker-10] WARN  io.antmedia.muxer.MuxAdaptor - Stream: 405962443156146838883691 does not get packet for 750 ms
2020-03-23 22:43:34,186 [Red5_Scheduler_Worker-10] WARN  io.antmedia.muxer.MuxAdaptor - Stream: 405962443156146838883691 does not get packet for 1000 ms
2020-03-23 22:44:10,997 [vert.x-eventloop-thread-2] INFO  i.antmedia.statistic.StatsCollector - -Heartbeat-
2020-03-23 22:45:09,090 [http-nio2-0.0.0.0-5080-exec-6] WARN  org.red5.server.scope.Scope - Requested scope: 405962443156146838883691 is not of IScope type: org.red5.server.scope.BroadcastScope
2020-03-23 22:45:17,197 [http-nio2-0.0.0.0-5080-exec-5] WARN  io.antmedia.rest.RestServiceBase -  endpoint does not exist in this app.
2020-03-23 22:45:29,838 [RTMPConnectionExecutor-1] INFO  o.r.s.stream.ClientBroadcastStream - Checking mux adaptor to stop 405962443156146838883691
2020-03-23 22:45:29,845 [RTMPConnectionExecutor-1] INFO  io.antmedia.muxer.MuxAdaptor - Calling stop for 405962443156146838883691
2020-03-23 22:45:29,846 [RTMPConnectionExecutor-1] INFO  o.r.s.stream.ClientBroadcastStream - Mux Adaptor stop called 405962443156146838883691
2020-03-23 22:45:29,849 [Red5_Scheduler_Worker-12] INFO  io.antmedia.muxer.MuxAdaptor - stop request for stream id : 405962443156146838883691 
2020-03-23 22:45:53,075 [RTMPConnectionExecutor-4] INFO  o.r.s.stream.ClientBroadcastStream - Stream start: 248475541525053093655513
2020-03-23 22:45:53,076 [RTMPConnectionExecutor-4] INFO  i.a.AntMediaApplicationAdapter - stream name in streamPublishStart: 248475541525053093655513
2020-03-23 22:45:53,076 [RTMPConnectionExecutor-4] INFO  i.a.AntMediaApplicationAdapter - start publish leaved
2020-03-23 22:45:53,076 [RTMPConnectionExecutor-4] INFO  i.a.e.streamapp.StreamApplication - W3C x-category:stream x-event:publish c-ip:103.249.76.18 x-sname:eaeae580-3ffc-4e3c-88db-90801a36fc4d x-name:248475541525053093655513
2020-03-23 22:45:53,083 [RTMPConnectionExecutor-4] ERROR io.antmedia.muxer.MuxAdaptor - io.antmedia.enterprise.adaptive.EncoderAdaptor
2020-03-23 22:45:53,096 [vert.x-worker-thread-2] INFO  i.a.AntMediaApplicationAdapter -  Status of stream 248475541525053093655513 is set to Broadcasting with result: true
2020-03-23 22:45:53,096 [RTMPConnectionExecutor-4] INFO  io.antmedia.muxer.MuxAdaptor - adding HLS Muxer for 248475541525053093655513
2020-03-23 22:45:53,097 [RTMPConnectionExecutor-4] INFO  io.antmedia.muxer.HLSMuxer - hls time: 2, hls list size: 5
2020-03-23 22:45:53,097 [RTMPConnectionExecutor-4] INFO  io.antmedia.muxer.MuxAdaptor - Number of items in the queue while adaptor is being started to prepare is 0
2020-03-23 22:45:53,098 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - before prepare for 248475541525053093655513
2020-03-23 22:45:53,098 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - before avformat_open_input for stream 248475541525053093655513
2020-03-23 22:45:53,102 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - Checking streams for stream: 248475541525053093655513
2020-03-23 22:45:53,786 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - Video and Audio is detected in the incoming stream for stream: 248475541525053093655513
2020-03-23 22:45:53,786 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - Streams for 248475541525053093655513 enableVideo:true enableAudio:true total spend time: 684 elapsed frame timestamp: 1 stop request exists: false
2020-03-23 22:45:53,786 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - before avformat_find_stream_info for stream: 248475541525053093655513
2020-03-23 22:45:55,160 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - avformat_find_stream_info takes 1374ms for stream:248475541525053093655513
2020-03-23 22:45:55,161 [Red5_Scheduler_Worker-1] INFO  io.antmedia.muxer.MuxAdaptor - after prepare for 248475541525053093655513

Version: Community Edition 1.9.1 20200112_1622

canat commented 4 years ago

Hello, We need more information to identify and reproduce the problem. I have followed exact same steps that you described and published an RMTP stream using OBS and the HLS stream played successfully in the browser. Which software did you use to publish the stream with RMTP? It can be also related to type or encodecing of the stream which you published. Did you publish directly a video file using ffmpeg or created stream from your camera or screen share using OBS, Wirecast etc?

Best Regards, Can

iamareebjamal commented 4 years ago

I used OBS and tested using a media file and I have been using similar steps in a commercial product (mux.com, dacast.com) and it works fine for both. I tried doing it various times. Let me clarify that I was connecting through 1935 for RTMP and 5080 for HLS, I think that's as expected. Tell me if you need more info

canat commented 4 years ago

Can you follow exactly the same steps in the following guide? https://github.com/ant-media/Ant-Media-Server/wiki/Open-Broadcaster-Software-Publishing and write me the result. For RMTP you dont have to to give a port. The URL for publishing will be like this: rtmp://your_server_domain_name/LiveApp To play m3u8 for my stream, I use following Link http://192.168.1.23:5080/LiveApp/streams/857190862347253083045206.m3u8 And if the problem persists, can you send me the link to the media file you are using for testing?

iamareebjamal commented 4 years ago

For RMTP you dont have to to give a port

For "RTMP", I am confused as to how you don't have to give it a port but I did retry and it seems it defaults to port 1935 so giving it a port if it is already 1935 is a no-op. However, it still didn't work. I doubt that the media file is the problem because it's the API which sends 404 but I'll provide it anyway

https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4

canat commented 4 years ago

VirtualBox_UbuntuVirt_25_03_2020_18_24_06 Yeah the file is fine. It can play the file for me. I use following link to publish rtmp://192.168.1.23/LiveApp from OBS where 192.168.1.23 is ip address of my Ant Media Server Please double check that you are using always using consistently LiveApp but not WebRTCApp in the URLs

iamareebjamal commented 4 years ago

Yes, confirmed it. I'm using LiveApp and the dashboard is also showing me that it is being broadcasted, so it is definitely receiving the steam

canat commented 4 years ago

What happens when you press the Play Stream button in the following screen? Can you send me a screenshot after waiting a little bit? VirtualBox_UbuntuVirt_25_03_2020_18_38_57 To be safe can you start the server again using admistrator role. Maybe it cannot write m3u8 realted files to the disk because it does not have necessary permissions.

canat commented 4 years ago

I checked your logs again, following log suggests that the problem can be related to Play URL. 2020-03-23 22:45:17,197 [http-nio2-0.0.0.0-5080-exec-5] WARN io.antmedia.rest.RestServiceBase - endpoint does not exist in this app. I don't get this warning. Please try everything from start with a different simple stream id and double check the URLs.

Best, Can

iamareebjamal commented 4 years ago

It is installed as a service using the installation script provided in the wiki, so it is running as sudo

Screenshot from 2020-03-25 21-45-09

This is the screenshot.

RestServiceBase - endpoint does not exist in this app. I don't get this warning.

Yes, that's why I wrote in the issue that it is throwing 404 not found.

start with a different simple stream id

Stream ID is autogenerated, right?

and double check the URLs.

I am copying everything from the dashboard, and it is showing broadcasting, OBS is showing LIVE, so how can the URLs be wrong. I am also clicking on the play button in the dashboard itself, so I don't know how can its URL be wrong. I mean both the stream ID and playback URL have the same identifier.

I can give you access to the dashboard. Can you tell me your email?

iamareebjamal commented 4 years ago
2020-03-25 21:43:35,819 [RTMPConnectionExecutor-2] INFO  o.r.s.stream.ClientBroadcastStream - Stream start: 405962443156146838883691
2020-03-25 21:43:35,820 [RTMPConnectionExecutor-2] INFO  i.a.AntMediaApplicationAdapter - stream name in streamPublishStart: 405962443156146838883691
2020-03-25 21:43:35,831 [RTMPConnectionExecutor-2] INFO  i.a.AntMediaApplicationAdapter - start publish leaved
2020-03-25 21:43:35,831 [RTMPConnectionExecutor-2] INFO  i.a.e.streamapp.StreamApplication - W3C x-category:stream x-event:publish c-ip:103.249.76.18 x-sname:de1d1bfb-3c5e-4764-9d38-dea501107609 x-name:405962443156146838883691
2020-03-25 21:43:35,835 [RTMPConnectionExecutor-2] ERROR io.antmedia.muxer.MuxAdaptor - io.antmedia.enterprise.adaptive.EncoderAdaptor
2020-03-25 21:43:35,847 [vert.x-worker-thread-2] INFO  i.a.AntMediaApplicationAdapter -  Status of stream 405962443156146838883691 is set to Broadcasting with result: true
2020-03-25 21:43:35,847 [RTMPConnectionExecutor-2] INFO  io.antmedia.muxer.MuxAdaptor - adding HLS Muxer for 405962443156146838883691
2020-03-25 21:43:35,848 [RTMPConnectionExecutor-2] INFO  io.antmedia.muxer.HLSMuxer - hls time: 2, hls list size: 5
2020-03-25 21:43:35,848 [RTMPConnectionExecutor-2] INFO  io.antmedia.muxer.MuxAdaptor - Number of items in the queue while adaptor is being started to prepare is 0
2020-03-25 21:43:35,849 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - before prepare for 405962443156146838883691
2020-03-25 21:43:35,850 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - before avformat_open_input for stream 405962443156146838883691
2020-03-25 21:43:35,856 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - Checking streams for stream: 405962443156146838883691
2020-03-25 21:43:36,638 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - Video and Audio is detected in the incoming stream for stream: 405962443156146838883691
2020-03-25 21:43:36,638 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - Streams for 405962443156146838883691 enableVideo:true enableAudio:true total spend time: 781 elapsed frame timestamp: 1 stop request exists: false
2020-03-25 21:43:36,638 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - before avformat_find_stream_info for stream: 405962443156146838883691
2020-03-25 21:43:37,921 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - avformat_find_stream_info takes 1283ms for stream:405962443156146838883691
2020-03-25 21:43:38,021 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - after prepare for 405962443156146838883691
2020-03-25 21:43:38,022 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - Number of items in the queue while adaptor is scheduled to process incoming packets is 8
2020-03-25 21:43:38,022 [Red5_Scheduler_Worker-9] INFO  io.antmedia.muxer.MuxAdaptor - Packet Feeder Job Name ScheduledJob_18
2020-03-25 21:43:38,023 [Red5_Scheduler_Worker-10] INFO  io.antmedia.muxer.MuxAdaptor - first packet time 67

Server is showing normal processing for the stream ID 405962443156146838883691

And for the exact same stream ID /LiveApp/streams/405962443156146838883691.m3u8, it is throwing 404

canat commented 4 years ago

No, stream id is not auto generated. You can choose any arbitrary string as stream id and you dont need to create it in the beginning from the management console. It will accept it automatically.

canat commented 4 years ago

My email address is can@antmedia.io. Yeah access to the dashboard would be nice to solve identify the problem.

iamareebjamal commented 4 years ago

I'm not sure if we are talking about the same thing. I only see the option of Stream Name when creating a new Live Stream and the Stream ID is autogenerated, which is seen even here - https://github.com/ant-media/Ant-Media-Server/wiki/Open-Broadcaster-Software-Publishing#3-configure-obs

Stream Key == Stream ID

Anyway, I have sent you the email with dashboard and credentials

canat commented 4 years ago

You dont need to create a new stream in the dashboard. You can just choose arbitrary stream id in OBS and start streaming. Ant Media Server will automatically create a stream for this id and you will see it on the dashboard. Ok, I received the email, I will check.

canat commented 4 years ago

Hi,

As I written per email, I can play your video file that I published to your server with OBS inside your dashboard and in my browser with HLS player extension. I also used the stream id which you used to publish your stream and it did also play successfully. I could not find any problems in your server installation. I stopped publishing to your server now.

Please follow the Wiki Guide I sent you before step by step, also tune for low latency, change bitrate etc. The URL, I used to play my stream from your server, I also sent you per email.

Best, Can

iamareebjamal commented 4 years ago

Hi, some hit and trial and I got it working. Really thankful for your support. However, I think I got a bug due to which all this happened. Instead of closing this, I'll update the issue so that you can look at it. Give me a few minutes to verify it thoroughly

chandrikadevis commented 3 years ago

Hi @iamareebjamal , I have the same issue. kindly update how did you fix this issue

unbranched commented 3 years ago

@canat Same problem here, only difference is that my stream is rtsp and needs auth.

mekya commented 3 years ago

@unbranched @chandrikadevis

could you please let us know some reproduce scenario? It's likely there is a problem in the pipeline or configuration.