Search code examples
gstreamerhttp-live-streaminggstreamer-1.0gst-launch-1.0

Gstreamer HLSSink Pipeline Displays Black Frames in Safari


This get-launch-1.0 command line pipeline: gst-launch-1.0 videotestsrc num-buffers=680 ! x264enc ! mpegtsmux ! hlssink location=junk2.%05d.ts playlist-location=junk2.m3u8

This server: python -m SimpleHTTPServer 8000

This local url on Mac OS X Safari: http://localhost:8000/junk2.m3u8

Appears to play in local Safari browser, but displays black frames. Why?

Note: python console output looks pretty happy, so all the paths are correct:

$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [25/Apr/2018 11:40:34] "GET /junk2.m3u8 HTTP/1.1" 200 -
127.0.0.1 - - [25/Apr/2018 11:40:34] "GET /junk2.m3u8 HTTP/1.1" 200 -
127.0.0.1 - - [25/Apr/2018 11:40:34] "GET /junk2.00001.ts HTTP/1.1" 200 -
127.0.0.1 - - [25/Apr/2018 11:40:34] "GET /junk2.00000.ts HTTP/1.1" 200 -

Note: Also tried various options to the hlssink plugin without changes in behavior:

  • target-duration=2
  • max-files=0
  • playlist-length=0

Other Players: Plays and displays correctly in VLC: VLC Playback


Solution

  • Your x264enc selects the wrong profile. If you don't tell it what to use and in your use case with videotestsrc it will select a 4:4:4 color profile instead of 4:2:0. A lot of decoders don't support this.

    Tell videotestsrc to feed a 4:2:0 format instead:

    gst-launch-1.0 videotestsrc num-buffers=680 ! video/x-raw, format=I420 ! x264enc ! mpegtsmux ! hlssink location=junk2.%05d.ts playlist-location=junk2.m3u8