Hi, I am trying to use apache mediarecorder and generate mpeg2ts output containing h264 video and aac audio.
1) When I record only video, the output .ts file created works fine without any delay. 2) when I record both audio and video, the application crashes. so I did a search on the Internet and found that this is an error in the MPEG2TS writer.cpp file found within the AOSP and based on this link, <<code.google.com/p/android/issues/detail?id=37714 → I applied the patch and tried the same thing. I was able to encode both audio and video, but the generated output file had problems.
3) the author did not work correctly. there was a lag. the video frame was played first, then the sound was played when the video froze, and this followed.
4) the recording code can be found here → <<androidxref.com/4.2.2_r1/xref/frameworks/av/media/libstagefright/MPEG2TSWriter.cpp →
and the added patch can be found here → & L; <code.google.com/p/android/issues/attachmentText?id=37714&aid=377140007000&name=patch&token=E7rjXqE55TIp50S7sI04mxbsRCA%3A1384836153502 →
5) someone please tell me what the problem is with the author and how can I fix this in the code and please provide some corrected code snippets.
my android source code:
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), as soon as I get the ts writer working, I need to send ts packets via RTP for live broadcast, so please help me fix the ts writer problem.