FFMPEG Video Recorder Issue
Asked Answered
L

1

1

I'm using FFmpegVideoRecorder - Customizable Video Recording Library for Android

in my app for video recording. I followed the instructions on GitHub and installed the library. When I run the app I'm getting the following error.

Error opening camera
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference
at com.google.common.collect.ImmutableSet.copyOf(ImmutableSet.java:247)
    at com.amosyuen.videorecorder.camera.CameraController.setFlashModeParams(CameraController.java:383)
    at com.amosyuen.videorecorder.camera.CameraController.openCamera(CameraController.java:175)
    at com.amosyuen.videorecorder.activity.FFmpegRecorderActivity$OpenCameraTask.doInBackground(FFmpegRecorderActivity.java:718)
    at com.amosyuen.videorecorder.activity.FFmpegRecorderActivity$OpenCameraTask.doInBackground(FFmpegRecorderActivity.java:706)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

The code which I have used is this

recordbtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                    String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                    String videoSTVString = "/sdcard/myapp_"+ date +".mp4";
                    prefs.edit().putString("videoSTVString", videoSTVString).commit();

                    String thumbnailString = "/sdcard/myapp_thumbnail_"+ date +".jpg";

                    File stvVideoFile = new File(videoSTVString);
                    File stvThumbnailFile = new File(thumbnailString);

                    startActivity(stvVideoFile, stvThumbnailFile);


                }
            });

public void startActivity(File videoFile, File thumbnailFile) {
    FFmpegRecorderActivityParams.Builder paramsBuilder =
            FFmpegRecorderActivityParams.builder(getApplicationContext())
                    .setVideoOutputFileUri(videoFile)
                    .setVideoThumbnailOutputFileUri(thumbnailFile);

    paramsBuilder.recorderParamsBuilder()
            .setVideoSize(new ImageSize(640, 480))
            .setVideoCodec(EncoderParamsI.VideoCodec.H264)
            .setVideoBitrate(100000)
            .setVideoFrameRate(30)
            .setVideoImageFit(ImageFit.FILL)
            .setVideoImageScale(ImageScale.DOWNSCALE)
            .setShouldCropVideo(true)
            .setShouldPadVideo(true)
            .setVideoCameraFacing(CameraControllerI.Facing.BACK)
            .setAudioCodec(EncoderParamsI.AudioCodec.AAC)
            .setAudioSamplingRateHz(44100)
            .setAudioBitrate(100000)
            .setAudioChannelCount(2)
            .setOutputFormat(EncoderParamsI.OutputFormat.MP4);

    Intent intent = new Intent(this, FFmpegRecorderActivity.class);
    intent.putExtra(FFmpegRecorderActivity.REQUEST_PARAMS_KEY, paramsBuilder.build());
    startActivityForResult(intent, 1000);

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1000) {
        switch (resultCode) {
            case RESULT_OK:
               Uri videoUri = data.getData();
            break;
        case Activity.RESULT_CANCELED:
            break;
        case FFmpegRecorderActivity.RESULT_ERROR:
            break;
       }
    }
}

Could anyone please help me resolve this bug?

Ladonna answered 26/8, 2019 at 5:34 Comment(1)
Have this issue fixed? I am also getting a similar issueGaylordgaylussac
S
1

The library you are using, https://github.com/amosyuen/FFmpegVideoRecorder has recently handled this error, this error is encountered when getting getSupportedFlashModes from Camera. You can check recent build here -

https://github.com/amosyuen/FFmpegVideoRecorder/commit/5844bd9b944cd6efa1e93278d35b95d1092c6016

Sasser answered 26/8, 2019 at 8:33 Comment(6)
Is it possible to edit the files inside the library? When I tried it showed that it's a read-only file. I'd installed it using implementation 'com.amosyuen.ffmpegvideorecorder:ffmpeg-video-recorder:2.0.3'Ladonna
Just Clean the Project and recompile the library, may be you resolve your error.Sasser
I cleaned and recompiled the library, now I'm getting the following error: E/FFmpegRecorderActivity: Error opening camera java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.<init>(Camera.java:546) at android.hardware.Camera.open(Camera.java:392)Ladonna
When I tested the same in One Plus 6T, I'm getting this error: E/libc: Access denied finding property "vendor.debug.egl.swapinterval" 2019-08-26 17:51:48.148 987-987/? E/FFmpegRecorderActivity: Error opening camera java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.<init>(Camera.java:764) at android.hardware.Camera.open(Camera.java:560)Ladonna
You can see here for camera problem: #23904959Sasser
Even when I cleaned and recompiled the library the getSupportedFlashModes is the same as before. It didn't get updated according to the link you shared above. What could be the reason?Ladonna

© 2022 - 2024 — McMap. All rights reserved.