harlanc / xiu

A simple,high performance and secure live media server in pure Rust (RTMP[cluster]/RTSP/WebRTC[whip/whep]/HTTP-FLV/HLS).🦀
https://www.rustxiu.com
MIT License
1.6k stars 168 forks source link

hls playback 404 not found for rtmp streaming #116

Open SaulMoonves opened 2 months ago

SaulMoonves commented 2 months ago

XIU version v0.12.6

Describe the bug hls m3u8 404 not found

To Reproduce

xiu --rtmp 1935 --rtsp 1554 --hls 8081 -l debug
ffmpeg -re -stream_loop -1 -i test.mp4 -c:a copy -c:v copy -f flv -flvflags no_duration_filesize rtmp://<my-server>:1935/live/test

on the streaming machine:

# curl http://localhost:8081/live/test/test.m3u8
Not Found

However rtmp playback via ffplay does work.

What am I doing wrong?

Expected behavior playback

harlanc commented 2 months ago

The issue can be reproduced using the Docker image environment but not with a locally build because the generation of .ts and .m3u8 files relies on relative paths. Using absolute paths can fix this problem.

SaulMoonves commented 2 months ago

I am having the problem even if it is built from Cargo or if I download a release. I did not try from source though.

harlanc commented 2 months ago

@SaulMoonves

Try to build from this branch https://github.com/harlanc/xiu/tree/fix_116

SaulMoonves commented 2 months ago

It seems to still get not found.

harlanc commented 2 months ago

Could you paste the logs of xiu when playing the hls stream which should contain "m3u8 folder:" and "ts folder:" as follows:

[2024-04-06T22:39:45Z INFO  hls::m3u8] m3u8 folder: /Users/username/github/xiu/target/debug/live/test
[2024-04-06T22:39:45Z INFO  hls::ts] ts folder: /Users/username/github/xiu/target/debug/live/test
suzp1984 commented 2 months ago

check whether below cmd works? ffplay -i http://localhost:8081/live/test/test.m3u8

otherwise, stop the service, then delete ${xiu running folder}/live/test/ directory, then run boot the service again. you need to wait around one ts segment time gap, around 6 ~ 10 seconds, to get first ts segment generated.

I met once the ${xiu running folder}/live/test/ has ts segment, maybe generated before, but no index m3u8 file. After I clean the live/test, and reboot service, hls recovered.

fs8vsx59h commented 2 months ago

I got this issue too

running in powershell:

.\xiu-0.12.5-x86_64-pc-windows-msvc.exe  -r 1935  -f 8888 -s 9999 --log debug

some info:

[2024-04-18T04:58:15Z INFO  streamhub] subscribe:  stream identifier: RTMP - app_name: live, stream_name: test

OBS setting: image

ffplay command:

 ffplay -i http://localhost:8888/live/test/test.flv

httpflv works fine:

Input #0, flv, from 'http://localhost:8888/live/test/test.flv':/0
  Metadata:
    fileSize        : 0
    audiochannels   : 2
    2.1             : false
    3.1             : false
    4.0             : false
    4.1             : false
    5.1             : false
    7.1             : false
    encoder         : obs-output module (libobs version 30.1.2)
  Duration: 00:00:00.00, start: 0.033000, bitrate: N/A
  Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s
  Stream #0:1: Video: hevc (Main), yuv420p(tv, bt709), 1600x900 [SAR 1:1 DAR 16:9], 2560 kb/s, 60 fps, 60 tbr, 1k tbn
   2.99 A-V: -0.012 fd=   5 aq=   19KB vq=  336KB sq=    0B f=0/0

ffplay command:

ffplay -i http://localhost:8888/live/test/test.m3u8

hls 404:

[http @ 0000026278cd3300] HTTP error 404 Not Foundsq=    0B f=0/0
http://localhost:8888/live/test/test.m3u8: Server returned 404 Not Found

The xiu running path generate no index m3u8 and ts (its acctially generated once , but after I delete it , no more ) image

harlanc commented 2 months ago

@fs8vsx59h It seems that you are not using the correct port number, the correct one may be :

ffplay -i http://localhost:9999/live/test/test.m3u8

If the problems persists, try the following step:

Try to build from this branch https://github.com/harlanc/xiu/tree/fix_116
fs8vsx59h commented 2 months ago

@fs8vsx59h 您似乎没有使用正确的端口号,正确的端口号可能是:

ffplay -i http://localhost:9999/live/test/test.m3u8

如果问题仍然存在,请尝试以下步骤:

Try to build from this branch https://github.com/harlanc/xiu/tree/fix_116

sorry for that , I delete the live/test folder and restart , it works now and generate correct index m3u8 I'm trying fix_116 see if this issue fixed