Add example usage
This commit is contained in:
parent
6024a7fed4
commit
9c4e5e5f4b
2 changed files with 41 additions and 0 deletions
30
README.md
30
README.md
|
@ -11,3 +11,33 @@ Progress:
|
|||
- [x] Write HLS playlist m3u8 file;
|
||||
- [ ] Signal to acquire segment stream;
|
||||
- [ ] Signal to acquire HLS playlist stream;
|
||||
|
||||
## Example Usage
|
||||
|
||||
After [installing GStreamer](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#installation)
|
||||
, it is possible to compile and run the `flexhlsplugin`.
|
||||
|
||||
```bash
|
||||
cargo build
|
||||
```
|
||||
|
||||
Under MacOS it might be necessary to set the `PKG_CONFIG_PATH` environment variable:
|
||||
```
|
||||
export PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/Current/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
||||
```
|
||||
|
||||
An example pipeline:
|
||||
```
|
||||
export PROJECT_DIR=`pwd`
|
||||
gst-launch-1.0 videotestsrc is-live=true ! \
|
||||
x264enc ! h264parse ! flexhlssink target-duration=4 \
|
||||
--gst-plugin-load=${PROJECT_DIR}/target/debug/libflexhlssink.dylib
|
||||
```
|
||||
|
||||
In another terminal run a simple HTTP server:
|
||||
```
|
||||
cd $PROJECT_DIR
|
||||
python simple_http.py
|
||||
```
|
||||
|
||||
Open the example player site https://hls-js.netlify.app/demo/ and play the `http://localhost:8000/playlist.m3u8` playback URL.
|
11
simple_http.py
Normal file
11
simple_http.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
|
||||
import sys
|
||||
|
||||
class CORSRequestHandler(SimpleHTTPRequestHandler):
|
||||
def end_headers(self):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
SimpleHTTPRequestHandler.end_headers(self)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
|
Loading…
Reference in a new issue