NVIDIA/NvPipe

Multiple encoder session for multiple users - best practice?

Closed this issue · 7 comments

If I am serving multiple clients, should I be creating separate encoder instances per client or just create one and share them across all clients? I am new to this, any help is highly appreciated.

Thanks!

When I try create multiple encoder sessions I get this error.

Encode error: Failed to create encoder (NvEncoder : m_nvenc.nvEncOpenEncodeSessionEx(&encodeSessionExParams, &hEncoder) returned error 10 at /home/op/NvPipe/src/NvCodec/NvEncoder/NvEncoder.cpp:54

Hi,

that depends on what exactly you want to serve your individual clients. If everybody is supposed to receive the same stream, then you only need a single encoder instance. Just remember that you'll probably want to force an I-frame whenever a new client has connected.

Regarding your error: How many encode sessions did you create? Depending on your hardware, you might run into a limit on the maximum number of concurrent encode sessions (e.g., 2 on GeForce).

Hi,

that depends on what exactly you want to serve your individual clients. If everybody is supposed to receive the same stream, then you only need a single encoder instance. Just remember that you'll probably want to force an I-frame whenever a new client has connected.

Everybody will receive different streams. Is there any example/pointer I can refer for the I-frame concept?

Regarding your error: How many encode sessions did you create? Depending on your hardware, you might run into a limit on the maximum number of concurrent encode sessions (e.g., 2 on GeForce).

I just created 2 sessions.
I have GeForce GTX 1080 Ti with 11GB GDDR5X

Every encode call has a bool forceIFrame parameter.
But if every client is supposed to receive a different stream, then you need separate encoder instances anyway.

I suggest having a separate encode thread for each client connection. So when a new client connects, start a thread, create an encoder in it, and then encode+send in a loop while the client is connected.

Sounds good, thanks for the quick responses :)

I've been getting this same error myself.. In my case:
1 - I've separate threads for encoding
2 - Second encoder instance is created without any error
3 - First frame I send in to the encoder gives me the above error
4 - It encodes from second frame BUT the video resolution is set to 1920x1080 (I'm sending in frames of 1152x648 size)

Any ideas?

Thanks!

I've been getting this same error myself.. In my case:
1 - I've separate threads for encoding
2 - Second encoder instance is created without any error
3 - First frame I send in to the encoder gives me the above error
4 - It encodes from second frame BUT the video resolution is set to 1920x1080 (I'm sending in frames of 1152x648 size)

Any ideas?

Thanks!

Check out the update to Video Codec SDK 9 that I just pushed. It also includes a fix for concurrent encoding, and a "concurrent" example.