package com.ss.android.ugc.aweme.services.video;

import X.3rb;
import X.C1417MpQ;
import X.DEW;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.services.external.ability.IAVProcessService$CompileParam;
import com.ss.android.ugc.aweme.services.external.ability.IAVProcessService$CompileResult;
import com.ss.android.vesdk.VEEditor;
import com.ss.android.vesdk.VEException;
import com.ss.android.vesdk.VESize;
import com.ss.android.vesdk.VEVideoEncodeSettings;

public final class ImVideoCompileService$compileVideo$1<T> implements 3rb {
    public final /* synthetic */ IAVProcessService$CompileParam $compileParam;
    public final /* synthetic */ IAVProcessService$CompileResult $result;
    public final /* synthetic */ ImVideoCompileService this$0;

    static {
        Covode.recordClassIndex(105484);
    }

    public ImVideoCompileService$compileVideo$1(ImVideoCompileService imVideoCompileService, IAVProcessService$CompileParam iAVProcessService$CompileParam, IAVProcessService$CompileResult iAVProcessService$CompileResult) {
        this.this$0 = imVideoCompileService;
        this.$compileParam = iAVProcessService$CompileParam;
        this.$result = iAVProcessService$CompileResult;
    }

    public final void subscribe(DEW<Boolean> dew) {
        M12.LIZ(dew);
        VEEditor createVEEditor = this.this$0.createVEEditor();
        ImVideoCompileService$compileVideo$1$onCompileErrorCallback$1 imVideoCompileService$compileVideo$1$onCompileErrorCallback$1 = new ImVideoCompileService$compileVideo$1$onCompileErrorCallback$1(this, createVEEditor, dew);
        ImVideoCompileService$compileVideo$1$onCompileInfoCallback$1 imVideoCompileService$compileVideo$1$onCompileInfoCallback$1 = new ImVideoCompileService$compileVideo$1$onCompileInfoCallback$1(this, createVEEditor, dew);
        try {
            int initVEEditor = this.this$0.initVEEditor(createVEEditor, this.$compileParam.getRawVideoPath());
            if (initVEEditor != 0) {
                C1417MpQ.LIZ("ImVideoCompileService VEEditor init error: ".concat(String.valueOf(initVEEditor)));
                this.this$0.safeOnError(dew, new IllegalStateException("VEEditor init error: ".concat(String.valueOf(initVEEditor))));
                return;
            }
            createVEEditor.LIZ(imVideoCompileService$compileVideo$1$onCompileErrorCallback$1);
            createVEEditor.LIZIZ(imVideoCompileService$compileVideo$1$onCompileInfoCallback$1);
            VEVideoEncodeSettings createEncodeSettings = this.this$0.createEncodeSettings(this.$compileParam);
            VESize videoRes = createEncodeSettings.getVideoRes();
            this.$result.setVideoWidth(videoRes.width);
            this.$result.setVideoHeight(videoRes.height);
            this.$result.setVideoPath(this.this$0.getOutputVideoFilePath());
            createVEEditor.LIZ(this.$result.getVideoPath(), (String) null, createEncodeSettings);
        } catch (VEException e) {
            C1417MpQ.LIZ((Throwable) e);
            this.this$0.safeOnError(dew, new IllegalStateException("VEEditor init error", e));
        }
    }
}
