[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
On Friday, March 25, 2016 at 12:29:57 AM UTC-7, gjs wrote: > > Hi again, > > Well I suspect you are also getting low resolution / low quality video due > to missing - > > mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); > > > See http://developer.android.com/guide/topics/media/camera.html > > Ok, I think this is working. The thing seems fragile, but it appears the resolution is higher. I can see the metadata now, and the resolution metadata is higher than it used to be, and the video looks that way. Doing this without the information in that javadoc emphasizes how careful you have to be in the ordering of these things. I was also getting some occurrences of "Method called after release()". I looked at some of the fixes for this, but they also seemed unreliable. In any case, I stopped seeing that error. > - you could verify that by examining the metadata / properties of the video > you have already recorded. > > > Regards > > > On Friday, March 25, 2016 at 11:58:15 AM UTC+11, David Karr wrote: >> >> >> >> On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: >>> >>> Hi, >>> >>> Re - I imagine I'm doing something horribly wrong, >>> >>> Well yes, particularly for this code, calling methods on a null object >>> ??? - >>> >>> if (mCamera == null) { >>> mCamera.setPreviewDisplay(holder); ... >>> >>> >>> I'd suggest waiting a little after starting the Camera Preview before >>> initiating a call to autofocus, say 500ms to 1 second, this is to give the >>> camera some time to settle after it has just been opened. >>> >>> >>> I'd also suggest that you do this asynchronously, eg - >>> >>> >>> // Need handler for callbacks to the UI thread >>> final Handler mHandler = new Handler(); >>> >>> >>> mHandler.postDelayed(new Runnable() >>> { >>>@Override >>>public void run() >>>{ >>> doAutoFocus(.. >>>} >>> >>> }, 500 ); >>> >>> >>> Regards >>> >>> >> Ok, well, the good news is that doing this let it get into the callback >> with success == true. And I think I saw the preview display sharpen. >> However, the resulting stored video seems to be the same. It's still >> fuzzy. >> >> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/f2af5403-005c-433d-beca-9af0c5af5717%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
Hi, To check the video metadata / properties I'd transfer the .mp4 video file(s) you have recorded with your app from your Android device to a PC, then use VLC ( http://www.videolan.org/vlc/index.html ) and select Media Information->Code Details and examine the Resolution values. High Quality / resolution would be 1920x1080 or better and Low quality would be something like 640x480 or less, the exact values will depend on the Android device used for your video recordings... Regards On Saturday, March 26, 2016 at 7:17:09 AM UTC+11, David Karr wrote: > > On Friday, March 25, 2016 at 12:29:57 AM UTC-7, gjs wrote: >> >> Hi again, >> >> Well I suspect you are also getting low resolution / low quality video >> due to missing - >> >> mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); >> >> >> See http://developer.android.com/guide/topics/media/camera.html >> >> >> - you could verify that by examining the metadata / properties of the video >> you have already recorded. >> >> > And how exactly do I do that? I found an app that shows the metadata of > videos, and I opened one of my recorded videos with that. It shows a > "Properties" list, along with a "View Atom Structure" function. How can I > tell from this whether it's "high quality" or not? > >> >> Regards >> >> >> On Friday, March 25, 2016 at 11:58:15 AM UTC+11, David Karr wrote: >>> >>> >>> >>> On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: Hi, Re - I imagine I'm doing something horribly wrong, Well yes, particularly for this code, calling methods on a null object ??? - if (mCamera == null) { mCamera.setPreviewDisplay(holder); ... I'd suggest waiting a little after starting the Camera Preview before initiating a call to autofocus, say 500ms to 1 second, this is to give the camera some time to settle after it has just been opened. I'd also suggest that you do this asynchronously, eg - // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); mHandler.postDelayed(new Runnable() { @Override public void run() { doAutoFocus(.. } }, 500 ); Regards >>> Ok, well, the good news is that doing this let it get into the callback >>> with success == true. And I think I saw the preview display sharpen. >>> However, the resulting stored video seems to be the same. It's still >>> fuzzy. >>> >>> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/7208b83c-6224-4361-8f87-b2983680d5c4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
On Friday, March 25, 2016 at 12:29:57 AM UTC-7, gjs wrote: > > Hi again, > > Well I suspect you are also getting low resolution / low quality video due > to missing - > > mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); > > > See http://developer.android.com/guide/topics/media/camera.html > > > - you could verify that by examining the metadata / properties of the video > you have already recorded. > > And how exactly do I do that? I found an app that shows the metadata of videos, and I opened one of my recorded videos with that. It shows a "Properties" list, along with a "View Atom Structure" function. How can I tell from this whether it's "high quality" or not? > > Regards > > > On Friday, March 25, 2016 at 11:58:15 AM UTC+11, David Karr wrote: >> >> >> >> On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: >>> >>> Hi, >>> >>> Re - I imagine I'm doing something horribly wrong, >>> >>> Well yes, particularly for this code, calling methods on a null object >>> ??? - >>> >>> if (mCamera == null) { >>> mCamera.setPreviewDisplay(holder); ... >>> >>> >>> I'd suggest waiting a little after starting the Camera Preview before >>> initiating a call to autofocus, say 500ms to 1 second, this is to give the >>> camera some time to settle after it has just been opened. >>> >>> >>> I'd also suggest that you do this asynchronously, eg - >>> >>> >>> // Need handler for callbacks to the UI thread >>> final Handler mHandler = new Handler(); >>> >>> >>> mHandler.postDelayed(new Runnable() >>> { >>>@Override >>>public void run() >>>{ >>> doAutoFocus(.. >>>} >>> >>> }, 500 ); >>> >>> >>> Regards >>> >>> >> Ok, well, the good news is that doing this let it get into the callback >> with success == true. And I think I saw the preview display sharpen. >> However, the resulting stored video seems to be the same. It's still >> fuzzy. >> >> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/63682c47-6a44-45a2-9c33-a97941e4cc93%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
Hi again, Well I suspect you are also getting low resolution / low quality video due to missing - mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); See http://developer.android.com/guide/topics/media/camera.html - you could verify that by examining the metadata / properties of the video you have already recorded. Regards On Friday, March 25, 2016 at 11:58:15 AM UTC+11, David Karr wrote: > > > > On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: >> >> Hi, >> >> Re - I imagine I'm doing something horribly wrong, >> >> Well yes, particularly for this code, calling methods on a null object >> ??? - >> >> if (mCamera == null) { >> mCamera.setPreviewDisplay(holder); ... >> >> >> I'd suggest waiting a little after starting the Camera Preview before >> initiating a call to autofocus, say 500ms to 1 second, this is to give the >> camera some time to settle after it has just been opened. >> >> >> I'd also suggest that you do this asynchronously, eg - >> >> >> // Need handler for callbacks to the UI thread >> final Handler mHandler = new Handler(); >> >> >> mHandler.postDelayed(new Runnable() >> { >>@Override >>public void run() >>{ >> doAutoFocus(.. >>} >> >> }, 500 ); >> >> >> Regards >> >> > Ok, well, the good news is that doing this let it get into the callback > with success == true. And I think I saw the preview display sharpen. > However, the resulting stored video seems to be the same. It's still > fuzzy. > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/4464ffeb-02e2-4c9a-9372-582ad4cfdc94%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: > > Hi, > > Re - I imagine I'm doing something horribly wrong, > > Well yes, particularly for this code, calling methods on a null object ??? > - > > if (mCamera == null) { > mCamera.setPreviewDisplay(holder); ... > > > I'd suggest waiting a little after starting the Camera Preview before > initiating a call to autofocus, say 500ms to 1 second, this is to give the > camera some time to settle after it has just been opened. > > > I'd also suggest that you do this asynchronously, eg - > > > // Need handler for callbacks to the UI thread > final Handler mHandler = new Handler(); > > > mHandler.postDelayed(new Runnable() > { >@Override >public void run() >{ > doAutoFocus(.. >} > > }, 500 ); > > > Regards > > Ok, well, the good news is that doing this let it get into the callback with success == true. And I think I saw the preview display sharpen. However, the resulting stored video seems to be the same. It's still fuzzy. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/7bd14e04-5edf-4d35-9d84-233190daaa0d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
On Thursday, March 24, 2016 at 3:49:52 PM UTC-7, gjs wrote: > > Hi, > > Re - I imagine I'm doing something horribly wrong, > > Well yes, particularly for this code, calling methods on a null object ??? > - > > if (mCamera == null) { > mCamera.setPreviewDisplay(holder); ... > > *smacking oneself in head* In reality, it didn't even matter, because it never got to that block with mCamera == null. I copied this from a sample on the internet. "It must be true, right?" > > I'd suggest waiting a little after starting the Camera Preview before > initiating a call to autofocus, say 500ms to 1 second, this is to give the > camera some time to settle after it has just been opened. > > > I'd also suggest that you do this asynchronously, eg - > > > // Need handler for callbacks to the UI thread > final Handler mHandler = new Handler(); > > > mHandler.postDelayed(new Runnable() > { >@Override >public void run() >{ > doAutoFocus(.. >} > > }, 500 ); > > > Regards > > Ok. I'll give that a try. > > > On Thursday, March 24, 2016 at 12:11:11 PM UTC+11, David Karr wrote: >> >> On Wednesday, March 23, 2016 at 12:06:47 AM UTC-7, gjs wrote: >> >> Hi, >> >> For the focus / fuzzy issue try initiating auto focusing of the camera >> before you start recording your video - >> >> >> http://developer.android.com/reference/android/hardware/Camera.html#autoFocus(android.hardware.Camera.AutoFocusCallback) >> >> >> Thanks for replying. I imagine I'm doing something horribly wrong, but >> I'm not getting much from this. I made a change in my "CameraPreview" >> class to add this call, in the "surfaceCreated()" method. It now looks >> like this, which will immediately look odd: >> >> public void surfaceCreated(SurfaceHolder holder) { >> try { >> // create the surface and start camera preview >> if (mCamera == null) { >> mCamera.setPreviewDisplay(holder); >> mCamera.startPreview(); >> mCamera.autoFocus(new Camera.AutoFocusCallback() { >> @Override >> public void onAutoFocus(boolean success, Camera camera) { >> Log.d(VIEW_LOG_TAG, "Completed autofocus setup: >> success[" + success + "]"); >> } >> }); >> } >> else { >> mCamera.setPreviewDisplay(holder); >> mCamera.startPreview(); >> mCamera.autoFocus(new Camera.AutoFocusCallback() { >> @Override >> public void onAutoFocus(boolean success, Camera camera) { >> Log.d(VIEW_LOG_TAG, "Completed autofocus setup: >> success[" + success + "]"); >> } >> }); >> } >> } catch (IOException e) { >> Log.d(VIEW_LOG_TAG, "Error setting camera preview: " + >> e.getMessage()); >> } >> } >> >> >> >> >> Yes, I'm calling that block for both the null and !null case. I did that >> because when I ran in the debugger, I saw that it never got into the "== >> null" block, so I'm experimenting with calling it when it's not null. In >> any case, it calls the "autofocus()" method, but the "onAutoFocus()" method >> is never called. At one point when it retrieves the "Camera.Parameters" >> object, I added a log statement for "focusMode", and it prints "auto". And >> it doesn't appear to be focusing. >> >> >> >> - you can also do this whilst the video is recording as well, although >> you will have periods of a few seconds where focus is lost before being >> regained. >> >> Note sure about upside down video, I suspect this not the video recording >> but perhaps some Camera Preview rotation mismatch / issue in your >> CameraPreview class ? Compare the Camera Preview orientation in your app >> vs when you use the default Camera App. (NOTE also that Nexus 5X has some >> wrong camera preview orientation issues...) >> >> Regards >> >> >> >> On Wednesday, March 23, 2016 at 3:41:02 PM UTC+11, David Karr wrote: >> >> I've assembled a relatively small camcorder app. It only does what I need >> it to do. I assembled it from sample code, and some people on this forum >> have helped me fix some of the problems with it, although some of the >> details of interfacing with the camera are beyond me. >> >> After some usage of it, I've realized there are two problems with it: >> >> * Although the preview display is right-side up, the resulting stored >> video is upside down. This isn't a huge deal, as I later process this with >> another app that lets me rotate it till its right-side up, but it's still >> an annoyance, especially when previewing many videos to see which ones I >> want to use. >> >> * The video it produces is just fuzzy, or out of focus. I don't know >> whether this is the nature of video vs. still images or whether I'm not >> doing something I should be doing. Is there some autofocus feature of the >> camcorder that I'm not taking
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
Hi, Re - I imagine I'm doing something horribly wrong, Well yes, particularly for this code, calling methods on a null object ??? - if (mCamera == null) { mCamera.setPreviewDisplay(holder); ... I'd suggest waiting a little after starting the Camera Preview before initiating a call to autofocus, say 500ms to 1 second, this is to give the camera some time to settle after it has just been opened. I'd also suggest that you do this asynchronously, eg - // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); mHandler.postDelayed(new Runnable() { @Override public void run() { doAutoFocus(.. } }, 500 ); Regards On Thursday, March 24, 2016 at 12:11:11 PM UTC+11, David Karr wrote: > > On Wednesday, March 23, 2016 at 12:06:47 AM UTC-7, gjs wrote: > > Hi, > > For the focus / fuzzy issue try initiating auto focusing of the camera > before you start recording your video - > > > http://developer.android.com/reference/android/hardware/Camera.html#autoFocus(android.hardware.Camera.AutoFocusCallback) > > > Thanks for replying. I imagine I'm doing something horribly wrong, but > I'm not getting much from this. I made a change in my "CameraPreview" > class to add this call, in the "surfaceCreated()" method. It now looks > like this, which will immediately look odd: > > public void surfaceCreated(SurfaceHolder holder) { > try { > // create the surface and start camera preview > if (mCamera == null) { > mCamera.setPreviewDisplay(holder); > mCamera.startPreview(); > mCamera.autoFocus(new Camera.AutoFocusCallback() { > @Override > public void onAutoFocus(boolean success, Camera camera) { > Log.d(VIEW_LOG_TAG, "Completed autofocus setup: success[" > + success + "]"); > } > }); > } > else { > mCamera.setPreviewDisplay(holder); > mCamera.startPreview(); > mCamera.autoFocus(new Camera.AutoFocusCallback() { > @Override > public void onAutoFocus(boolean success, Camera camera) { > Log.d(VIEW_LOG_TAG, "Completed autofocus setup: success[" > + success + "]"); > } > }); > } > } catch (IOException e) { > Log.d(VIEW_LOG_TAG, "Error setting camera preview: " + > e.getMessage()); > } > } > > > > > Yes, I'm calling that block for both the null and !null case. I did that > because when I ran in the debugger, I saw that it never got into the "== > null" block, so I'm experimenting with calling it when it's not null. In > any case, it calls the "autofocus()" method, but the "onAutoFocus()" method > is never called. At one point when it retrieves the "Camera.Parameters" > object, I added a log statement for "focusMode", and it prints "auto". And > it doesn't appear to be focusing. > > > > - you can also do this whilst the video is recording as well, although you > will have periods of a few seconds where focus is lost before being > regained. > > Note sure about upside down video, I suspect this not the video recording > but perhaps some Camera Preview rotation mismatch / issue in your > CameraPreview class ? Compare the Camera Preview orientation in your app > vs when you use the default Camera App. (NOTE also that Nexus 5X has some > wrong camera preview orientation issues...) > > Regards > > > > On Wednesday, March 23, 2016 at 3:41:02 PM UTC+11, David Karr wrote: > > I've assembled a relatively small camcorder app. It only does what I need > it to do. I assembled it from sample code, and some people on this forum > have helped me fix some of the problems with it, although some of the > details of interfacing with the camera are beyond me. > > After some usage of it, I've realized there are two problems with it: > > * Although the preview display is right-side up, the resulting stored > video is upside down. This isn't a huge deal, as I later process this with > another app that lets me rotate it till its right-side up, but it's still > an annoyance, especially when previewing many videos to see which ones I > want to use. > > * The video it produces is just fuzzy, or out of focus. I don't know > whether this is the nature of video vs. still images or whether I'm not > doing something I should be doing. Is there some autofocus feature of the > camcorder that I'm not taking advantage of? > > I'd appreciate any useful advice on this. > > I'll provide here the entire Activity class. > > package com.integralsoftware.videograbber; > > import android.content.Intent; > import android.media.AudioFormat; > import android.media.AudioManager; > import android.media.AudioTrack; > import android.media.MediaScannerConnection; > import android.net.Uri; > import android.os.Bundle; > import android.os.Environment; > import
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
On Wednesday, March 23, 2016 at 12:06:47 AM UTC-7, gjs wrote: > > Hi, > > For the focus / fuzzy issue try initiating auto focusing of the camera > before you start recording your video - > > > http://developer.android.com/reference/android/hardware/Camera.html#autoFocus(android.hardware.Camera.AutoFocusCallback) > Thanks for replying. I imagine I'm doing something horribly wrong, but I'm not getting much from this. I made a change in my "CameraPreview" class to add this call, in the "surfaceCreated()" method. It now looks like this, which will immediately look odd: public void surfaceCreated(SurfaceHolder holder) { try { // create the surface and start camera preview if (mCamera == null) { mCamera.setPreviewDisplay(holder); mCamera.startPreview(); mCamera.autoFocus(new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) { Log.d(VIEW_LOG_TAG, "Completed autofocus setup: success[" + success + "]"); } }); } else { mCamera.setPreviewDisplay(holder); mCamera.startPreview(); mCamera.autoFocus(new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) { Log.d(VIEW_LOG_TAG, "Completed autofocus setup: success[" + success + "]"); } }); } } catch (IOException e) { Log.d(VIEW_LOG_TAG, "Error setting camera preview: " + e.getMessage()); } } Yes, I'm calling that block for both the null and !null case. I did that because when I ran in the debugger, I saw that it never got into the "== null" block, so I'm experimenting with calling it when it's not null. In any case, it calls the "autofocus()" method, but the "onAutoFocus()" method is never called. At one point when it retrieves the "Camera.Parameters" object, I added a log statement for "focusMode", and it prints "auto". And it doesn't appear to be focusing. > > - you can also do this whilst the video is recording as well, although you > will have periods of a few seconds where focus is lost before being > regained. > > Note sure about upside down video, I suspect this not the video recording > but perhaps some Camera Preview rotation mismatch / issue in your > CameraPreview class ? Compare the Camera Preview orientation in your app > vs when you use the default Camera App. (NOTE also that Nexus 5X has some > wrong camera preview orientation issues...) > > Regards > > > > On Wednesday, March 23, 2016 at 3:41:02 PM UTC+11, David Karr wrote: > > I've assembled a relatively small camcorder app. It only does what I need > it to do. I assembled it from sample code, and some people on this forum > have helped me fix some of the problems with it, although some of the > details of interfacing with the camera are beyond me. > > After some usage of it, I've realized there are two problems with it: > > * Although the preview display is right-side up, the resulting stored > video is upside down. This isn't a huge deal, as I later process this with > another app that lets me rotate it till its right-side up, but it's still > an annoyance, especially when previewing many videos to see which ones I > want to use. > > * The video it produces is just fuzzy, or out of focus. I don't know > whether this is the nature of video vs. still images or whether I'm not > doing something I should be doing. Is there some autofocus feature of the > camcorder that I'm not taking advantage of? > > I'd appreciate any useful advice on this. > > I'll provide here the entire Activity class. > > package com.integralsoftware.videograbber; > > import android.content.Intent; > import android.media.AudioFormat; > import android.media.AudioManager; > import android.media.AudioTrack; > import android.media.MediaScannerConnection; > import android.net.Uri; > import android.os.Bundle; > import android.os.Environment; > import android.util.Log; > import android.view.View; > > import java.io.File; > import java.io.IOException; > import java.text.SimpleDateFormat; > import java.util.Date; > > import android.app.Activity; > import android.content.Context; > import android.content.pm.PackageManager; > import android.hardware.Camera; > import android.hardware.Camera.CameraInfo; > import android.media.MediaRecorder; > import android.view.View.OnClickListener; > import android.view.WindowManager; > import android.view.animation.AlphaAnimation; > import android.view.animation.Animation; > import android.widget.Button; > import android.widget.LinearLayout; > import android.widget.TextView; > import android.widget.Toast; > > public class VideoGrabberActivity extends Activity { > private Camera mCamera; > private CameraPreview mPreview; > private MediaRecorder mediaRecorder; >
[android-developers] Re: Camcorder app produces video that is out of focus, and upside down
Hi, For the focus / fuzzy issue try initiating auto focusing of the camera before you start recording your video - http://developer.android.com/reference/android/hardware/Camera.html#autoFocus(android.hardware.Camera.AutoFocusCallback) - you can also do this whilst the video is recording as well, although you will have periods of a few seconds where focus is lost before being regained. Note sure about upside down video, I suspect this not the video recording but perhaps some Camera Preview rotation mismatch / issue in your CameraPreview class ? Compare the Camera Preview orientation in your app vs when you use the default Camera App. (NOTE also that Nexus 5X has some wrong camera preview orientation issues...) Regards On Wednesday, March 23, 2016 at 3:41:02 PM UTC+11, David Karr wrote: > > I've assembled a relatively small camcorder app. It only does what I need > it to do. I assembled it from sample code, and some people on this forum > have helped me fix some of the problems with it, although some of the > details of interfacing with the camera are beyond me. > > After some usage of it, I've realized there are two problems with it: > > * Although the preview display is right-side up, the resulting stored > video is upside down. This isn't a huge deal, as I later process this with > another app that lets me rotate it till its right-side up, but it's still > an annoyance, especially when previewing many videos to see which ones I > want to use. > > * The video it produces is just fuzzy, or out of focus. I don't know > whether this is the nature of video vs. still images or whether I'm not > doing something I should be doing. Is there some autofocus feature of the > camcorder that I'm not taking advantage of? > > I'd appreciate any useful advice on this. > > I'll provide here the entire Activity class. > > package com.integralsoftware.videograbber; > > import android.content.Intent; > import android.media.AudioFormat; > import android.media.AudioManager; > import android.media.AudioTrack; > import android.media.MediaScannerConnection; > import android.net.Uri; > import android.os.Bundle; > import android.os.Environment; > import android.util.Log; > import android.view.View; > > import java.io.File; > import java.io.IOException; > import java.text.SimpleDateFormat; > import java.util.Date; > > import android.app.Activity; > import android.content.Context; > import android.content.pm.PackageManager; > import android.hardware.Camera; > import android.hardware.Camera.CameraInfo; > import android.media.MediaRecorder; > import android.view.View.OnClickListener; > import android.view.WindowManager; > import android.view.animation.AlphaAnimation; > import android.view.animation.Animation; > import android.widget.Button; > import android.widget.LinearLayout; > import android.widget.TextView; > import android.widget.Toast; > > public class VideoGrabberActivity extends Activity { > private Camera mCamera; > private CameraPreview mPreview; > private MediaRecorder mediaRecorder; > private Button capture; > private Context myContext; > private LinearLayoutcameraPreview; > private TextViewcountdownText; > private String outputFilePath; > private SimpleDateFormatsimpleDateFormat= new SimpleDateFormat > ("MMdd_HHmmss"); > > private static final String VG = "VideoGrabber"; > > private static final intRS_WAITING = 0; > private static final intRS_COUNTING = 1; > private static final intRS_RECORDING= 2; > > private int recordingState = RS_WAITING; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.activity_video_grabber); > getWindow().addFlags(WindowManager.LayoutParams. > FLAG_KEEP_SCREEN_ON); > countdownText = (TextView) findViewById(R.id.countdown_text); > myContext = this; > initialize(); > } > > > private int findBackFacingCamera() { > int cameraId = -1; > int numberOfCameras = Camera.getNumberOfCameras(); > for (int i = 0; i < numberOfCameras; i++) { > CameraInfo info = new CameraInfo(); > Camera.getCameraInfo(i, info); > if (info.facing == CameraInfo.CAMERA_FACING_BACK) { > cameraId = i; > break; > } > } > return cameraId; > } > > public void onResume() { > super.onResume(); > if (!hasCamera(myContext)) { > Toast toast = Toast.makeText(myContext, "Sorry, your phone > does not have a camera!", Toast.LENGTH_LONG); > toast.show(); > finish(); > } > if (mCamera == null) { > mCamera = Camera.open(findBackFacingCamera()); > mPreview.refreshCamera(mCamera); >