zegocloud

Preview and push stream are all black


I use ZEGOCLOUD express SDK. After accessing beauty through custom pre-processing, the preview and push stream are all black.

code:

express.enableCustomVideoProcessing( enable: true, config, ZegoPublishChannel.MAIN);
express.setCustomVideoProcessHandler(new IZegoCustomVideoProcessHandler(){
    @Override
    public void onStart (ZegoPublishChannel channel) {
        Log_i(tag:"ZEGOCLOUD", msg:"[Express] [onStart]");
        effects.initEnv(720, 1280);
    }

    @override
    public void onStop(ZegoPublishChannel channel) {
        Log_i(tag:"ZEGOCLOUD", msg:"[Express] [onStop]");
        effects.uninitEnv();
    }

    @Override
    public void onCapturedUnprocessedTextureData(int textureID, int width, int height, Long referenceTimeMillisecond, ZegoPublishChannel channel) {
        Log.i( tag: "ZEGOCLOUD". msg: "[Exoress] [onCapturedUnprocessedTextureData] textureID:" + textureID + "width:" + width + "height: " + height + ", ts:" + referenceTimeMillisecond);

        effectsVideoFrameParam.width = width;
        effectsVideoFrameParam.height = height;


        int processedTextureID = effects.processTexture(textureID, effectsVideoFrameParam);

        express.sendCustomVideoProcessedTextureData(processedTextureID, width, height, referenceTimeMillisecond);
    }
});


Solution

  • The effects initialization is called in onStart, but there is a problem with the glcontext obtained here, and then beautify in onCapturedUnprocessedTextureData, because the glcontext is wrong, it reads black.

    So you need to move effects.initEnv() to the onCapturedUnprocessedTextureData method.

    like it:

    express.enableCustomVideoProcessing( enable: true, config, ZegoPublishChannel.MAIN);
    express.setCustomVideoProcessHandler(new IZegoCustomVideoProcessHandler(){
        @Override
        public void onStart (ZegoPublishChannel channel) {
            Log_i(tag:"ZEGOCLOUD", msg:"[Express] [onStart]");
        }
    
        @override
        public void onStop(ZegoPublishChannel channel) {
            Log_i(tag:"ZEGOCLOUD", msg:"[Express] [onStop]");
            effects.uninitEnv();
        }
    
        @Override
        public void onCapturedUnprocessedTextureData(int textureID, int width, int height, Long referenceTimeMillisecond, ZegoPublishChannel channel) {
            Log.i( tag: "ZEGOCLOUD". msg: "[Exoress] [onCapturedUnprocessedTextureData] textureID:" + textureID + "width:" + width + "height: " + height + ", ts:" + referenceTimeMillisecond);
            
            effects.initEnv(720, 1280);
    
            effectsVideoFrameParam.width = width;
            effectsVideoFrameParam.height = height;
    
    
            int processedTextureID = effects.processTexture(textureID, effectsVideoFrameParam);
    
            express.sendCustomVideoProcessedTextureData(processedTextureID, width, height, referenceTimeMillisecond);
        }
    });