Android的:不能改变编码视频的大小和放大器;如何H.264编码 [英] android : cannot change encoding video size & how to encoding h.264

查看:225
本文介绍了Android的:不能改变编码视频的大小和放大器;如何H.264编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的HTC Desire(Android版2.3.3,API 9级)。我试图写一个程序来录制320x240的H.263视频。无需任何设置,code运作良好,并输出分辨率为177x144。但它总是当我设置视频大小崩溃。而且我发现只有Android 3.0以上版本支持H.264编码,我想知道如何做到这一点在Android 2.1+?我将是一个解决方案,要么问题表示感谢。下面是我在做什么和日志

 录音机=新MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEn codeR(MediaRecorder.AudioEn coder.AMR_NB);
recorder.setAudioChannels(1);
recorder.setVideoEn codeR(MediaRecorder.VideoEn coder.H263);
recorder.setVideoEncodingBitRate(141000);
recorder.setVideoSize(320240);
recorder.setMaxDuration(30000);

有是日志

  08-11 21:57:32.048:ERROR / AndroidRuntime(9546):致命异常:主要
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):java.lang.IllegalStateException
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.media.MediaRecorder.start(本机方法)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在com.mobvcasting.camcorder.CamcorderView.startRecording(CamcorderView.java:75)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在com.mobvcasting.camcorder.Camcorder.onKeyDown(Camcorder.java:36)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.view.KeyEvent.dispatch(KeyEvent.java:1256)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.app.Activity.dispatchKeyEvent(Activity.java:2102)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchKeyEvent(PhoneWindow.java:1666)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2574)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2549)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.view.ViewRoot.handleMessage(ViewRoot.java:1881)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.os.Handler.dispatchMessage(Handler.java:99)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.os.Looper.loop(Looper.java:130)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在android.app.ActivityThread.main(ActivityThread.java:3694)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在java.lang.reflect.Method.invokeNative(本机方法)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在java.lang.reflect.Method.invoke(Method.java:507)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-11 21:57:32.048:ERROR / AndroidRuntime(9546):在dalvik.system.NativeStart.main(本机方法)


解决方案

根据你不能在2.1这样做(只在3.0 +)这个链接。它根本就无法做到的。

I have an HTC Desire (Android 2.3.3, API level 9). I am trying to write a program to record 320x240 h.263 video. Without any settings, the code works well and the output resolution is 177x144. But it always crashes when I set the video size. And I find that only android 3.0+ support encoding h.264, I want to know how to do that on android 2.1+? I would be grateful for a solution to either issue. Here is what I am doing and the log

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioChannels(1);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
recorder.setVideoEncodingBitRate(141000);
recorder.setVideoSize(320,240);
recorder.setMaxDuration(30000);

There is the log

08-11 21:57:32.048: ERROR/AndroidRuntime(9546): FATAL EXCEPTION: main
08-11 21:57:32.048: ERROR/AndroidRuntime(9546): java.lang.IllegalStateException
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.media.MediaRecorder.start(Native Method)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at com.mobvcasting.camcorder.CamcorderView.startRecording(CamcorderView.java:75)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at com.mobvcasting.camcorder.Camcorder.onKeyDown(Camcorder.java:36)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.view.KeyEvent.dispatch(KeyEvent.java:1256)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.app.Activity.dispatchKeyEvent(Activity.java:2102)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1666)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2574)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2549)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1881)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.os.Looper.loop(Looper.java:130)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at android.app.ActivityThread.main(ActivityThread.java:3694)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at java.lang.reflect.Method.invokeNative(Native Method)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at java.lang.reflect.Method.invoke(Method.java:507)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-11 21:57:32.048: ERROR/AndroidRuntime(9546):     at dalvik.system.NativeStart.main(Native Method)

解决方案

According to this link you cannot do this in 2.1 (only in 3.0+). It simply cannot be done.

这篇关于Android的:不能改变编码视频的大小和放大器;如何H.264编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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