Rohit Daid
Rohit Daid

Reputation: 11

Gstreamer -- Unable to link audio when using the hlssink2 sink

I am recording audio with video through gstreamer. I am able to save .ts file using hlssink2. The other components are also working such as multisink, autoaudio and autovideosink but I want to record it live through hlssink2. Hlssink2 is outputting the following error:

erroneous pipeline: could not link mux to hlssink2-0

I know hlssink2 is using internal mux but when I remove mux then other pipeline components get disturbed. My pipeline is as follows:

gst-launch-1.0 rtspsrc location="RTSP URL" latency=0 protocols=tcp name=src src. ! application/x-rtp,media=audio ! rtpjitterbuffer ! decodebin ! audioconvert ! avenc_aac ! flvmux name=mux src. ! rtph264depay ! h264parse config-interval=-1 !  mux. mux. ! hlssink2 location=videotest%05d.ts playlist-location=file.m3u8 max-files=20 target-duration=30

Upvotes: 1

Views: 1377

Answers (1)

Chris Andrew
Chris Andrew

Reputation: 113

Not sure if you arrived on an answer or not, but it looks like you can apply the audio onto the hlssink2 audio pad via:

224premux. ! queue ! h264parse ! queue ! hlssink2 name=224hlssink location=videotest%05d.ts \

Note "name=224hlssink" in this case.

And link via:

encoded_audio. ! queue ! 224hlssink.audio \

Note ".audio" on the sink name.

The following pipeline (which I translated to a Rust program which integrates with gstreamer and encodes files for distribution on the web) illustrates this in whole:

filesrc location=video.mov name=src ! \
decodebin name=decode ! tee name=raw_stream \
decode. ! queue ! audioconvert ! audioresample ! avenc_aac ! tee name=encoded_audio \
raw_stream. ! queue ! videoscale ! 'video/x-raw,width=400,height=224' ! x264enc psy-tune=film pass=qual quantizer=25 speed-preset=slow ! queue ! tee name=224premux \
raw_stream. ! queue ! videoscale ! 'video/x-raw,width=640,height=360' ! x264enc psy-tune=film pass=qual quantizer=25 speed-preset=slow ! queue ! tee name=360premux \
raw_stream. ! queue ! videoscale ! 'video/x-raw,width=960,height=540' ! x264enc psy-tune=film pass=qual quantizer=25 speed-preset=slow ! queue ! tee name=540premux \
raw_stream. ! queue ! videoscale ! 'video/x-raw,width=1280,height=720' ! x264enc psy-tune=film pass=qual quantizer=25 speed-preset=slow ! queue ! tee name=720premux \
raw_stream. ! queue ! videoscale ! 'video/x-raw,width=1920,height=1080' ! x264enc psy-tune=film pass=qual quantizer=25 speed-preset=slow ! queue ! tee name=1080premux \
224premux. ! queue ! mp4mux name=224mux ! filesink async=0 location=video400x224.mp4 \
224premux. ! queue ! h264parse ! queue ! hlssink2 name=224hlssink location=video400x224%05d.ts \
360premux. ! queue ! mp4mux name=360mux ! filesink async=0 location=video640x360.mp4 \
360premux. ! queue ! h264parse ! queue ! hlssink2 name=360hlssink location=video640x360%05d.ts \
540premux. ! queue ! mp4mux name=540mux ! filesink async=0 location=video960x540.mp4 \
540premux. ! queue ! h264parse ! queue ! hlssink2 name=540hlssink location=video960x540%05d.ts \
720premux. ! queue ! mp4mux name=720mux ! filesink async=0 location=video1280x720.mp4 \
720premux. ! queue ! h264parse ! queue ! hlssink2 name=720hlssink location=video1280x720%05d.ts \
1080premux. ! queue ! mp4mux name=1080mux ! filesink async=0 location=video1920x1080.mp4 \
1080premux. ! queue ! h264parse ! queue ! hlssink2 name=1080hlssink location=video1920x1080%05d.ts \
encoded_audio. ! queue ! 224mux. \
encoded_audio. ! queue ! 224hlssink.audio \
encoded_audio. ! queue ! 360mux. \
encoded_audio. ! queue ! 360hlssink.audio \
encoded_audio. ! queue ! 540mux. \
encoded_audio. ! queue ! 540hlssink.audio \
encoded_audio. ! queue ! 720mux. \
encoded_audio. ! queue ! 720hlssink.audio \
encoded_audio. ! queue ! 1080mux. \
encoded_audio. ! queue ! 1080hlssink.audio

In Code you can do something like this (example in rust)

gst::Element::link_pads(&ea_queue_2, Some("src"), &hlssink2, Some("audio"))?;

Which links a queue src pad to a hlssink2 element audio pad, in my case the encoded audio tee of the pipeline.

Upvotes: 4

Related Questions