-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash onClick of Start recording #6
Comments
Please try and change HBRecorder/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java Line 161 in 2a6a75e
To: path = String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)); |
@HBiSoft Thanks, thats fixed now. However, there are two more exceptions:
|
Try and disable the audio and see if the first issue goes away. |
No changes. Still both the issues exists |
It has something to do with the parameters set, I will look into this and get back to you. In the meantime you can try custom settings and see if there is any settings that works on your device. |
@HBiSoft However, when we set a valid resolution like 480 * 854, 720 * 1280 etc as recorder.videoSize and set it while creating virtualDisplay, it is working fine!!! |
How did you get this dimensions? |
These dimensions I took from your sample. |
Ah ok, I see what the problem is. I set the width and height to be the same as the screen dimension -
But this does not mean it is supported by the device, I will update the application later today. |
Sure. I will look forward to it. Thanks. |
Can you test something for me? -> Create a class in any project and call it import android.content.Context;
import android.content.res.Configuration;
import android.media.CamcorderProfile;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import androidx.annotation.RequiresApi;
import static android.content.Context.WINDOW_SERVICE;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
public class HBRecorderCodecInfo {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void getSupportedSizes(){
RecordingInfo recordingInfo = getRecordingInfo();
Log.e("MaxSupportedSizes --", "WIDTH = "+recordingInfo.width + " HEIGHT = "+recordingInfo.height);
}
private RecordingInfo getRecordingInfo() {
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager wm = (WindowManager) context.getSystemService(WINDOW_SERVICE);
wm.getDefaultDisplay().getRealMetrics(displayMetrics);
int displayWidth = displayMetrics.widthPixels;
int displayHeight = displayMetrics.heightPixels;
int displayDensity = displayMetrics.densityDpi;
Configuration configuration = context.getResources().getConfiguration();
boolean isLandscape = configuration.orientation == ORIENTATION_LANDSCAPE;
CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
int cameraWidth = camcorderProfile != null ? camcorderProfile.videoFrameWidth : -1;
int cameraHeight = camcorderProfile != null ? camcorderProfile.videoFrameHeight : -1;
int cameraFrameRate = camcorderProfile != null ? camcorderProfile.videoFrameRate : 30;
return calculateRecordingInfo(displayWidth, displayHeight, displayDensity, isLandscape,
cameraWidth, cameraHeight, cameraFrameRate, 100);
}
private Context context;
public void setContext(Context c) {
context = c;
}
static final class RecordingInfo {
final int width;
final int height;
final int frameRate;
final int density;
RecordingInfo(int width, int height, int frameRate, int density) {
this.width = width;
this.height = height;
this.frameRate = frameRate;
this.density = density;
}
}
static RecordingInfo calculateRecordingInfo(int displayWidth, int displayHeight, int displayDensity, boolean isLandscapeDevice, int cameraWidth, int cameraHeight, int cameraFrameRate, int sizePercentage) {
// Scale the display size before any maximum size calculations.
displayWidth = displayWidth * sizePercentage / 100;
displayHeight = displayHeight * sizePercentage / 100;
if (cameraWidth == -1 && cameraHeight == -1) {
// No cameras. Fall back to the display size.
return new RecordingInfo(displayWidth, displayHeight, cameraFrameRate, displayDensity);
}
int frameWidth = isLandscapeDevice ? cameraWidth : cameraHeight;
int frameHeight = isLandscapeDevice ? cameraHeight : cameraWidth;
if (frameWidth >= displayWidth && frameHeight >= displayHeight) {
// Frame can hold the entire display. Use exact values.
return new RecordingInfo(displayWidth, displayHeight, cameraFrameRate, displayDensity);
}
// Calculate new width or height to preserve aspect ratio.
if (isLandscapeDevice) {
frameWidth = displayWidth * frameHeight / displayHeight;
} else {
frameHeight = displayHeight * frameWidth / displayWidth;
}
return new RecordingInfo(frameWidth, frameHeight, cameraFrameRate, displayDensity);
}
} Now in your Activity HBRecorderCodecInfo hbRecorderCodecInfo = new HBRecorderCodecInfo();
hbRecorderCodecInfo.setContext(this);
hbRecorderCodecInfo.getSupportedSizes(); Run the application and let me know what the log says, it will be something like:
|
@ritesh-karmare |
@HBiSoft |
@ritesh-karmare HBRecorder/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java Line 369 in 2a6a75e
to mMediaRecorder.setVideoSize(720, 1520); and see if it is working? |
Yes, I did. And it's working! |
Ok I will be updating later today, until then you can use the class above to determine the dimensions if you do not want to wait for the update. |
Sure. I will consider it as resolved and close the issue |
This is now fixed in |
Hi HBBiSoft, In your first comment above, you mentioned changing code inside ScreenRecordService.java, that is a class inside the lib, are you not planning to post an update?
|
@vivek-mittal
|
Got it. But I am not using |
@vivek-mittal HBRecorder/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java Lines 637 to 658 in 584417e
I would recommend implementing it like this. |
Hi @HBiSoft ,
I executed the HBRecorder Example, on click of start button, the app crashes (irrespective of customSettings on/off).
So in logs I can see 2 exceptions:
Following are the logs:
The text was updated successfully, but these errors were encountered: