您现在的位置是:首页 > 博客日记 > Php Php

TRTC 旁路流实现截图鉴黄 - php

2022-03-18 00:35:10 【Php】 人已围观

在对接腾讯的trtc中,使用官方的直播自动截图功能出现了以下问题

  1. 因为自动截图和鉴黄是针对 直播 模块进行的

  2. ``

  3. 腾讯的trtc实时音视频模块不能直接进行使用

`提交腾讯云工单想咨询一下这个功能,被工作人员拽过来一个链接``

  1. TRTC 旁路流实现截图鉴黄

  2. https://www.rtcgeek.com/?/article/69

安装腾讯的扩展 composer.json

  1. "tencentcloud/tencentcloud-sdk-php": "v3.0.595",

重写两个类

在项目app下创建 /Plugins/Live/Models/

创建文件: CreateSnapshotTemplateRequest.php

  1. php

  2. ``

  3. namespace TencentCloud\Live\V20180801\Models;

  4. use TencentCloud\Common\AbstractModel;

  5. ````

  6. class CreateSnapshotTemplateRequest extends AbstractModel

  7. {

  8. public $TemplateName;

  9. ``````

  10. public $CosAppId;

  11. ``````

  12. public $CosBucket;

  13. ``````

  14. public $CosRegion;

  15. ``````

  16. public $Description;

  17. ``````

  18. public $ProductName;

  19. ``````

  20. public $SnapshotInterval;

  21. ``````

  22. public $Width;

  23. ``````

  24. public $Height;

  25. ``````

  26. public $PornFlag;

  27. ``````

  28. public $CosPrefix;

  29. ``````

  30. public $CosFileName;

  31. ``````

  32. function __construct()

  33. {

  34. ``````

  35. }

  36. ``````

  37. public function deserialize($param)

  38. {

  39. if ($param === null) {

  40. return;

  41. }

  42. if (array_key_exists("TemplateName",$param) and $param["TemplateName"] !== null) {

  43. $this->TemplateName = $param["TemplateName"];

  44. }

  45. ``````

  46. if (array_key_exists("CosAppId",$param) and $param["CosAppId"] !== null) {

  47. $this->CosAppId = $param["CosAppId"];

  48. }

  49. ``````

  50. if (array_key_exists("CosBucket",$param) and $param["CosBucket"] !== null) {

  51. $this->CosBucket = $param["CosBucket"];

  52. }

  53. ``````

  54. if (array_key_exists("CosRegion",$param) and $param["CosRegion"] !== null) {

  55. $this->CosRegion = $param["CosRegion"];

  56. }

  57. ``````

  58. if (array_key_exists("Description",$param) and $param["Description"] !== null) {

  59. $this->Description = $param["Description"];

  60. }

  61. ``````

  62. if (array_key_exists("ProductName",$param) and $param["ProductName"] !== null) {

  63. $this->ProductName = $param["ProductName"];

  64. }

  65. ``````

  66. if (array_key_exists("SnapshotInterval",$param) and $param["SnapshotInterval"] !== null) {

  67. $this->SnapshotInterval = $param["SnapshotInterval"];

  68. }

  69. ``````

  70. if (array_key_exists("Width",$param) and $param["Width"] !== null) {

  71. $this->Width = $param["Width"];

  72. }

  73. ``````

  74. if (array_key_exists("Height",$param) and $param["Height"] !== null) {

  75. $this->Height = $param["Height"];

  76. }

  77. ``````

  78. if (array_key_exists("PornFlag",$param) and $param["PornFlag"] !== null) {

  79. $this->PornFlag = $param["PornFlag"];

  80. }

  81. ``````

  82. if (array_key_exists("CosPrefix",$param) and $param["CosPrefix"] !== null) {

  83. $this->CosPrefix = $param["CosPrefix"];

  84. }

  85. ``````

  86. if (array_key_exists("CosFileName",$param) and $param["CosFileName"] !== null) {

  87. $this->CosFileName = $param["CosFileName"];

  88. }

  89. }

  90. }

``创建文件: CreateSnapshotTemplateResponse.php````

  1. php

  2. namespace TencentCloud\Live\V20180801\Models;

  3. use TencentCloud\Common\AbstractModel;

  4. ``

  5. class CreateSnapshotTemplateResponse extends AbstractModel

  6. {

  7. public $TemplateId;

  8. ````

  9. public $RequestId;

  10. ``````

  11. function __construct()

  12. {

  13. ``````

  14. }

  15. ``````

  16. public function deserialize($param)

  17. {

  18. if ($param === null) {

  19. return;

  20. }

  21. if (array_key_exists("TemplateId",$param) and $param["TemplateId"] !== null) {

  22. $this->TemplateId = $param["TemplateId"];

  23. }

  24. ``````

  25. if (array_key_exists("RequestId",$param) and $param["RequestId"] !== null) {

  26. $this->RequestId = $param["RequestId"];

  27. }

  28. }

  29. }

``

项目composer.php加载该自定义autoload.php 加载器: ``

``

  1. "autoload": {

  2. "psr-4": {

  3. "app\\": "application"

  4. },

  5. "files": [ //以下是自己添加的两个类

  6. "app/Plugins/Live/Models/CreateSnapshotTemplateRequest.php",

  7. "app/Plugins/Live/Models/CreateSnapshotTemplateResponse.php"

  8. ]

  9. },

修改了composer.php的autoload的配置后,我们需要重新生成整个项目最终autoload.php,在项目路径执行命令:

  1. composer dump-autoload

`````



关注TinyMeng博客,更多精彩分享,敬请期待!
 

很赞哦! ()