In short, d3d11h264dec
doesn’t seem to handle multiple slices per frame by default, how do I remedy this?
I have a Maevex 6052 encoder appliance that produces an H.264 stream of an HDMI input. The output stream is sent over RTSP where I decode it using GStreamer to display it locally. Notably, the encoder is configured to be “Optimized for low latency”, which appears to divide outgoing frames into 4 slices.
When decoding, only the top of the image appears to be decoded correctly, where the bottom 3/4ths is a big blur that appears to just repeat the last successfully decoded line of pixels. The top portion plays normally. Errors appear in the log indicating the slice error:
...
0:00:03.747752100 22856 000001203CC3E180 INFO videodecoder gstvideodecoder.c:1631:gst_video_decoder_sink_event_default:<d3d11h264dec0> upstream tags: taglist, video-codec=(string)"H.264\ \(High\ Profile\)", minimum-bitrate=(uint)59041, maximum-bitrate=(uint)3019281, bitrate=(uint)8594073;
0:00:03.762124100 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 2040
0:00:03.762317000 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.762531900 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 4080
0:00:03.762687800 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.762814800 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 6120
0:00:03.762992800 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.763102400 22856 000001203CC3E180 WARN codecparsers_h264 gsth264parser.c:1116:gst_h264_parser_parse_user_data_unregistered: No more remaining payload data to store
0:00:03.763213700 22856 000001203CC3E180 WARN h264parse gsth264parse.c:642:gst_h264_parse_process_sei:<h264parse0> failed to parse one or more SEI message
0:00:03.778765600 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 2040
0:00:03.778999900 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.779136600 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 4080
0:00:03.779257000 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.779384900 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 6120
0:00:03.779505200 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
0:00:03.779673100 22856 000001203CC3E180 WARN codecparsers_h264 gsth264parser.c:1116:gst_h264_parser_parse_user_data_unregistered: No more remaining payload data to store
0:00:03.779826700 22856 000001203CC3E180 WARN h264parse gsth264parse.c:642:gst_h264_parse_process_sei:<h264parse0> failed to parse one or more SEI message
0:00:03.796004200 22856 000001203CC3E180 ERROR h264decoder gsth264decoder.c:751:gst_h264_decoder_preprocess_slice:<d3d11h264dec0> Invalid stream, first_mb_in_slice 2040
0:00:03.797273500 22856 000001203CC3E180 WARN videodecoder gstvideodecoder.c:4787:_gst_video_decoder_error:<d3d11h264dec0> error: Failed to decode data
...
I’m running Windows 10 with GStreamer MSVC x64 1.24.7. Some other decoders appear to have the same issue (nvh264dec
), or they work, but with higher latency or system utilization, so I’d prefer to use d3d11. Here’s the pipeline used.
gst-launch-1.0.exe rtspsrc location="rtsp://192.168.42.101:3049/S1" latency=10 ! rtph264depay ! queue ! h264parse ! d3d11h264dec ! d3d11videosink
I tried saving the stream to file after h264parse
, but when replaying the file (starting with h264parse), it decodes fine, so not sure what’s going on there…
# Save
gst-launch-1.0.exe rtspsrc location="rtsp://192.168.42.101:3049/S1" latency=10 ! rtph264depay ! h264parse config-interval=1 ! video/x-h264,stream-format=byte-stream, alignment=au ! tee name=t ! queue ! filesink location= test.h264 t. ! queue ! d3d11h264dec ! d3d11videosink
# Play from file
gst-launch-1.0.exe filesrc location= test.h264 ! 'video/x-h264, stream-format=byte-stream, alignment=au' ! h264parse ! d3d11h264dec ! d3d11videosink