Created
May 5, 2016 07:28
-
-
Save chikadance/618198030c2ad459ad85f8961d59b6b1 to your computer and use it in GitHub Desktop.
TestMr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.rotry; | |
import android.media.MediaRecorder; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import java.io.IOException; | |
public class TestMr extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_test_mr); | |
MediaRecorder mr = new MediaRecorder(); | |
mr.setVideoSource(MediaRecorder.VideoSource.SURFACE); | |
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); | |
mr.setVideoSize(1920, 1080); | |
mr.setVideoEncoder(MediaRecorder.VideoEncoder.H264); | |
mr.setVideoEncodingBitRate(12 * 1000 * 1000); | |
mr.setVideoFrameRate(60); | |
mr.setOutputFile(getFilesDir() + "/try.mp4"); | |
try { | |
mr.prepare(); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
mr.start(); | |
try { | |
Thread.sleep(2000); | |
} catch (InterruptedException e) { | |
throw new RuntimeException(e); | |
} | |
mr.stop(); | |
mr.reset(); // You can reuse the object by going back to setAudioSource() step | |
mr.release(); // Now the object cannot be reused | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment