It is ok when I set output file as **.3gp thank you very much! </br> Deva R <[email protected]> 在 Wed, 17 Nov 2010 01:05:19 写道: </br> </br><div><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div>any log or what error code is returned??</div><div><br></div><div>on quick glance,</div><div>><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">ret = mr->setOutputFile("/system/videoTest.mpeg");</span></div> <div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">?i havent seen any support for mpeg container. try .3gp ?(refer?<a href="http://developer.android.com/guide/appendix/media-formats.html">http://developer.android.com/guide/appendix/media-formats.html</a>?)</span></font></div> <div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; border-collapse: collapse; ">You can refer android camcorder app soruce for reference.,</span></div> <div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><a href="http://git.omapzoom.org/?p=platform/packages/apps/Camera.git;a=blob;f=src/com/android/camera/VideoCamera.java;h=0e04e319e590efec541e010e56d80cacab9ed679;hb=HEAD#l895">http://git.omapzoom.org/?p=platform/packages/apps/Camera.git;a=blob;f=src/com/android/camera/VideoCamera.java;h=0e04e319e590efec541e010e56d80cacab9ed679;hb=HEAD#l895</a></span></font></div> <div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><a href="http://git.omapzoom.org/?p=platform/packages/apps/Camera.git;a=blob;f=src/com/android/camera/VideoCamera.java;h=0e04e319e590efec541e010e56d80cacab9ed679;hb=HEAD#l895"></a><span class="Apple-style-span" style="border-collapse: separate; font-family: arial; "><br> --?<br><div>Regards,</div><div>Deva</div><div><a href="http://www.bittoggler.com/" target="_blank">www.bittoggler.com</a></div><div><br></div></span></span></font><br><div class="gmail_quote">On Tue, Nov 16, 2010 at 4:29 PM, qin xiaofen <span dir="ltr"><<a href="mailto:[email protected]">[email protected]</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">hi, all<br> <br> when I code a demo to record video, but i meet "prepare" error.<br> Following is my steps:<br> 1.create surface<br> 2. create mediarecorder<br> 3. set audio,video endec/format/output file<br> 4. add surface to mediarecorder<br> 5. prepare<br> 6. start<br> <br> #define LOG_TAG "Video_Demo"<br> <br> #include <cutils/memory.h><br> #include <binder/IPCThreadState.h><br> #include <binder/ProcessState.h><br> #include <binder/IServiceManager.h><br> <br> #include <surfaceflinger/Surface.h><br> #include <surfaceflinger/ISurfaceComposer.h><br> #include <surfaceflinger/ISurface.h><br> #include <surfaceflinger/SurfaceComposerClient.h><br> #include <camera/Camera.h><br> #include <camera/ICamera.h><br> #include <media/mediarecorder.h><br> #include <ui/Overlay.h><br> #include <camera/CameraParameters.h><br> #include <utils/Log.h><br> #include <time.h><br> #include <sys/stat.h><br> #include <fcntl.h><br> <br> using namespace android;<br> <br> <br> #define INFO(...) \<br> ? ?do { \<br> ? ? ? ?printf(__VA_ARGS__); \<br> ? ? ? ?printf("\n"); \<br> ? ? ? ?LOGD(__VA_ARGS__); \<br> ? ?} while(0)<br> <br> <br> int main ( )<br> {<br> ? ? ? ?int ret = 0;<br> ? ? ? ?sp<ProcessState> proc(ProcessState::self());<br> ? ? ? ?ProcessState::self()->startThreadPool();<br> <br> ? ? ? ?//sp<Camera> camera = Camera::connect();<br> ? ? ? ?//camera->setPreviewCallbackFlags(FRAME_CALLBACK_FLAG_CAMERA);<br> ? ? ? ?//camera->startPreview();<br> <br> ? ? ? ?//INFO("camera = %p\n", camera.get());<br> <br> ? ? ? ?sp<SurfaceComposerClient> client = new SurfaceComposerClient();<br> ? ? ? ?sp<SurfaceControl> sc = client->createSurface(getpid(), 0, 320, 240, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);<br> ? ? ? ?INFO("SurfaceControl = %p \n", sc.get());<br> ? ? ? ?client->openTransaction();<br> ? ? ? ?sc->setLayer(100000);<br> ? ? ? ?//sc->setSize(640, 480);<br> ? ? ? ?sc->show();<br> ? ? ? ?client->closeTransaction();<br> ? ? ? ?INFO("closeTransaction\n");<br> ? ? ? ?sp<Surface> surface = sc->getSurface();<br> <br> ? ? ? ?INFO("surface = %p\n", surface.get());<br> <br> ? ? ? ?sp<MediaRecorder> mr = new MediaRecorder();<br> <br> ? ? ? ?INFO("mediacorder = %p\n", mr.get());<br> <br> ? ? ? ?ret = mr->init();<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("init error\n");<br> ? ? ? ?}<br> <br> /*<br> ? ? ? ?ret = mr->setCamera(camera->remote());<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setCamera error\n");<br> ? ? ? ?}<br> ? ? ? ?*/<br> <br> ? ? ? ?ret = mr->setAudioSource(AUDIO_SOURCE_MIC);<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setAudioSource error\n");<br> ? ? ? ?}<br> <br> <br> ? ? ? ?ret = mr->setVideoSource(VIDEO_SOURCE_CAMERA);<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setVideoSource error\n");<br> ? ? ? ?}<br> <br> <br> ? ? ? ?ret = mr->setOutputFormat(OUTPUT_FORMAT_MPEG_4);<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setOutputFormat error\n");<br> ? ? ? ?}<br> <br> ? ? ? ?ret = mr->setVideoEncoder(VIDEO_ENCODER_DEFAULT);<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setVideoEncoder error\n");<br> ? ? ? ?}<br> <br> <br> ? ? ? ?ret = mr->setAudioEncoder(AUDIO_ENCODER_AMR_NB);<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setAudioEncoder error\n");<br> ? ? ? ?}<br> ? ? ? ?mr->setVideoSize(200, 200);<br> ? ? ? ?mr->setVideoFrameRate(15);<br> <br> <br> <br> ? ? ? ?ret = mr->setPreviewSurface(surface);<br> ? ? ? ?INFO("setPreviewSurface E28_MOT_PHONE = %d\n", E28_MOT_PHONE);<br> <br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setPreviewSurface error\n");<br> ? ? ? ?}<br> <br> ? ? ? ?ret = mr->setOutputFile("/system/videoTest.mpeg");<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("setOutputFile error\n");<br> ? ? ? ?}<br> <br> <br> ? ? ? ?ret = mr->prepare();<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("prepare error\n");<br> ? ? ? ?}<br> <br> ? ? ? ?ret = mr->start();<br> ? ? ? ?if (ret != NO_ERROR)<br> ? ? ? ?{<br> ? ? ? ? ? ? ? ?INFO("start error\n");<br> ? ? ? ?}<br> <br> ? ? ? ?sleep(15);<br> <br> ? ? ? ?mr->stop();<br> ? ? ? ?mr->release();<br> <br> ? ? ? ?return 0;<br> }<br> <font color="#888888"><br> <br> <br> <br> <br> --<br> unsubscribe: <a href="mailto:android-porting%[email protected]">[email protected]</a><br> website: <a href="http://groups.google.com/group/android-porting" target="_blank">http://groups.google.com/group/android-porting</a><br> </font></blockquote></div><br><br clear="all"><br> </div>
</blockquote></div></br> <br> <br> -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting
