[Spice-devel] [spice] streaming: Limit the h264 image compression level

Francois Gouget fgouget at codeweavers.com
Thu Oct 27 17:04:27 UTC 2016


When uncapped x264enc can compress the frames beyond recognition in low 
bitrate situation. Beyond the set limit the gains are modest and it is 
better to drop frames to reduce the bit rate further.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 server/gstreamer-encoder.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
index cb04569..6afc7e4 100644
--- a/server/gstreamer-encoder.c
+++ b/server/gstreamer-encoder.c
@@ -932,11 +932,14 @@ static gboolean create_pipeline(SpiceGstEncoder *encoder)
     case SPICE_VIDEO_CODEC_TYPE_H264:
         /* - Set tune and sliced-threads to ensure a zero-frame latency
          * - qp-min ensures the bitrate does not get needlessly high.
+         * - qp-max ensures the compression does not go so high that the video
+         *   is unrecognizable. When that threshold is reached it is better to
+         *   drop frames to lower the bit rate further.
          * - Set speed-preset to get realtime speed.
          * - Set intra-refresh to get more uniform compressed frame sizes,
          *   thus helping with streaming.
          */
-        gstenc_opts = g_strdup("byte-stream=true aud=true qp-min=15 tune=4 sliced-threads=true speed-preset=ultrafast intra-refresh=true");
+        gstenc_opts = g_strdup("byte-stream=true aud=true qp-min=15 qp-max=35 tune=4 sliced-threads=true speed-preset=ultrafast intra-refresh=true");
         break;
     default:
         /* gstreamer_encoder_new() should have rejected this codec type */
-- 
2.9.3


More information about the Spice-devel mailing list