How To Convert Codec Of Video Recorded By Inbuilt Android Camera?
Solution 1:
(1) Fixing current video file :
Your video is of format H.263 (or Mpeg-2) using Simple
profile. Correctly as you said, this means you must convert. You must do this re-encode into H.264 task using some free video tool.
For example : Using Handbrake you can do...
Choose to Open your "not playing" MP4 file. Should be detected as MP4, now tick (or enable) the option
web optimized
.In
Video
settings tab, choose EncoderProfile
as Main and Encoderlevel
as 3.In
Destination
put your preferred output folder and filename. (just browse to some folder then type your new filename to create here).Click green button
Start Encode
and test new MP4 output file in browser.
(2) Fixing Android code for future recordings :
You have to set the codec to H.264 in your MediaRecorder
object settings like :
myMediaRec = newMediaRecorder(); //create MediaRecorder object
myMediaRec.setVideoEncoder(MediaRecorder.VideoEncoder.H264); //set video codec
So basically your code should look like : (untested code, just use for study or guidance)...
@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == RECORD_VIDEO_PERMISSION && resultCode == RESULT_OK)
{
//# Create a new instance of MediaRecorder
myMediaRec = newMediaRecorder(); //create MediaRecorder object
mMediaRec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRec.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
myMediaRec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//# Video settings
myMediaRec.setVideoEncoder(MediaRecorder.VideoEncoder.H264); //contained inside MP4
myMediaRec.setVideoSize(640, 480); //width 640, height 480
myMediaRec.setVideoFrameRate(30); //30 FPS
myMediaRec.setVideoEncodingBitRate(3000000); //adjust this for picture quality//# Audio settings
myMediaRec.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); //must always be AAC
myMediaRec.setAudioEncoder(MediaRecorder.getAudioSourceMax());
myMediaRec.setAudioEncodingBitRate(16);
myMediaRec.setAudioSamplingRate(44100);
}
}
Post a Comment for "How To Convert Codec Of Video Recorded By Inbuilt Android Camera?"