Open MattWanjia opened 4 months ago
Yeah this is technically possible but a bit of a pain to be honest. You would need to obtain an egl context and store it somehow.
On Tue, 23 Jul 2024 at 11:41, MattWanjia @.***> wrote:
Am i able to run this app in the background? Extract the bytes data without having a CameraSurfaceView?
— Reply to this email directly, view it on GitHub https://github.com/quantum6/Android-USB-OTG-Camera/issues/36, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOVTHNQML2DPYJCVHD6BJYDZNYQOPAVCNFSM6AAAAABLKBN5HOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZDINZUGI2TEMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I have managed to get almost everything working atleast in connecting to the camera and opening it without the dependence on a cameraview surface. The issue now comes in when trying to encode the video using a pusher. I get the folloing error.
E FATAL EXCEPTION: Thread-4 Process: com.jiangdg.usbcamera, PID: 9641 java.lang.IllegalArgumentException: at android.media.MediaCodec.native_configure(Native Method) at android.media.MediaCodec.configure(MediaCodec.java:2332) at android.media.MediaCodec.configure(MediaCodec.java:2248) at com.serenegiant.usb.encoder.biz.H264EncodeConsumer.startMediaCodec(H264EncodeConsumer.java:258) at com.serenegiant.usb.encoder.biz.H264EncodeConsumer.run(H264EncodeConsumer.java:137)
this comes from thepiece of code below
`mCameraHelper.startPusher(new AbstractUVCCameraHandler.OnEncodeResultListener() { @Override public void onEncodeResult(byte[] data, int offset, int length, long timestamp, int type) {
//Toast.makeText(getApplicationContext(), String.valueOf(length), Toast.LENGTH_SHORT).show();
Log.d("CAMERAAAAA", String.valueOf(data.length));
// type = 1,h264 video stream
if (type == 1) {
//byte[] encodedData = encodeToH264(data, offset, length, timestamp);
rtmpMuxer.writeVideo(data, 0, length, timestamp);
//if(encodedData != null){
// rtmpMuxer.writeVideo(encodedData, 0, encodedData.length, timestamp);
// Log.d("CAMERAAAAA", String.valueOf(rtmpMuxer.isConnected()));
//}
}
// type = 0,aac audio stream
if(type == 0) {
rtmpMuxer.writeAudio(data, offset, length, timestamp);
}
}
@Override
public void onRecordResult(String videoPath) {
}
});`
Any thoughts?
I am not sure what is your mean. When app push to background: 1, read data and send it to somewhere? I think it's very difficult, Android doesn't allow. 2, What to startup and move to front?
Am i able to run this app in the background? Extract the bytes data without having a CameraSurfaceView?