Closed prashantgunit closed 5 years ago
If you try reproduce any mp4 file in your device, it works fine? Can you share me device model and api version?
Device Model is Micromax E484 android version is 5.1 by default camera is recording in .3gp format and file is shown in sdcard like this in image
Write a log in this conditional to make sure your encoder create key frame and start record video: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera1Base.java#L619
It is not working when i changed file format to
mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_3GPP);
Is there any workaround to resolve the issue?
Did you try write a log to know if your device start mediamuxer? https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera1Base.java#L619
Hi, I have write the log and mediaMuxer is not getting started. What should i do now?
It means that your encoder never mark a keyframe so mediamuxer never start. Try record 2mins video and see if sometime your encoder mark some keyframe. I will try find a way to force mark that frame but I don't know if I can do it. What mode and view are you using? (rtmpcamera1 with surfaceview for example, rtmcamera1 with lightopengl, etc)
i am using rtmpcamera1 with surfaceview. 2 mins recording does not capture any frame.
when i remove this condition
if (info.flags == MediaCodec.BUFFER_FLAG_KEY_FRAME
&& !canRecord
&& videoFormat != null
&& audioFormat != null) {
}
Got this error in logcat
java.lang.IllegalStateException: Muxer is not initialized.
at android.media.MediaMuxer.addTrack(MediaMuxer.java:265)
at com.pedro.rtplibrary.base.Camera1Base.getH264Data(Camera1Base.java:623)
at com.pedro.encoder.video.VideoEncoder.getDataFromEncoderAPI21(VideoEncoder.java:422)
at com.pedro.encoder.video.VideoEncoder.access$800(VideoEncoder.java:31)
at com.pedro.encoder.video.VideoEncoder$1.run(VideoEncoder.java:247)
at java.lang.Thread.run(Thread.java:818)
07-21 15:41:43.653 13121-13500/ E/MPEG4Writer: There are no sync frames for video track
Go to: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java#L415 Replace:
if (buffers != null) {
getH264Data.onSPSandPPS(buffers.first, buffers.second);
spsPpsSetted = true;
}
To:
if (buffers != null) {
getH264Data.onVideoFormat(videoEncoder.getOutputFormat());
videoInfo.flags = MediaCodec.BUFFER_FLAG_KEY_FRAME;
getH264Data.onSPSandPPS(buffers.first, buffers.second);
spsPpsSetted = true;
}
Not working. Same result with 0 bytes file
Last 2 shoot. I haven't more ideas for now. If no work I only can think that your device can't record mp4 because your native camera can't do it. Try force hardware and software video encoders.
//hardware
rtmpCamera1.setForce(CodecUtil.Force.HARDWARE, CodecUtil.Force.FIRST_COMPATIBLE_FOUND);
//software
rtmpCamera1.setForce(CodecUtil.Force.SOFTWARE, CodecUtil.Force.FIRST_COMPATIBLE_FOUND);
If no work try use lightopenglview instead of surfaceview. Also combine it with both previous suggestions.
Now i am gettting this in my logcat
E/VideoEncoder: Valid encoder not found
07-21 17:46:09.378 27017-27017E/VideoEncoder: Valid encoder not found
07-21 17:46:09.384 27017-27017 E/VideoEncoder: VideoEncoder need be prepared, VideoEncoder not enabled
When you force hardware, software or using lightopenglview?
when i use software and surfaceview
Try hardware and lightopenglview. If no work I don't know more ways to solve it.
I have an issue regarding out file format. Recorded file format change to 3gp in my micromax phone. Otherwise it is working fine in my other phones. Please help me out.