MediaRecorder setVideoSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaRecorder setVideoSource method.

This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		cameraView.setClickable(true);
		cameraView.setOnClickListener(this);
	} 
 
	private void initRecorder() { 
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
		recorder.setOutputFile("/sdcard/videocapture_example.mp4");
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
	} 
 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
 
		try { 
8
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		// TODO Auto-generated method stub 
 
	} 
 
	private void initMediaRecorder() { 
		mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
		CamcorderProfile camcorderProfile_HQ = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		CamcorderProfile camcorderProfile_LOW = CamcorderProfile
				.get(CamcorderProfile.QUALITY_LOW);
		mediaRecorder.setProfile(camcorderProfile_LOW);
		mediaRecorder.setOutputFile("/sdcard/hookupvideo.mp4");
		mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
		mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M
	} 
 
	private void prepareMediaRecorder() { 
		mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
		try { 
7
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setOutputFile, setProfile, setVideoSource
         WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
 
        String videoPath = "";
         
        recorder = new MediaRecorder();// Instantiate our media recording object
        initRecorder(videoPath);
        //setContentView(R.layout.view); 
 
        SurfaceView cameraView = null;// (SurfaceView) findViewById(R.id.surface_view);
        holder = cameraView.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 
        cameraView.setClickable(true);// make the surface view clickable
        cameraView.setOnClickListener((OnClickListener) this);// onClicklistener to be called when the surface view is clicked
    } 
 
 
    private void initRecorder (String path)

7
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		Log.v(TAG, "onCreate finished");
	} 
 
	private void initRecorder() { 
		Log.v(TAG, "in initRecorder");
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		Log.v(TAG, "set audio src");
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
		Log.v(TAG, "set video src");
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
		recorder.setOutputFile(Environment.getExternalStorageDirectory().getPath() + "/videocapture_example.mp4");
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
		Log.v(TAG, "recorder initialized");
	} 
 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
7
CodeRank
This code example shows how to use the following methods:setAudioSource, setCamera, setProfile, setVideoSource
 
        setOnTouchListener(this);
    } 
     
    public void PrepareMedia(int wid, int hei) {
        myMediaRecorder =  new MediaRecorder();
        myCamera.stopPreview();
        myCamera.unlock();
         
        myMediaRecorder.setCamera(myCamera);
        myMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        myMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
	     
        CamcorderProfile targetProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
        targetProfile.quality = 60;
        targetProfile.videoFrameWidth = wid;
        targetProfile.videoFrameHeight = hei;
        targetProfile.videoFrameRate = 30;
        targetProfile.videoCodec = MediaRecorder.VideoEncoder.H264;
        targetProfile.audioCodec = MediaRecorder.AudioEncoder.AMR_NB;

6
CodeRank
This code example shows how to use the following methods:prepare, setOutputFile, setOutputFormat, setVideoEncoder, setVideoSource
	public void CaptureVideo() 
	{ 
		 
		final String FICHIER_SORTIE = "/sdcard/video_test.3gp";
		 
		MediaRecorder mediaRecorder =  new MediaRecorder();
		 
		try { 
		mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
		 
		mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
		mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
		 
		mediaRecorder.setOutputFile(FICHIER_SORTIE);
		 
			mediaRecorder.prepare();
		} 
		catch (IOException e) {
			Log.e("CaptureVideo", "Failed to prepare the video recorder handler");
			return; 

6
CodeRank
This code example shows how to use the following methods:setAudioSource, setOutputFile, setProfile, setVideoSource
 
    private String Init()
    { 
    	InitWithoutNewFile(); 
    	String outputFileName = getOutputMediaFile().toString();
        mRecorder.setOutputFile(outputFileName);
    	return outputFileName;
    } 
     
    private void InitWithoutNewFile(){ 
        mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        mRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
        CamcorderProfile camcorderProfile_HQ = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
        mRecorder.setProfile(camcorderProfile_HQ);
    } 
 
     
    /* Create a File for saving an image or video*/  
    private static File getOutputMediaFile(){
        File mediaStorageDir = Functions.getInstance().fileLocation();

6
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
	    
 
	    private void initRecorder()  
	    { 
	    	Log.d(TAG, "initRecorder called");
	        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
	        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
	        CamcorderProfile cpHigh = CamcorderProfile
	                .get(CamcorderProfile.QUALITY_LOW);
	        recorder.setProfile(cpHigh);
	        recorder.setOutputFile(Environment.getExternalStorageDirectory()+"/videocapture_example.mp4");
	        recorder.setMaxDuration(6000); // 6 seconds
	        recorder.setMaxFileSize(500000); // Approximately 5 megabytes
//	        new Handler().postDelayed(new Runnable() 
//	       	 { 
//	 
//					@Override 
//					public void run()  
//					{ 
6
CodeRank
This code example shows how to use the following methods:setAudioEncoder, setAudioSource, setOutputFormat, setVideoEncoder, setVideoSource
	private Socket clientSocket;
 
	public Camcorder(String ip, int port) throws UnknownHostException,
			IOException { 
		clientSocket = new Socket(ip, port);
		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.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
		// recorder.setVideoSize(480, 320); 
		// recorder.setVideoFrameRate(15); 
		// recorder.setMaxDuration(10000); 
	} 
 
	public void startRecording() { 
		ParcelFileDescriptor fd = ParcelFileDescriptor.fromSocket(clientSocket);
		recorder.setOutputFile(fd.getFileDescriptor());
		recorder.setOutputFile(outputFile);
6
CodeRank
This code example shows how to use the following methods:setAudioEncoder, setAudioSource, setOutputFormat, setVideoEncoder, setVideoSource
 
	/** 
	 * Set up the source and the encorder 
	 */ 
	private void setupSourceEncoder() { 
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
	} 
 
	public void surfaceCreated(SurfaceHolder holder) {
		recorder.setOutputFile(outputFile);
		recorder.setPreviewDisplay(holder.getSurface());
		prepare(); 
	} 
 
	/** 
	 * Prepare the camera. Basically call {@link MediaRecorder#prepare()} 
6
CodeRank

Related MediaRecorder setVideoSource Questions & Answers:

setVideoSource Method Overview
Sets the video source to be used for recording.
See Code Examples for other Android MediaRecorder Methods: