XPModder
XPModder

Reputation: 321

Live video feed from ffmpeg to html with minimum latency

I am currently working on a project that requires me to get live video from a raspberry pi camera and stream it to a html page. At the moment I am using ffmpeg to create *.m3u8 and *.ts files and stream the video that way. In the html page I have hls.js running that receives the video and displays it through a video tag. This does work pretty good, but the latenca is a problem... The video in the browser is always between a few seconds and multiple minutes late. This is not really acceptable.

I am currently using the following command to run ffmpeg:

ffmpeg -loglevel quiet -y -i - -c:v copy -preset veryfast -hls_wrap 2 -hls_time 1 -g 1 stream.m3u8

I have also tried other values for -hls_time and -g including values between 0 and 1.

I am now searching for an alternative solution, that does not have this problem, or a way to reduce the latency to at least 2 seconds max. The video itself is transferred in to ffmpeg as h264. The html webpage is hosted on the same raspberry pi using apache2.

Is there a way to accomplish that without installing a seperate streaming server on the pi?

Also this all has to work without a internet connection. Meaning the pi and the smartphone/computer that is viewing the html page are on the same wifi, but that wifi does not always have a connection to the internet and does not need to have one.

So basically I want to have h264 video into ffmpeg and then somehow into html tag. The stream should also be accessable in another way, as I have a button on the page that should start and stop the recording of the stream to an mp4 file. This recording is also done using ffmpeg at the moment.

I am asking this here and not on the raspberry pi stackexchange forum, because it is a general problem and the problem itself does not have anythingto do with the raspberry pi.

Upvotes: 0

Views: 1532

Answers (1)

szatmary
szatmary

Reputation: 31101

No. There is currently no widely deployed standard for low latency HLS. The Apple standard has only very recently been finalized, and it’s not yet available on Apple devices. And there has not been enough time to implement it into ffmpeg or players.

There are some custom solutions that have been developed, But none are open source or freely available.

What you have now is the best you can do without writing a ton of code.

Upvotes: 1

Related Questions