0017-chromecast-use-vt-encoder-from-avcodec.patch 2.04 KB
Newer Older
1
From 954b849b2c65830978c2ed85e3f7900ead8f30c7 Mon Sep 17 00:00:00 2001
2 3
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 27 Mar 2018 16:52:35 +0200
4
Subject: [PATCH 17/18] chromecast: use vt encoder from avcodec
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

---
 modules/stream_out/chromecast/cast.cpp | 33 ++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index b330b70297..47a2758259 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -956,12 +956,45 @@ static std::string GetVencX264Option( sout_stream_t * /* p_stream */,
     return ssout.str();
 }
 
+#ifdef __APPLE__
+static std::string GetVencAvcodecVTOption( sout_stream_t * /* p_stream */,
+                                           const video_format_t * p_vid,
+                                           int i_quality )
+{
+    const bool b_hdres = p_vid == NULL || p_vid->i_height == 0 || p_vid->i_height >= 800;
+    std::stringstream ssout;
+    ssout << "venc=avcodec{codec=h264_videotoolbox,options{realtime=1}}";
+    if( b_hdres )
+    {
+        switch( i_quality )
+        {
+            /* Here, performances issues won't come from videotoolbox but from
+             * some old chromecast devices */
+
+            case CONVERSION_QUALITY_HIGH:
+                break;
+            case CONVERSION_QUALITY_MEDIUM:
+                ssout << ",vb=8000000";
+                break;
+            case CONVERSION_QUALITY_LOW:
+            case CONVERSION_QUALITY_LOWCPU:
+                ssout << ",vb=3000000";
+                break;
+        }
+    }
+
+    return ssout.str();
+}
+#endif
 
 static struct
 {
     vlc_fourcc_t fcc;
     std::string (*get_opt)( sout_stream_t *, const video_format_t *, int);
 } venc_opt_list[] = {
+#ifdef __APPLE__
+    { .fcc = VLC_CODEC_H264, .get_opt = GetVencAvcodecVTOption },
+#endif
     { .fcc = VLC_CODEC_H264, .get_opt = GetVencX264Option },
     { .fcc = VLC_CODEC_VP8,  .get_opt = GetVencVPXOption },
     { .fcc = VLC_CODEC_H264, .get_opt = NULL },
-- 
61
2.17.1
62