与前置摄像头的Andr​​oid着录像,MediaRecorder启动失败:-19 [英] Android cant record video with Front Facing Camera, MediaRecorder start failed: -19

查看:214
本文介绍了与前置摄像头的Andr​​oid着录像,MediaRecorder启动失败:-19的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我花了一整天试图解决这个问题,我已经阅读计算器与错误code和其他类似的问题,但似乎没有任何区别的每一篇文章。

Okay so I have spent all day trying to fix this problem, I have read every article on StackOverflow relating to the error code and other similar issues but nothing seems to make any difference.

我有同样的问题,两种不同的code碱基。

I have two different code bases with the same problem.

第一个是code从developer.android.com这里直接复制: <一href="http://developer.android.com/guide/topics/media/camera.html#custom-camera">http://developer.android.com/guide/topics/media/camera.html#custom-camera

第二个是这个code:

<一个href="http://android-er.blogspot.com.au/2011/10/simple-exercise-of-video-capture-using.html">http://android-er.blogspot.com.au/2011/10/simple-exercise-of-video-capture-using.html

无论做工精细与正常的后置摄像头,但只要我尝试使用前置摄像头我得到的错误。

Both work fine with the normal rear camera, but as soon as I try to use the front facing camera I get the error.

这发生在以下设备:

  • 的Nexus S 4.1.2

Galaxy Nexus的4.1.2

的Nexus 7 4.2.1(它只有前置摄像头)

我已经试过什么样子2.2时代相机PARAMS为好,其中一些人声称需要与一些三星和HTC设备,但多个不同的文章引用不同的字符串键:

I have tried what looks like 2.2 era Camera Params as well, which some people claim is required with some Samsung and HTC devices, although multiple different articles reference different String Keys:

c = Camera.open(frontFacingCameraID); // attempt to get a Camera instance
Camera.Parameters params = c.getParameters();
params.set("cam-mode", 1);
params.set("cam_mode", 1);
params.set("camera-id", 1);
c.setParameters(params);

所有这些工作,也请​​大家注意,我检测了正确的前置摄像头ID,它的的Nexus 7当然是:0.但结果上的所有设备在同一个

None of these work, also please note that I am detecting the correct Front Facing Camera ID which on the Nexus 7 is of course: 0. But the results are the same on all the devices.

我已经尝试使用低质量的轮廓试过了,我已经在多种方式尝试设置视频分辨率,连接codeR,输出格式,比特率,帧速率和视频大小手动,但其中没有工作过。

I have tried using low quality profile, I have tried setting the video resolution, encoder, output format, bitrate, frame rate and video size manually in a multitude of ways but none which have worked.

这让我觉得孤单没有错,大多数的code的事情是,普通相机工作正常。所以我的猜测是它的东西做的prepareVideoRecorder()/ prepareMediaRecorder()方法,设置了媒体录像机。

The thing which makes me think theres nothing wrong with most of the code is that the regular camera works fine. So my guess is its something to do with the prepareVideoRecorder() / prepareMediaRecorder() method which sets up the Media Recorder.

有谁知道这个问题什么?也许这是已知的媒体录像机手动编码设置一个前置摄像头的工作?

Does anyone know anything about this issue? Perhaps a Media Recorder manual encoding settings that are known to work on a front facing camera?

我不得不说,Android的相机和MediaRecorder API的吸吮。与iOS的有点乱相比,更不用提一些跨越分散的装置景观可怕看参数不兼容的问题和不同的解决方案。

I have to say, the Android Camera and MediaRecorder API's suck. Compared with iOS its a bit of a mess, not to mention some of the scary looking param incompatibility issues and different resolutions across the fragmented device landscape.

假设我能得到它的工作对我的JB设备,从经验没有人知道,如果大多数问题都与API 15 ICS解决?

Assuming I can get it working on my JB devices, does anyone know from experience if most of these issues are resolved with API 15 ICS?

我会考虑不支持API 10姜饼,如果它的将是太难支持。

I would consider not supporting API 10 Gingerbread if its going to be too hard to support.

推荐答案

好了,我终于有工作之类的。

这个问题似乎肯定涉及到文件的设置,尤其是帧速率。

The issue seems to definately relate to Profile Settings and in particular Frame Rate.

在了Nexus S,我的主要测试设备,如果我试探Camera.Parameters我得到:

On the Nexus S, my main test device if I probe the Camera.Parameters I get:

有关的后置摄像头:
15 FPS 30 FPS,很公平。

For the Rear Camera:
15 FPS to 30 FPS, fair enough.

有关的前置摄像头:
7.5 FPS为30 FPS,没关系。

For the Front Facing Camera:
7.5 FPS to 30 FPS, okay.

然后我检查了档案,我尝试使用,

Then I check the Profiles I am trying to use,:

CamcorderProfile.QUALITY_HIGH
CamcorderProfile.QUALITY_LOW

CamcorderProfile.QUALITY_HIGH
CamcorderProfile.QUALITY_LOW

QUALITY_LOW:
audioBitRate:12200
audioChannels:1
音频codeC:AMR_NB audioSampleRate:8000
持续时间:30
FILEFORMAT:THREE_GPP
质量:0
videoBitRate:256000
视频codeC:H26​​4
videoFrameRate:30
videoFrameWidth:176
videoFrameHeight:144

QUALITY_LOW:
audioBitRate: 12200
audioChannels: 1
audioCodec: AMR_NB audioSampleRate: 8000
duration: 30
fileFormat: THREE_GPP
quality: 0
videoBitRate: 256000
videoCodec: H264
videoFrameRate: 30
videoFrameWidth: 176
videoFrameHeight: 144

QUALITY_HIGH:
audioBitRate:24000
audioChannels:1
音频codeC:AAC
audioSampleRate:16000
持续时间:60
FILEFORMAT:MPEG_4
质量:1
videoBitRate:3000000
视频codeC:H26​​4
videoFrameRate:30
videoFrameWidth:720
videoFrameHeight:480

QUALITY_HIGH:
audioBitRate: 24000
audioChannels: 1
audioCodec: AAC
audioSampleRate: 16000
duration: 60
fileFormat: MPEG_4
quality: 1
videoBitRate: 3000000
videoCodec: H264
videoFrameRate: 30
videoFrameWidth: 720
videoFrameHeight: 480

显然,优质的配置文件是为后置摄像头,看到前方面对的是只有640×480。 但他们都状态30 FPS。

Clearly, the High Quality Profile is meant for the Rear Camera, seeing as the front facing is only 640x480. But they both state 30 FPS.

现在......

继承人的怪事。

如果我设置的任意帧速率后置摄像头,不管是什么配置文件,它与可怕的崩溃:-19错误

If I set ANY frame rate for the rear facing camera, no matter what profile, it crashes with the dreaded: -19 error

mediaRecorder.setVideoFrameRate(fpsInt);

那不是什么大不了的事怎么我不关心的后置摄像头,但奇怪的是,考虑到配置文件默认为30和PARAMS说,他们接受15-30。但是,没有int值IV尝试工作过。如果我ommit的setVideoFrameRate的罚款。

Thats not a big deal coz I dont care about the rear camera but it is weird, considering the profiles are defaulting to 30 and the Params say they accept 15-30. But no int value iv tried has worked. If I ommit the setVideoFrameRate its fine.

无论如何,移动到了前置摄像头。

所以,如果我用QUALITY_LOW模板和帧速率15或更低,它可以神奇地运行。

So, if I use the QUALITY_LOW profile AND set the frame-rate to 15 or lower, it magically works.

mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
mediaRecorder.setVideoFrameRate(15);

逸岸任意值,1 - 15作品。这似乎不可思议。

Infact any value, 1 - 15 works. Which seems weird.

因此​​,继承人的connundrum,我大概可以探测的分辨率,并选择合适的资源对于大多数摄像头,虽然IM也相当有信心,几乎所有的前置摄像头以最小的VGA 640×480。

So heres the connundrum, I can probably probe for resolution and select an appropriate res for most cameras, although im also fairly confident almost all front-facing cameras at minimum VGA 640x480.

但是,这个帧速率? 在Nexus S的情况下,我看不出有什么办法,我可以决定的15或更低的值,而不只是猜测? 如果我的目标是始终使用由摄像头返回的最低帧率?

But, what about the frame rate? In the case of the Nexus S, I don't see any way I could determine the value of 15 or lower without just guessing? Should I aim to always use the LOWEST frame-rate that is returned by the Camera?

予了在一下银河Nexus和它有3个帧速率范围,第一个是15 - 15,第二个是15 - 30。 它的低质量的轮廓类似于albiet更高的分辨率。 如果我使用的Galaxy Nexus的低调似乎很好地工作。

I took at look at the Galaxy Nexus and it has 3 frame rate ranges, the first one is 15 - 15 and the second is 15 - 30. Its low quality profile is similar albiet higher resolution. If I use low profile on Galaxy Nexus it seems to work fine.

通过了Nexus 7,我不能探测CamcorderProfile的我不断收到空指针,这是奇怪的。 它说,它支持4 FPS - 60 FPS。 如果让我选择QUALITY_LOW它你几乎觉得应该工作,它崩溃了,我无法找到一个帧速率,它将与。 尽管错误涉及setProfile,所以我觉得这个问题是内置的配置文件。 当然,Android的API的一点是,其一贯的,这是国旗的船舶设备和FF相机是有视频会议不是它?????

With the Nexus 7, I cant probe the CamcorderProfile's I keep getting null pointers, which is weird. It says it supports 4 FPS - 60 FPS. If I choose QUALITY_LOW which youd think should work, it crashes, and I cant find a frame rate it will work with. Although the error relates to setProfile, so I think the issue is with the built in profile. Surely the point of Android API is that its consistent, this is a flag ship device and the FF camera is there for Video Conferencing isnt it?????

所以,虽然我有工作在两个每次用手动自定义设置的设备,我看不出使其通过code跨多个设备正常工作的一条明路。

So, while I have it working on two of the devices using manual custom settings for each, I can't see a clear way of making it work across multiple devices through code.

看来,Nexus S的不表现它承诺的关于设置的FPS根据其Camera.getParameters()。getSupported previewFpsRange()

It seems that the Nexus S does not behave the way it promises to with regards to setting the FPS as per its Camera.getParameters().getSupportedPreviewFpsRange()

林都乐意为它使用自动FPS设置,但显然它不会与FF相机,那我该怎么办?我已经明确地设置FPS上的Nexus S,在这种情况下,任何东西,从1到15 FPS,尽管摄像头告诉我,它可以处理7.5 - 30 FPS

Im all happy for it to use Auto FPS settings but apparently it wont with the FF camera so what am I supposed to do? I have to explicitly set the FPS on the Nexus S and in this case to anything from 1 to 15 FPS, despite the Camera telling me it handles 7.5 - 30 FPS.

好像setProfile的固定在2.x的所有问题wasnt完全属实的承诺。

我可以理解,如果你写的相机应用为你只是定制,以特定的硬件,这或许可以解释一个特定的ROM为什么人们似乎总是有自定义光盘越野车摄像头的应用程序。但.....怎么下载的视频录制应用程序的工作吗? 他们是定制给每个设备?

I can understand if your writing the Camera App for a particular ROM you just customize it to that particular hardware, which might explain why people seem to always have buggy camera apps on custom roms. BUT..... how do downloadable video recording apps work? Are they custom to each device?

这究竟是为什么孤单还没有Facebook的打招呼和Twitter藤在Android ???? :P

Is this why theres no Facebook Poke and Twitter Vine on Android yet???? :P

妈的谷歌,跆拳道是与你的照相机API?

Shit Google, wtf is with your Camera API?

有谁知道的最佳实践的方法来确定的分辨率和帧速率所有的API 15+兼容的设备?

Does ANYONE know the best practises way to determine resolution and frame-rate for ALL API 15+ compatible devices?

时,即使是可能的,还是我要编写的每一个设备我测试自定义code,然后只是掷骰子的休息吗?

Is that even possible, or am I going to be writing custom code on each device I test and then just roll the dice on the rest?

或者是Nexus S的和Nexus 7只是奇怪的意外?

Or is the Nexus S and the Nexus 7 just freak accidents?

这篇关于与前置摄像头的Andr​​oid着录像,MediaRecorder启动失败:-19的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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