I want to perform HLS (HTTP Live Streaming) using

2020-05-28 23:40发布

问题:

I would like to stream web cam video to http web page. I know how to read from web cam and archive it to file.

But how to stream via web. What is the pipeline for that?

回答1:

Use hlssink element from gst-plugins-bad:

gst-launch-1.0 videotestsrc is-live=true ! x264enc ! mpegtsmux ! hlssink

It will generate playlist and segments files. You need to provide HTTP access to these files, you can use any webserver, nginx or Apache, for example.

You can tweak hlssink's parameters to specify target location, segments count, etc. All options can be listed with:

gst-inspect-1.0 hlssink

If you need better low-level control, you'd better create your own web server with libsoup, manually split MPEG-TS into segments and add your own playlist endpoint.