{"id":10006490,"date":"2022-09-15T12:44:01","date_gmt":"2022-09-15T04:44:01","guid":{"rendered":"https:\/\/ityet.com\/?p=10006490"},"modified":"2022-09-15T12:44:01","modified_gmt":"2022-09-15T04:44:01","slug":"%e4%b8%8d%e6%83%a7%e7%b9%81%e6%9d%82%e8%83%8c%e6%99%af%ef%bc%8c%e8%a7%86%e9%a2%91%e7%bc%96%e8%be%91%e6%9c%8d%e5%8a%a1%e4%b8%80%e9%94%ae%e5%ae%9e%e7%8e%b0%e4%ba%ba%e5%83%8f%e6%8a%a0%e5%9b%be","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006490","title":{"rendered":"\u4e0d\u60e7\u7e41\u6742\u80cc\u666f\uff0c\u89c6\u9891\u7f16\u8f91\u670d\u52a1\u4e00\u952e\u5b9e\u73b0\u4eba\u50cf\u62a0\u56fe"},"content":{"rendered":"<p>\u6700\u8fd1\uff0c\u201c\u4f60\u8fd9\u80cc\u666f\u592a\u5047\u4e86\u201d\u5e2d\u5377\u5168\u7f51\u3002\u7531\u4e8e\u8eab\u540e\u98ce\u666f\u592a\u4f18\u7f8e\uff0c\u88ab\u7f51\u53cb\u8d28\u7591\u80cc\u666f\u592a\u5047\uff0c\u67d0\u4e3b\u64ad\u4e3a\u4e86\u81ea\u8bc1\uff0c\u76f4\u63a5\u628a\u624b\u91cc\u7684\u6876\u6254\u8fdb\u4e86\u80cc\u540e\u7684\u6c34\u91cc\u3002\u77ed\u77ed\u51e0\u5929\u65f6\u95f4\u64ad\u653e\u91cf\u51e0\u5341\u4ebf\uff0c\u5f15\u53d1\u4e86\u5168\u7f51P\u56fe\u72c2\u6f6e\uff0c\u7f51\u53cb\u5728\u77ed\u89c6\u9891App\u91cc\u5c06\u5176\u4eba\u50cf\u62a0\u51fa\u6765\uff0c\u66ff\u6362\u4e86\u4e0d\u540c\u7684\u80cc\u666f\uff0c\u5404\u7c7b\u521b\u610f\u89c6\u9891\u5f88\u5feb\u51b2\u4e0a\u70ed\u641c\u3002<\/p>\n<p>\u73b0\u5982\u4eca\uff0c\u89c6\u9891\u4eba\u50cf\u62a0\u56fe\u6709\u7740\u5e7f\u6cdb\u5e94\u7528\u3002\u5728\u76f4\u64adApp\u91cc\u53ef\u4ee5\u4e3a\u4eba\u50cf\u589e\u52a0\u5404\u79cd\u80cc\u666f\u7279\u6548\u3001\u8d34\u7eb8\u9053\u5177\u7b49\uff0c\u63d0\u4f9b\u66f4\u52a0\u4e30\u5bcc\u7684\u5a31\u4e50\u6c1b\u56f4\uff1b\u4f1a\u8baeApp\u91cc\u53ef\u4ee5\u66ff\u6362\u80cc\u666f\uff0c\u4fdd\u62a4\u7528\u6237\u9690\u79c1\uff1b\u6559\u80b2\u7c7bApp\u4e2d\u53ef\u4ee5\u5c06\u80cc\u666f\u66ff\u6362\u4e3a\u8bfe\u4ef6\u7b49\u5185\u5bb9\uff1b\u800c\u5728\u77ed\u89c6\u9891App\u91cc\u4eba\u50cf\u62a0\u56fe\u80fd\u7ed9\u7528\u6237\u66f4\u591a\u53d1\u6325\u7a7a\u95f4\uff0c\u65e0\u9700\u7eff\u5e55\u62cd\u6444\u548c\u540e\u671f\u5236\u4f5c\u4e5f\u53ef\u4ee5\u8f7b\u677e\u62cd\u6444\u7a7f\u8d8a\u65f6\u7a7a\u7684\u9707\u64bc\u5927\u7247\u3002<\/p>\n<p>\u90a3\u4e48\uff0cApp\u5982\u4f55\u5b9e\u73b0\u4e00\u952e\u63d0\u53d6\u4eba\u50cf\u529f\u80fd\u5462\uff1fHMS Core<a href=\"https:\/\/link.segmentfault.com\/?enc=tNsjGSRPD6F5Cumvu8vn1Q%3D%3D.js0ZkQWM9zNvURdcG%2BKaAvl65%2BvZeVAT0Z2q4LGkUzLBIuW0f%2BI%2Fx7P8eP%2FvaElN2xH4zupGEfOgwfwWOYzveeQ10845BuP9QWfMHNtkHlk%3D\" rel=\"nofollow\">\u89c6\u9891\u7f16\u8f91\u670d\u52a1<\/a>\u63d0\u4f9b<a href=\"https:\/\/link.segmentfault.com\/?enc=r1D98XarRVxihvPQftuJXw%3D%3D.PcvOtYngUABlM3I%2FNrnU5Eql9GY%2FE0cGPSnwSfrUqCYKWH9%2Fbn%2BWO9sIS%2BnTzZC9Iej5CH%2F4l2apnIhF7qrGiJm%2Fh1QjxZQ2KN%2BRli%2FroZ%2BxT6kXdU8%2Bl%2FG9ijGQTo7r753BUGFjF1KGM%2B9rGQisM4h3GrL%2BS%2BO5jbkr%2BlqxW%2FwDX0tY0rZfjxqCnwaggjXG4lvY%2BnbYUqRfY5twuCOQOw%3D%3D\" rel=\"nofollow\">\u4eba\u50cf\u548c\u5934\u90e8\u5206\u5272\u80fd\u529b<\/a>\uff0c\u652f\u6301\u5bf9\u8f93\u5165\u7684\u89c6\u9891\u6216\u56fe\u7247\u8fdb\u884c\u4eba\u50cf\u6216\u5934\u90e8\u5206\u5272\uff0c\u751f\u6210\u5206\u5272\u540e\u7684\u89c6\u9891\u3001\u56fe\u7247\u6216\u8d34\u7eb8\u3002<\/p>\n<h3>\u5f00\u53d1\u6b65\u9aa4<\/h3>\n<h4>1.    \u5f00\u53d1\u51c6\u5907<\/h4>\n<p>\u8be6\u7ec6\u51c6\u5907\u6b65\u9aa4\u53ef\u53c2\u8003<a href=\"https:\/\/link.segmentfault.com\/?enc=Qm1DKLvft5wJwfe6Vl6AEg%3D%3D.3XvT3paavOewnaZhk9WaVfouRZ0S1rYHMMU9fbz%2FFFULIM901tsBtmfe8pszsXKUXLAuq6tGsrzJQGN9MdZAihB3udY3FKp9CnfnVCUxb8MtCKVlXVrvGRDMfrF65bkExfkeF9QKcHastZzZLK%2F4Fqsf%2BZqdXlXusBFJRx3Wtgf0XxWts2gWaQFNPmIECuj2\" rel=\"nofollow\">\u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df\u5b98\u7f51<\/a>\u3002<\/p>\n<h4>2.    \u7f16\u8f91\u5de5\u7a0b\u96c6\u6210<\/h4>\n<p>2.1 \u8bbe\u7f6e\u5e94\u7528\u7684\u9274\u6743\u4fe1\u606f<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7api_key\u6216\u8005Access Token\u6765\u8bbe\u7f6e\u5e94\u7528\u9274\u6743\u4fe1\u606f\u3002<\/p>\n<p>\u901a\u8fc7setAccessToken\u65b9\u6cd5\u8bbe\u7f6eAccess Token\uff0c\u5728\u5e94\u7528\u542f\u52a8\u65f6\u521d\u59cb\u5316\u8bbe\u7f6e\u4e00\u6b21\u5373\u53ef\uff0c\u65e0\u9700\u591a\u6b21\u8bbe\u7f6e\u3002<\/p>\n<pre><code>MediaApplication.getInstance().setAccessToken(&quot;your access token&quot;);<\/code><\/pre>\n<p>\u901a\u8fc7setApiKey\u65b9\u6cd5\u8bbe\u7f6eapi_key\uff0c\u5728\u5e94\u7528\u542f\u52a8\u65f6\u521d\u59cb\u5316\u8bbe\u7f6e\u4e00\u6b21\u5373\u53ef\uff0c\u65e0\u9700\u591a\u6b21\u8bbe\u7f6e\u3002<\/p>\n<pre><code>MediaApplication.getInstance().setApiKey(&quot;your ApiKey&quot;);<\/code><\/pre>\n<p>2.2\u8bbe\u7f6e\u552f\u4e00\u6807\u8bc6ID\uff0c\u5373License ID\u3002<\/p>\n<p>License ID\u662f\u8fdb\u884c\u7ba1\u63a7\u7684\u6709\u6548\u51ed\u8bc1\uff0c\u60a8\u8981\u4fdd\u8bc1\u8bbe\u7f6eLicense ID\u7684\u552f\u4e00\u6027\u3002<\/p>\n<pre><code>MediaApplication.getInstance().setLicenseId(&quot;License ID&quot;);<\/code><\/pre>\n<p>2.2.1\u521d\u59cb\u5316Editor\u8fd0\u884c\u73af\u5883<\/p>\n<p>\u521b\u5efa\u7f16\u8f91\u5de5\u7a0b\uff0c\u9700\u8981\u9996\u5148\u521b\u5efaEditor\u5bf9\u8c61\u5e76\u521d\u59cb\u5316\u5176\u8fd0\u884c\u73af\u5883\u3002\u5f53\u79bb\u5f00\u7f16\u8f91\u5de5\u7a0b\u65f6\uff0c\u5e94\u91ca\u653eEditor\u5b9e\u4f8b\u3002<\/p>\n<p>(1)    \u521b\u5efaEditor\u5bf9\u8c61<\/p>\n<pre><code>HuaweiVideoEditor editor = HuaweiVideoEditor.create(getApplicationContext());<\/code><\/pre>\n<p>(2)    \u6307\u5b9a\u9884\u89c8\u7a97\u53e3\u7684\u5e03\u5c40\u4f4d\u7f6e<\/p>\n<p>\u9884\u89c8\u7a97\u53e3\u8d1f\u8d23\u89c6\u9891\u56fe\u50cf\u753b\u9762\u7684\u6e32\u67d3\uff0c\u7531\u89c6\u9891\u7f16\u8f91\u539f\u5b50\u80fd\u529bSDK\u5185\u90e8\u521b\u5efaSurfaceView\u6765\u5b9e\u73b0\u3002\u5728\u521b\u5efa\u7a97\u53e3\u4e4b\u524d\uff0c\u9700\u8981\u5728\u60a8\u7684App\u4e2d\u6307\u5b9a\u9884\u89c8\u7a97\u53e3\u7684\u5e03\u5c40\u4f4d\u7f6e\u3002<\/p>\n<pre><code>&lt;LinearLayout    \n    android:id=&quot;@+id\/video_content_layout&quot;    \n    android:layout_width=&quot;0dp&quot;    \n    android:layout_height=&quot;0dp&quot;    \n    android:background=&quot;@color\/video_edit_main_bg_color&quot;    \n    android:gravity=&quot;center&quot;    \n    android:orientation=&quot;vertical&quot; \/&gt;\n\/\/ \u6307\u5b9a\u9884\u89c8\u7a97\u53e3 \nLinearLayout mSdkPreviewContainer = view.findViewById(R.id.video_content_layout);\n\n\/\/ \u8bbe\u7f6e\u9884\u89c8\u7a97\u53e3\u627f\u8f7d\u7684\u5e03\u5c40 \neditor.setDisplay(mSdkPreviewContainer);<\/code><\/pre>\n<p>(3)    \u521d\u59cb\u5316\u8fd0\u884c\u73af\u5883\uff0c\u5982\u679cLicense\u9274\u6743\u5931\u8d25\uff0c\u4f1a\u629b\u51faLicenseException\u3002<\/p>\n<p>\u5f53Editor\u5bf9\u8c61\u521b\u5efa\u4e4b\u540e\uff0c\u6b64\u65f6\u8fd8\u6ca1\u6709\u5360\u7528\u5b9e\u9645\u7684\u7cfb\u7edf\u8d44\u6e90\uff0c\u9700\u8981\u624b\u52a8\u9009\u62e9\u5176\u73af\u5883\u521d\u59cb\u5316\u7684\u65f6\u673a\uff0c\u6b64\u65f6\u89c6\u9891\u7f16\u8f91\u539f\u5b50\u80fd\u529bSDK\u5185\u90e8\u4f1a\u521b\u5efa\u5fc5\u987b\u7684\u7ebf\u7a0b\u548c\u5b9a\u65f6\u5668\u7b49\u3002<\/p>\n<pre><code>try {\n        editor.initEnvironment();\n   } catch (LicenseException error) { \n        SmartLog.e(TAG, &quot;initEnvironment failed: &quot; + error.getErrorMsg());    \n        finish();\n        return;\n   }<\/code><\/pre>\n<h4>3.    \u4eba\u50cf\u548c\u5934\u90e8\u5206\u5272\u80fd\u529b\u96c6\u6210<\/h4>\n<pre><code>\/\/ \u521d\u59cb\u5316\u5206\u5272AI\u5f15\u64ce\u3002segPart\u4e3aint\u7c7b\u578b\uff0c\u503c\u4e3a1\u65f6\uff0c\u8fdb\u884c\u4eba\u50cf\u5206\u5272\uff1b\u503c\u4e3a\u5176\u4ed6\u65f6\uff0c\u8fdb\u884c\u5934\u90e8\u5206\u5272\nvisibleAsset.initBodySegEngine(segPart, new HVEAIInitialCallback() {\n    @Override\n    public void onProgress(int progress) {\n        \/\/ \u521d\u59cb\u5316\u8fdb\u5ea6\n    }\n\n    @Override\n    public void onSuccess() {\n        \/\/ \u521d\u59cb\u5316\u6210\u529f\n    }\n\n    @Override\n    public void onError(int errorCode, String errorMessage) {\n        \/\/ \u521d\u59cb\u5316\u5931\u8d25\n    }\n});\n\n\/\/ \u5206\u5272\u7684\u5904\u7406\u7ed3\u679c\u6210\u529f\u540e\uff0c\u6dfb\u52a0\u5206\u5272AI\u7279\u6548\nvisibleAsset.addBodySegEffect(new HVEAIProcessCallback() {\n    @Override\n    public void onProgress(int progress) {\n        \/\/ \u5206\u5272AI\u7279\u6548\u5904\u7406\u8fdb\u5ea6\n    }\n\n    @Override\n    public void onSuccess() {\n        \/\/ \u5206\u5272AI\u7279\u6548\u5904\u7406\u6210\u529f\n    }\n\n    @Override\n    public void onError(int errorCode, String errorMsg) {\n        \/\/ \u5206\u5272AI\u7279\u6548\u5904\u7406\u5931\u8d25\n    }\n});\n\n\/\/ \u4e2d\u65ad\u5206\u5272AI\u7279\u6548\u5904\u7406\nvisibleAsset.interruptBodySegEffect();\n\n\/\/ \u79fb\u9664\u5206\u5272AI\u7279\u6548\nvisibleAsset.removeBodySegEffect();\n\n\/\/ \u91ca\u653e\u5206\u5272AI\u5f15\u64ce\nvisibleAsset.releaseBodySegEngine();<\/code><\/pre>\n<p><strong>\u4e86\u89e3\u66f4\u591a\u8be6\u60c5&gt;&gt;<\/strong><\/p>\n<p>\u8bbf\u95ee<a href=\"https:\/\/link.segmentfault.com\/?enc=TOHRHTmmHpqEd8nunPkpjQ%3D%3D.%2BqP9ROXjavxQsIua4pCdjYiM6jb%2FKbLEDxGM9MEduj3FC3Gwz%2BY%2BA6nhC3jKvC12xljwDlIT0Tk0HlJ%2B1DEjPA%3D%3D\" rel=\"nofollow\">\u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df\u5b98\u7f51<\/a>  <br \/>\u83b7\u53d6<a href=\"https:\/\/link.segmentfault.com\/?enc=UGKlMK9qcyHN4X9Jj2cryg%3D%3D.zddqsFALiI6hNymxITSs%2FL9QoN%2B2XrgtGfC7FykpHiQWblsU2R3LgvgOQ7sZFm3KAKscxggRkjfgZPuy1h7dHXnIpLohzjlQRn0GGQgbIdo%3D\" rel=\"nofollow\">\u5f00\u53d1\u6307\u5bfc\u6587\u6863<\/a>  <br \/>\u534e\u4e3a\u79fb\u52a8\u670d\u52a1\u5f00\u6e90\u4ed3\u5e93\u5730\u5740\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=wjADPC1e85Y1rWTCvpN0Eg%3D%3D.%2B2EoBpPqaw33Wni3%2BhySdBNULWgbDUYnJMKj2K6tZ%2BI%3D\" rel=\"nofollow\">GitHub<\/a>\u3001<a href=\"https:\/\/link.segmentfault.com\/?enc=MCiYhcf7RgatBEvShUOjbQ%3D%3D.n7bHxn0lugav%2FaZ%2BbIHr0wDla2vQy4ORXVOU99v%2BGIo%3D\" rel=\"nofollow\">Gitee<\/a><\/p>\n<p><strong>\u5173\u6ce8\u6211\u4eec\uff0c\u7b2c\u4e00\u65f6\u95f4\u4e86\u89e3 HMS Core \u6700\u65b0\u6280\u672f\u8d44\u8baf~<\/strong><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042484182\">https:\/\/segmentfault.com\/a\/1190000042484182<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\uff0c\u201c\u4f60\u8fd9\u80cc\u666f\u592a\u5047\u4e86\u201d\u5e2d\u5377\u5168\u7f51\u3002\u7531\u4e8e\u8eab\u540e\u98ce\u666f\u592a\u4f18\u7f8e\uff0c\u88ab\u7f51\u53cb\u8d28\u7591\u80cc\u666f\u592a\u5047\uff0c\u67d0\u4e3b\u64ad\u4e3a\u4e86\u81ea\u8bc1\uff0c\u76f4\u63a5\u628a\u624b\u91cc\u7684\u6876\u6254\u8fdb\u4e86 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006490","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006490"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006490\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}