0

I'm just invoking video intent to capture.

`

private void dispatchTakeVideoIntent() {
       Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
        }
}

`

like this. But I need to capture it without Audio.I checked this below link but couldn't found how to resolve Android record video without audio

Community
  • 1
  • 1
rashmi
  • 9
  • 1
  • 6

1 Answers1

0

Just use the MediaRecorder class to record the video. With media recorder, while setting up the audio and video source just don't set the audio source there. like this.

public class MuteVideoRecorderView extends SurfaceView implements
        SurfaceHolder.Callback {

    private SurfaceHolder mHolder;

    private Camera mCamera;
    private MediaRecorder mMediaRecorder;

    public CamcorderView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mHolder = getHolder();
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        mHolder.addCallback(this);

        mCamera = Camera.open();
        mRecorder = new MediaRecorder();

    }

    public void stop() {
        mRecorder.stop();
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width,
            int height) {
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {

        mCamera.unlock();
        mMediaRecorder.setCamera(mCamera);

        // Here we will not set mRecorder.setAudio(..);
        mMediaRecorder.setVideoSize(int, int);
        mMediaRecorder.setVideoFrameRate(int);

        mMediaRecorder.setPreviewDisplay(mHolder.getSurface());


        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
            mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
        mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

        // change for desired output folder
        mMediaRecorder.setOutputFile("/mnt/sdcard/test/work");

        try {
            mMediaRecorder.prepare();
        } catch (IllegalStateException e) {
            Log.e("IllegalStateException", e.toString());
        } catch (IOException e) {
            Log.e("IOException", e.toString());
        }
        mMediaRecorder.start();
    }
}
Bajrang Hudda
  • 3,028
  • 1
  • 36
  • 63
Priyavrat
  • 451
  • 3
  • 14
  • Simply leaving out the `AudioSource` unfortunately doesn't work on Android 10+; `MediaRecorder.prepare()` fails. I've been searching without success for a method which works on this API level. – head in the codes Feb 20 '21 at 02:04