Stream HLS but with HEVC CODEC? How Do I Set It Up?

Mark Weiss

Member
Now that I learned that OBS supports HLS, I want to try streaming lower bitrate HEVC to my server.

Context:
I've been streaming to nginx up til now and it works, but it's h.264 and I must use a relatively high 1900 kbs to get a good 1080P picture. In the interest of reaching Japan and also mobile devices on 2G/3G speeds, I wish to drop my bitrate to 512kbs or lower, this requires HEVC CODEC to maintain quality.

Referencing this article:

So far, I've set up the HLS streaming and it is working with the libh.264 option. I've experimented with the HEVC options, but I get audio only and a black screen. I'm not sure if I must change something in the viewer code, particularly this line: type="application/vnd.apple.mpegurl in order to make the video portion work. I think I'm on the cusp of solving this, but there are some stumbling blocks to solve.
 

rockbottom

Active Member

Module ngx_http_hls_module​

The ngx_http_hls_module module provides HTTP Live Streaming (HLS) server-side support for MP4 and MOV media files. Such files typically have the .mp4, .m4v, .m4a, .mov, or .qt filename extensions. The module supports H.264 video codec, AAC and MP3 audio codecs.

For each media file, two URIs are supported:


  • A playlist URI with the “.m3u8” filename extension. The URI can accept optional arguments:
    • “start” and “end” define playlist boundaries in seconds (1.9.0).
    • “offset” shifts an initial playback position to the time offset in seconds (1.9.0). A positive value sets a time offset from the beginning of the playlist. A negative value sets a time offset from the end of the last fragment in the playlist.
    • “len” defines the fragment length in seconds.
  • A fragment URI with the “.ts” filename extension. The URI can accept optional arguments:
    • “start” and “end” define fragment boundaries in seconds.





This module is available as part of our commercial subscription.
 

Mark Weiss

Member
Looks like they are releasing Windows versions soon.
I'll look into this. Hopefully it won't be as difficult to setup as nginx was.

Interestingly, I am testing HLS streaming from OBS. Two observations:

The stream at 512kbps looks almost as good as the former RTMP stream at 1900 kbps. I wonder if some quality loss was the result of the data being repackaged by nginx on my server?

The CPU utilization for the standard h.264 CODEC is more than double what it was with RTMP using quicksync h.264 (iGPU). I could not find a hardware GPU CODEC for the HLS streaming mode of OBS. Otherwise, this looks halfway decent now. But if I could utilize HEVC, I might be able to go as low as 256kbps for my 1080P stream. Anybody, even in the most underdeveloped parts of the world can play a stream of that low bitrate.
 

rockbottom

Active Member
I use MistServer v2.18.1, no need to wait for v3.x. It's already been about 2 years & it will probably be another 2 years before it's released.

But they may have trouble with the CODEC..
 

Mark Weiss

Member
If I had the $$$ for a CDN, I wouldn't be doing this. I don't have corporate deep pockets. I'm retired on a fixed income and can barely afford to eat, much less pay for additional internet services.

MistServer 2.18.1 handles HEVC streaming, yes/no?
 

Mark Weiss

Member
And they shut down your stream within MINUTES if they detect "copyright" or the censors don't agree with your politics.
Youtube banned me for 183 days in 2018 April on my very FIRST live stream. Why? Because I had a small TV in the background, no audio, just a visible picture. So nope. I don't do corporate controlled CDNs anymore.
 

rockbottom

Active Member
Of course they do but then you never mentioned that you're breaking the law & streaming copyrighted material. Don't do the crime if you can't do the time or afford a damn good attorney. Penalties/fines are really stiff, just sayin.
 

Mark Weiss

Member
I never cared about the "law". I just don't want my stream shut off for no good reason (and there are no good reasons, IMHO). So I do it myself. I can discuss whatever I want, run whatever music I want, and the server just streams it. No politics. No lawyers. No censors.

Now, back to topic, I see there is no hardware encoding when using HLS. My CPU usage is triple without using iGPU. Need to solve that. Or maybe an upcoming version of OBS will add that functionality?
 

Mark Weiss

Member
I've been reserving my RTX card for AI and 3D rendering. The intel iGPU has been ideal for OBS RTMP streaming. I like to make use of unused resources as it improves overall throughput.
I did try the NVENC h.264 on the custom output but the browser could not play it. There was a media error.
 

rockbottom

Active Member
It's working fine here. OBS v30

1701017036632.png

1701017652818.png
 
Last edited:

Mark Weiss

Member
These are my CODEC choices. Maybe I'll try upgrading to v30 and see what happens. Is it a safe upgrade (won't break my plugins?)

1701018190342.png
 

rockbottom

Active Member
Since QSV isn't available in the Custom Output & you don't want to use your Nvidia GPU, I think your best option is to update to v30 & install the multi-rtmp output. QSV H265 is now available to use in that plug-in & the newest version even has a frame-rate adjustment setting that may prove useful for those extremely low bit-rates. Further testing is needed to see if it'll actually work....


 

rockbottom

Active Member
I ran a few quick tests with H265 on the multi output. It looks like it may work but only if OBS is running on the iGPU. If you leave it running on the Nvidia GPU, the multi out will fall-back to the old QSV & there's no H265, see below. Anyway, I'm done testing since I will never stream H265.

Worse case, use H264 & lower the frame-rate/resolution.

13:36:41.069: >>> app not on intel GPU, fall back to old qsv encoder
13:36:41.069: [qsv encoder: 'multi-rtmp-venc2615121047'] settings:
13:36:41.069: codec: HEVC
13:36:41.069: rate_control: CBR
13:36:41.069: target_bitrate: 5000
13:36:41.069: Lookahead Depth:60
13:36:41.069: target_usage: TU3
13:36:41.069: profile: high
13:36:41.069: keyint: 1
13:36:41.069: latency: normal
13:36:41.069: b-frames: 0
13:36:41.069: enhancements: off
13:36:41.069: fps_num: 60
13:36:41.069: fps_den: 1
13:36:41.069: width: 1920
13:36:41.069: height: 1080
13:36:41.069: [qsv encoder: 'multi-rtmp-venc2615121047'] debug info:
13:36:41.162: surf: Texture
13:36:41.339: m_nSurfNum: 9
13:36:41.355: m_nTaskPool: 4
13:36:41.355: major: 2
13:36:41.355: minor: 9
13:36:41.355: ---------------------------------
13:36:41.355: [FFmpeg aac encoder: 'adv_stream_audio'] bitrate: 160, channels: 2, channel_layout: stereo
13:36:41.355:
13:36:41.355: obs-data.c: [obs_data_create_from_json] Failed reading json string (1): '[' or '{' expected near 'null'
13:36:41.355: >>> app not on intel GPU, fall back to old qsv encoder
13:36:41.355: [qsv encoder: 'advanced_video_stream'] settings:
13:36:41.355: codec: H.264
13:36:41.355: rate_control: CBR
13:36:41.355: target_bitrate: 16000
13:36:41.355: Lookahead Depth:60
13:36:41.355: target_usage: TU3
13:36:41.355: profile: high
13:36:41.355: keyint: 1
13:36:41.355: latency: normal
13:36:41.355: b-frames: 0
13:36:41.355: enhancements: off
13:36:41.355: fps_num: 60
13:36:41.355: fps_den: 1
13:36:41.355: width: 1920
13:36:41.355: height: 1080
13:36:41.487: surf: Texture
13:36:41.930: m_nSurfNum: 9
13:36:41.931: m_nTaskPool: 4
13:36:41.931: major: 2
13:36:41.931: minor: 9
 

Mark Weiss

Member
Well they don't work now do they? Follow my settings & just adjust the bit-rate, gonna look like sh!t.
Are there any issues with the upgrade, or is it not going to break anything? I can only follow your settings if I upgrade, because v 29 lacks that CODEC option.

It's good to know you can stream HEVC. I'll want to take a close look at how to set it up.
 

rockbottom

Active Member
I have no issues with v30, if you have plug-ins make sure they are compatible before you upgrade. If not, remove them prior.

Nope, never said I streamed in H265 only that it is possible with MistServer. You will need to confirm that it works as I'm not making any system changes to test further.
 
Top