Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream (m3u8 format) cannot be played on iOS devices #24

Closed
gongzhang opened this issue May 19, 2019 · 3 comments
Closed

Stream (m3u8 format) cannot be played on iOS devices #24

gongzhang opened this issue May 19, 2019 · 3 comments

Comments

@gongzhang
Copy link

gongzhang commented May 19, 2019

Hi, I created a HLS video on my Raspberry Pi Zero W by this command:

# http://<raspi-address>:8000/camera/livestream.m3u8
raspi-live start -w 640 -h 360 -p 8000

And I wrote a simple static web page and served it by python3 -m http.server 80:

<!DOCTYPE html>
<!-- index.html -->
<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <video src="http://localhost:8000/camera/livestream.m3u8" width="400" height="300"></video>
  </body>
</html>

I found that the video cannot be played in Safari on iPhone and iPad. I confirmed that the iOS version Safari supports HLS (m3u8) indeed and I tested the following sample video:

<!-- this sample video is ok on iOS-->
<video src="http://delta-media.mediasocial.tv.s3.amazonaws.com/Videos/348/ios.m3u8" ...

So there must be something wrong. Maybe incorrect ffmpeg command?

@jaredpetersen
Copy link
Owner

@gongzhang

I suspect that raspi-live is working but that there's some sort of issue with how you're trying to play the video. Since you mentioned Safari and iOS, I'm assuming you're trying to do playback on another device. In that case, you can't provide localhost as an address. If you do, the browser will read your HTML and look at localhost on the machine running the browser rather than the local networking environment of the raspberry pi.

If you open up the developer tools in your browser, you should be able to see that your browser can't even download the livestream.m3u8 file at all because there's nothing serving that file on the browser machine's localhost.

Try using the IP address of the raspberry pi instead of localhost in your HTML file, e.g. http://78.16.253.91:8000/camera/livestream.m3u8.

@gongzhang
Copy link
Author

Thank you for your quick reply 😊
Sorry for the localhost. It misleads the problem. You can assume that I have correct IP address pointing to raspi in that web page.
iOS Safari does not recognize the stream for some reason. I will debug it using browser inspector later.

@jaredpetersen
Copy link
Owner

Hmm... Okay.

Assuming the IP address is good to go, the next thing I would try is to remove the python server entirely from the equation. Safari can support playback without having the <video> tag at all by just pasting in the URL directly, e.g. http://78.16.253.91:8000/camera/livestream.m3u8.

If that doesn't work but it downloads the file correctly, please paste the contents of the m3u8 file and screenshots of anything you see in the browser inspector (console logs, network waterfall, etc.). Also share whatever log output that raspi-live gives out.

I've tested raspi-live's streaming files with Safari before but haven't had any issues. I suspect it's a network problem but could be wrong. The logs and screenshots will help make that more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants