Android: Save Mediarecorder-Stream as playable file
I want to record videos with my android device (Nexus 10) and upload it
later to youtube.
So far I'am recording with the android MediaRecoder and stream it via
LocalSocket to save the data to multiple files. But the files are not
playable.
I read some articles that sine API-Level 18 it is possible to convert
files with MediaCodec and/or MediaMuxer. And i found this this code, but i
do not really understand how to handle it.
Has anybody an easy example which shows how to convert the raw data from
the LocalSocket to a playable file (i.e. mp4 files)?
My MediaRecoder looks like this:
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile camcorderProfile_HQ =
CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
camcorderProfile_HQ.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
camcorderProfile_HQ.videoCodec = MediaRecorder.VideoEncoder.MPEG_4_SP;
recorder.setProfile(camcorderProfile_HQ);
recorder.setPreviewDisplay(surfaceHolder.getSurface());
clientSocket = new LocalSocket();
clientSocket.connect(new LocalSocketAddress(SOCKET_ADDRESS));
recorder.setOutputFile(clientSocket.getFileDescriptor());
recorder.prepare();
recorder.start();
Thanks in advance.
No comments:
Post a Comment