Boke
Boke

Reputation: 85

I want to create a HLS (HTTP Live Streaming) Stream using Gstreamer but Audio only

what I want to do is create an m3u8-file out of an alsa soundcard input.

Like:

arecord  hw:1,0 -d 10 test.wav | gst-launch-1.0 ....

I tried this for testing:

gst-launch-1.0 audiotestsrc ! audioconvert ! audioresample ! hlssink

but it doesn't work.

Thank you for helping.

Upvotes: 1

Views: 3519

Answers (2)

Eduard Grinberg
Eduard Grinberg

Reputation: 337

I could make it work with hlssink2:

gst-launch-1.0 audiotestsrc ! audioconvert ! audioresample ! avenc_aac ! hlssink2 target-duration=5 max-files=5

Upvotes: 0

jgorostegui
jgorostegui

Reputation: 1310

You can’t create directly HLS video transport segments (.ts) from audio raw source. You need to encode it with some encoder and then mux it before sending to hlssink plugin.

One of the problems that you’ll encounter is that the hlssink plugin won’t split the segments with only audio stream so you are going to need something like keyunitsscheduler to split correctly the streams and create the files.

An example pipeline using voaacenc to encode audio and mpegtmux to mux would be as follows:

gst-launch-1.0 audiotestsrc is-live=true ! audioconvert ! voaacenc bitrate=128000 ! aacparse ! audio/mpeg ! queue ! mpegtsmux ! keyunitsscheduler interval=5000000000 ! hlssink playlist-length=5 max-files=10 target-duration=5 playlist-root="http://localhost/hls/" playlist-location="/var/www/html/hls/stream0.m3u8" location="/var/www/html/hls/fragment%05d.ts"

Upvotes: 2

Related Questions