Video encoding

by PStrand » Thu, 30 Jul 2009 01:21:07 GMT


Sponsored Links
 I'm trying to encode a video file from a series of images using
android.
I am wondering if this is at all possible with the current API's --
all current devices has the ability to encode video ( from the
camera ), but is it possible to use the encoder with user-supplied
images ?

thanks,
Peter

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. voice communication over WIFI within same region(without VOIP)

Device:Any device which supports J2ME with WIFI enabled



i want to develop an android application with the following features

1.A wifi enabled router should contain a list  of all the mobile
devices which are connected to it.

2.  the above list should be accessed  by all the mobile phones .A
mobile phone should be able to call(voice communication)  other mobile
which is present in the list through WIFI.

3.As both are within the same WIFI region no VOIP concepts should be
applied.

Is it possible for two mobile devices to communicate with each
other(full duplex) through wifi ?

-- 

2. Problem with camera preview in portrait mode

Hi all,

I'm not able to display the camera preview in portrait mode with Samsung S.
The preview is not well oriented. I have try to rotate it with the following
camera API but nothing change.
*params.set("orientation", "landscape");
params.set("rotation", 0);

*Is there a known issue on Samsung S (2.1), because I don't have this
problem with HTC Desire (2.1) ?

Is it related to:
6558 <http://code.google.com/p/android/issues/detail?id=6558>: Camera API
lacks a way to set orientation to portrait
9901 <http://code.google.com/p/android/issues/detail?id=9901>: Camera
preview only works in landscape


Cyril

____________________
*Part of source code:

*/**
 *
 */
public class ARPreviewer extends SurfaceView implements
SurfaceHolder.Callback{
    private SurfaceHolder mHolder;
    private int mpreview_width, mpreview_height; // requested frame size
    private byte[] mybuffer=null;
    ARCameraPreviewer myCameraPreviewer;


    public ARPreviewer(Context context, int preview_width, int
preview_height){
        super(context);

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        mpreview_width = preview_width;
        mpreview_height = preview_height;

        setZOrderMediaOverlay(false);

        myCameraPreviewer = new ARCameraPreviewer(this);
    }


    public void surfaceCreated(SurfaceHolder holder) {
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        myCameraPreviewer.release();
    }


    public void surfaceChanged(SurfaceHolder holder, int format, int w, int
h) {

        if (mybuffer == null){ //don't restart camera when screen
orientation changed
            try {
                myCameraPreviewer.initCamera(holder, mpreview_width,
mpreview_height);
            } catch (InterruptedException e) {
                e.printStackTrace();
                return;
            }

            int bufSize = myCameraPreviewer.getBufferSize();
            mybuffer = new byte[bufSize];

            myCameraPreviewer.addCallbackBuffer(mybuffer);
            myCameraPreviewer.startPreview();
        }

        /*
        [...]
        */
    }

/**
 *
 */
public class ARCameraPreviewer implements Camera.PreviewCallback,
Camera.ErrorCallback{
    private Method mAcb;
    private Method mPCWB;
    private Camera mCamera;
    private ARPreviewer myPreviewer;
    private int pixelformat;

    ARCameraPreviewer(ARPreviewer Previewer){
        myPreviewer = Previewer;
    }

    void initCamera(SurfaceHolder holder, int preview_width, int
preview_height) throws InterruptedException{
        if(mCamera == null){
            // The Surface has been created, acquire the camera and tell it
where
            // to draw.
            int i = 0;
            while(i++ < 5){
                try{
                    mCamera = Camera.open();
                    break;
                }catch(RuntimeException e){
                    Thread.sleep(200);
                }
            }
            try {
                mCamera.setPreviewDisplay(holder);
            } catch (IOException exception) {
                mCamera.release();
                mCamera = null;

            }catch(RuntimeException e){
                Log.e("camera", "stacktrace", e);
            }
        }

        // Camera configuration
        if(mCamera != null){
            parameters.setPreviewSize(preview_width, preview_height);
            mCamera.setParameters(parameters);
        }

        //init setPreviewCallbackWithBuffer
        try {
            mPCWB = Class.forName("android.hardware.Camera").getMethod(
                    "setPreviewCallbackWithBuffer", PreviewCallback.class);
        } catch (Exception e) {
            Log.e("CameraView",
                    "Problem setting up for setPreviewCallbackWithBuffer: "
                            + e.toString());
        }

        //init addCallbackBuffer
        try {
            mAcb = Class.forName("android.hardware.Camera").getMethod(
                    "addCallbackBuffer", byte[].class);
        } catch (Exception e) {
            Log.e("CameraView", "Problem setting up for addCallbackBuffer:
"+ e.toString());
        }
    }


    void release(){
        if(mCamera !=null){
            mCamera.stopPreview();
            mCamera.release();
        }

        clearPreviewCallbackWithBuffer();
        mCamera = null;
        mAcb = null;
        mPCWB = null;
    }

    /**
     * Camera callback, call after a frame request
     */
    @Override
    public void onPreviewFrame(byte[] data, Camera camera) {
        // Forward frame to previewer
        myPreviewer.onPreviewFrame(data, pixelformat);
    }


    public void addCallbackBuffer(byte[] b) {
        try {
            mAcb.invoke(mCamera, b);
        } catch (Exception e) {
            Log.e("CameraView", "invoking addCallbackBuffer failed: "+
e.toString());
        }
    }


    /**
     * Tell the camera driver to use a preview callback with buffer
     */
    private void setPreviewCallbackWithBuffer() {
        try {
            mPCWB.invoke(mCamera, this);
        } catch (Exception e) {
            Log.e("CameraView", e.toString());
        }
    }

    protected void clearPreviewCallbackWithBuffer() {
        try {
            mPCWB.invoke(mCamera, (PreviewCallback) null);
        } catch (Exception e) {
            Log.e("CameraView", e.toString());
        }
    }

    public void startPreview(){
        setPreviewCallbackWithBuffer();
        mCamera.startPreview();
    }


    /**
     * Call by preview to know the size of frame buffer
     * @return frame buffer size
     */
    public int getBufferSize(){
        // define buffer size
        PixelFormat pixelinfo = new PixelFormat();
        pixelformat = mCamera.getParameters().getPreviewFormat();
        PixelFormat.getPixelFormatInfo(pixelformat, pixelinfo);

        Size preview_size = mCamera.getParameters().getPreviewSize();

        return preview_size.width * preview_size.height *
pixelinfo.bitsPerPixel / 8;
    }
/*
    [...]
*/
}

-- 

3. Difference between StageFright and Opencore

4. image size for live wallpaper

5. Java / Weblogic Portal Developer

6. Add my New Email ID to your Distribution List

7. Image corrupted with RFCOMM Bluetooth