Encoding multiple concurrent real time video streams with NVIDIA hardware video encoder

NVIDIA consumer grade hardware provides support nowadays for – mostly – three concurrent sessions. The support matrix is provided here: Video Encode and Decode GPU Support Matrix | NVIDIA Developer.

This small tool starts video encoding with given signal parameters (resolution, rate) and provides an easy way to measure load of GPU video encoding engine.

The application creates a Media Foundation pipeline with signal source based on software implementation of Direct2D and system memory backed RGB32 media samples. Then it is connected to H.264 video encoder MFT (not a stock one, a customer wrapper over NVIDIA SDK) with encoding profile around the lowest latency and maximal performance. The output is being fed into null media sink, with or without dumping created content to disk.

Video feed configuration is defined in associated JSON file:

{
    "Tasks": [
        {
            "RateN": 60,
            "RateD": 1,
            "SizeW": 1920,
            "SizeH": 1080
        },
        {
            "RateN": 60,
            "RateD": 1,
            "SizeW": 1920,
            "SizeH": 1080
        },
        {
            "RateN": 60,
            "RateD": 1,
            "SizeW": 1920,
            "SizeH": 1080
        }
    ],
    "Duration": 60
}

The GPU load is displayed by task manager as encoding goes, for example three 1920×1080@60 streams load NVIDIA GeForce RTX 2060 by ~45%.

Command line parameter -ws may be added to write streams to disk, the produced .h264 files can be played out by Media Player Classic or other players:

The archive below contains 32 and 64 bit builds of the utility with configuration files. Have fun!

Leave a Reply