Gstreamer and hlssink to display over http doesn't work

4.3k views Asked by At

I used the below command using gstreamer. I see the generated files in the root but VLC crashes when I try to open the playlist.m3u8 The main goal is to live stream from webcam on firefox browser.

gst-launch-1.0 ksvideosrc ! decodebin ! videoconvert ! openh264enc ! mpegtsmux ! hlssink playlist-root=localhost location=C:/inetpub/wwwroot/hlssink.%05d.ts playlist-location=C:/inetpub/wwwroot/playlist.m3u8

also the video tag doesn't show the video streaming.

<video width="352" height="198" controls>
    <source src="http://localhost/playlist.m3u8" type="application/x-mpegURL">
</video>

I can't figure out what I am doing wrong here ; any help would be appreciated.

1

There are 1 answers

1
Dusan Kovacevic On

To make this playable in VLC (started on the same machine where your IIS server is) you will need to modify hlssink playlist-root parameter. It should be

... ! hlssink playlist-root=http://localhost ...

This will correctly set prefix URL part of TS segments inside HLS playlist

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:88
#EXT-X-TARGETDURATION:15

#EXTINF:15.026812553405762,
http://localhost/hlssink.00087.ts
#EXTINF:15.006274223327637,
http://localhost/hlssink.00088.ts
#EXTINF:15.011569976806641,
http://localhost/hlssink.00089.ts
#EXTINF:15.020917892456055,
http://localhost/hlssink.00090.ts
#EXTINF:15.016651153564453,
http://localhost/hlssink.00091.ts

and VLC player will know exact URL(s) to download segments from.

Unfortunately, your HLS is not playable by (most of) browsers because implementation of <video> tag does not support MPEG Transport Stream (MPEG TS) media container that your segments are packed in.

To solve this, you can use, for example, hls.js library which will, among other things, transmux MPEGTS segments into MP4 container supported by standard HTML5 <video> tag.