相机输入:不支持的参数

发布于 2024-12-22 18:56:05 字数 2390 浏览 2 评论 0原文

首先,请原谅它已经被问过或者可以通过谷歌轻松找到。我发布此内容是因为我的时间有限。这是录制音频和视频的代码。

        stopPreview();

        Log.d("streamer", "Start camera.....");
        videoRecorder = new MediaRecorder();
        videoRecorder.setPreviewDisplay(surfaceView.getHolder()
                .getSurface());
        videoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
        videoRecorder.setVideoSize(800, 600);
        videoRecorder.setVideoFrameRate(30);
        videoRecorder.setOutputFile(videoPipe.getOutput());
        videoRecorder.prepare();
        videoRecorder.start();
        Log.d("streamer", "Start camera.....action.......");

        Log.d("streamer", "Start mic.....");
        audioRecorder = new MediaRecorder();
        audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
        audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        audioRecorder.setOutputFile(audioPipe.getOutput());
        audioRecorder.prepare();
        audioRecorder.start();
        Log.d("streamer", "Start mic.....action");

但是,当我运行它时,上面的代码在 logcat 上生成以下内容。

12-22 09:05:43.456: E/CameraInput(2407): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0

.....
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 2
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 1
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 3

并且,显示预览的表面视图似乎被冻结了。它显示最后拍摄的图像帧。此外,视频和音频似乎没有录制。会出现什么问题呢?非常感谢任何帮助!

注意:

我正在运行 Android 2.2 的 Samsung Galaxy Tab 上尝试此操作。

注释以下两行似乎也不能解决问题

        videoRecorder.setVideoSize(800, 600);
        videoRecorder.setVideoFrameRate(30);

以下权限是在清单文件上设置的。

<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

Firstly, please forgive it is already asked one or can be find easily with Google. I am posting this since I do have only limited time. Here is code to record audio and video.

        stopPreview();

        Log.d("streamer", "Start camera.....");
        videoRecorder = new MediaRecorder();
        videoRecorder.setPreviewDisplay(surfaceView.getHolder()
                .getSurface());
        videoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
        videoRecorder.setVideoSize(800, 600);
        videoRecorder.setVideoFrameRate(30);
        videoRecorder.setOutputFile(videoPipe.getOutput());
        videoRecorder.prepare();
        videoRecorder.start();
        Log.d("streamer", "Start camera.....action.......");

        Log.d("streamer", "Start mic.....");
        audioRecorder = new MediaRecorder();
        audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
        audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        audioRecorder.setOutputFile(audioPipe.getOutput());
        audioRecorder.prepare();
        audioRecorder.start();
        Log.d("streamer", "Start mic.....action");

But, when I run it, the above code produces the following on logcat.

12-22 09:05:43.456: E/CameraInput(2407): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0

.....
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 2
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 1
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 3

And, the surface view showing preview seems to be freezed. It shows last taken frame of image. Also, the video & audio doesn't seems to be recording. What will be the problem? Any help is very much appreciated!

NOTE:

I am trying this on Samsung Galaxy Tab with Android 2.2.

Commenting the following two lines also doesn't seems to solve the problem

        videoRecorder.setVideoSize(800, 600);
        videoRecorder.setVideoFrameRate(30);

The following permissions are set on the manifest file.

<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶ ̄淡然 2024-12-29 18:56:06

如果您看到 MPEG-4 SP 的支持的媒体格式,您需要使用 3GP (THREE_GPP) 输出格式。
所以你可以尝试

videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

If you see the Supported Media Formats, for MPEG-4 SP, you need to use 3GP (THREE_GPP) output format.
So you can try with

videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文