Hi am trying to use the mediarecorder api and generate a mpeg2ts output that contains h264 video and aac audio.
1) When i record the video alone, the output .ts file generated works fine without any lag. 2) when i record both audio and video, the application crashes. so i did some search online and found that it was a bug in the MPEG2TS writer.cpp found in the AOSP framework and based upon this link, << code.google.com/p/android/issues/detail?id=37714 >> I applied the patch suggested and tried the same. i was able to encode both audio and video but the output file generated had issues.
3) the writer didnt work correct. there was lag. first a video frame was played, then audio played while the video froze and this followed.
4) the writer code can be found here -> << androidxref.com/4.2.2_r1/xref/frameworks/av/media/libstagefright/MPEG2TSWriter.cpp >>
and the patch i added can be found here -> << code.google.com/p/android/issues/attachmentText?id=37714&aid=377140007000&name=patch&token=E7rjXqE55TIp50S7sI04mxbsRCA%3A1384836153502 >>
5) somebody please tell me what was the issue with the writer and how should i fix it in the code and please provide some fixed code snippets.
my android source code is :
myCamera = getCameraInstance();
mediaRecorder = new MediaRecorder();
myCamera.unlock();
mediaRecorder.setCamera(myCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(8);
mediaRecorder.setOutputFile("/sdcard/myvideo.ts");
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setVideoSize(320, 240);
mediaRecorder.setVideoFrameRate(15);
mediaRecorder.setMaxDuration(20);
mediaRecorder.setMaxFileSize(10000);
mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder()
.getSurface());
6) once i get the ts writer to work, i need to send the ts packets over RTP for live streaming so please help in fixing the ts writer issue.