이유 및 방법: 비디오 편집기에 템플릿 추가

배경



창의적인 것은 어렵지만 환상적인 아이디어를 생각하는 것은 훨씬 더 어렵습니다. 일단 그렇게 하고 나면 가장 어려운 부분은 그 아이디어를 매력적인 방식으로 표현하는 것입니다.

이것이 바로 템플릿이 텍스트, 이미지, 오디오 및 비디오 편집 등에서 인기를 얻고 있는 이유라고 생각합니다. 이 모든 템플릿 중에서 비디오 템플릿은 아마도 사용자가 가장 많이 요구하는 템플릿일 것입니다. 동영상은 시간이 오래 걸리고 비용도 많이 들기 때문입니다. 따라서 처음부터 시작하는 것보다 템플릿을 사용하여 비디오를 만드는 것이 훨씬 더 편리합니다. 이는 특히 비디오 편집 아마추어에게 해당됩니다.

내 앱용으로 가지고 있는 비디오 템플릿 솔루션은 HMS Core Video Editor Kittemplate capability입니다. 이 기능에는 사용자가 짧은 비디오를 빠르게 만들고, 여정 중에 vlog를 만들고, 제품 디스플레이 비디오를 만들고, 뉴스 비디오를 생성하는 등의 작업에 직접 사용할 수 있는 템플릿 라이브러리가 미리 로드되어 있습니다.

게다가 이 기능은 템플릿을 이렇게 쉽게 관리할 수 있는 플랫폼과 함께 제공됩니다.
템플릿 관리 플랫폼 — AppGallery Connect

솔직히 말해서 이 기능에 대해 제가 정말 좋아하는 것 중 하나는 간단한 코드와 전체 API 세트 및 사용 방법에 대한 관련 설명 덕분에 통합이 쉽다는 것입니다. 다음은 기능을 내 앱에 통합하기 위해 따랐던 프로세스입니다.

개발 절차


준비



1) 앱 정보를 구성합니다.
2) SDK를 통합합니다.
3) 난독화 스크립트를 설정합니다.
4) 장치 진동 권한, 마이크 사용 권한, 저장소 읽기 권한, 저장소 쓰기 권한을 포함하여 필요한 권한을 선언합니다.

프로젝트 구성


인증 정보 설정



다음을 사용하여 인증 정보를 설정합니다.
  • 액세스 토큰입니다. 설정은 앱 초기화 중에 한 번만 필요합니다.

  • MediaApplication.getInstance().setAccessToken("your access token");
    

  • 또는 앱 초기화 중에 한 번만 설정해야 하는 API 키입니다.

  • MediaApplication.getInstance().setApiKey("your ApiKey");
    

    라이선스 ID 구성



    이 ID는 서비스의 사용 할당량을 관리하는 데 사용되므로 ID는 고유해야 합니다.

    MediaApplication.getInstance().setLicenseId("License ID");
    


    HuaweiVideoEditor의 런타임 환경을 초기화합니다.
    프로젝트 구성 시 HuaweiVideoEditor의 개체를 먼저 생성하고 해당 런타임 환경을 초기화해야 합니다. 프로젝트를 종료하면 개체가 해제됩니다.
    1) HuaweiVideoEditor 개체를 만듭니다.

    HuaweiVideoEditor editor = HuaweiVideoEditor.create(getApplicationContext());
    


    2) 미리보기 영역 위치를 지정합니다. 이러한 영역은 SDK 내에서 생성된 SurfaceView를 통해 구현되는 비디오 이미지를 렌더링합니다. 이 영역을 생성하기 전에 먼저 위치를 지정하십시오.

    <LinearLayout    
        android:id="@+id/video_content_layout"    
        android:layout_width="0dp"    
        android:layout_height="0dp"    
        android:background="@color/video_edit_main_bg_color"    
        android:gravity="center"    
        android:orientation="vertical" />
    // Specify a preview area.
    LinearLayout mSdkPreviewContainer = view.findViewById(R.id.video_content_layout);
    
    // Set the preview area layout.
    editor.setDisplay(mSdkPreviewContainer);
    


    3) 런타임 환경을 초기화합니다. 라이선스 확인에 실패하면 LicenseException이 발생합니다.
    HuaweiVideoEditor 개체가 생성될 때 시스템 리소스가 사용되지 않았습니다. 런타임 환경이 초기화되는 시간을 수동으로 설정하면 SDK에서 필요한 스레드와 타이머가 생성됩니다.

    try {
            editor.initEnvironment();
       } catch (LicenseException error) { 
            SmartLog.e(TAG, "initEnvironment failed: " + error.getErrorMsg());    
            finish();
            return;
       }
    


    기능 통합



    이 부분에서는 HVETemplateManager을 사용하여 on-cloud 템플릿 목록을 가져온 다음 내 앱 사용자에게 목록을 제공합니다.

    // Obtain the template column list.
    final HVEColumnInfo[] column = new HVEColumnInfo[1];
    HVETemplateManager.getInstance().getColumnInfos(new HVETemplateManager.HVETemplateColumnsCallback() {
            @Override
            public void onSuccess(List<HVEColumnInfo> result) {
               // Called when the list is successfully obtained.
               column[0] = result.get(0);
            }
    
            @Override
            public void onFail(int error) {
               // Called when the list failed to be obtained.
            }
    });
    
    // Obtain the list details.
    final String[] templateIds = new String[1];
    // size indicates the number of the to-be-requested on-cloud templates. The size value must be greater than 0. Offset indicates the offset of the to-be-requested on-cloud templates. The offset value must be greater than or equal to 0. true indicates to forcibly obtain the data of the on-cloud templates.
    HVETemplateManager.getInstance().getTemplateInfos(column[0].getColumnId(), size, offset, true, new HVETemplateManager.HVETemplateInfosCallback() {
            @Override
            public void onSuccess(List<HVETemplateInfo> result, boolean hasMore) {
               // Called when the list details are successfully obtained.
               HVETemplateInfo templateInfo = result.get(0);
               // Obtain the template ID.
               templateIds[0] = templateInfo.getId();
            }
    
            @Override
            public void onFail(int errorCode) {
               // Called when the list details failed to be obtained.
            }
    });
    
    // Obtain the template ID when the list details are obtained.
    String templateId = templateIds[0];
    
    // Obtain a template project.
    final List<HVETemplateElement>[] editableElementList = new ArrayList[1];;
    HVETemplateManager.getInstance().getTemplateProject(templateId, new HVETemplateManager.HVETemplateProjectCallback() {
            @Override
            public void onSuccess(List<HVETemplateElement> editableElements) {
               // Direct to the material selection screen when the project is successfully obtained. Update editableElements with the paths of the selected local materials.
               editableElementList[0] = editableElements;
            }
    
            @Override
            public void onProgress(int progress) {
               // Called when the progress of obtaining the project is received.
            }
    
            @Override
            public void onFail(int errorCode) {
               // Called when the project failed to be obtained.
            }
    });
    
    // Prepare a template project.
    HVETemplateManager.getInstance().prepareTemplateProject(templateId, new HVETemplateManager.HVETemplateProjectPrepareCallback() {
            @Override
            public void onSuccess() {
                // Called when the preparation is successful. Create an instance of HuaweiVideoEditor, for operations like playback, preview, and export.           
            }
            @Override
            public void onProgress(int progress) {
                // Called when the preparation progress is received.
            }
    
            @Override
            public void onFail(int errorCode) {
                // Called when the preparation failed.
            }
    });
    
    // Create an instance of HuaweiVideoEditor.
    // Such an instance will be used for operations like playback and export.
    HuaweiVideoEditor editor = HuaweiVideoEditor.create(templateId, editableElementList[0]);
    try {
          editor.initEnvironment();
    } catch (LicenseException e) {
          SmartLog.e(TAG, "editor initEnvironment ERROR.");
    }
    


    이 프로세스를 완료하면 아래 표시된 데모와 같은 앱을 만들게 됩니다.


    결론



    눈길을 끄는 비디오는 그것이 가져올 수 있는 모든 장점에도 불구하고 만들기가 어려울 수 있습니다. 그러나 비디오 템플릿의 도움으로 사용자는 더 짧은 시간에 멋진 비디오를 만들 수 있으므로 더 많은 비디오를 만드는 데 더 많은 시간을 할애할 수 있습니다.

    이 문서는 모바일 앱용 비디오 템플릿 솔루션을 설명합니다. 템플릿 기능은 플랫폼에서 쉽게 관리할 수 있는 다양한 기본 사전 설정 템플릿을 제공합니다. 그리고 더 나은 점은 전체 통합 프로세스가 쉽다는 것입니다. 템플릿이 있는 동영상 앱을 만들 수도 있었습니다.

    좋은 웹페이지 즐겨찾기