FFMPEG录像机问题 [英] FFMPEG Video Recorder Issue

查看:182
本文介绍了FFMPEG录像机问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 FFmpegVideoRecorder-适用于Android的可自定义视频录制库

在我的视频录制应用中.我按照GitHub上的说明进行操作,并安装了该库.当我运行该应用程序时,出现以下错误.

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)

我使用的代码是这个

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?

推荐答案

您正在使用的库 https://github.com/amosyuen/FFmpegVideoRecorder 最近已处理此错误,当从Camera获取getSupportedFlashModes时遇到此错误.您可以在此处查看最新版本-

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/5844bd9b944cd6e1092

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

这篇关于FFMPEG录像机问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆