1

I'm making an app to record video without using the default video recorder. To make the video I'm using the MediaMuxer. The audio and video recording is done on separate threads.

The app randomly crashes when I stop recording, and the log shows

MPEG4Writer(23890): There are no sync frames for video track

java.lang.IllegalStateException: Failed to stop the muxer

12-24 15:26:36.736: E/AndroidRuntime(23890): FATAL EXCEPTION: TextureMovieEncoder
12-24 15:26:36.736: E/AndroidRuntime(23890): Process: com.example.cameradummy, PID: 23890
12-24 15:26:36.736: E/AndroidRuntime(23890): java.lang.IllegalStateException: Failed to stop the muxer
12-24 15:26:36.736: E/AndroidRuntime(23890):    at android.media.MediaMuxer.nativeStop(Native Method)
12-24 15:26:36.736: E/AndroidRuntime(23890):    at android.media.MediaMuxer.stop(MediaMuxer.java:226)
12-24 15:26:36.736: E/AndroidRuntime(23890):    at com.example.cameradummy.VideoEncoderCore.closeMuxer(VideoEncoderCore.java:421)

When I tried recording the video without adding the audio track it worked fine, but when both audio and video tracks are added to the muxer it gives this issue.

I am referring grafika cameracaptureactivity for video recording

I am not able to figure out if the issue is caused due to the threading or some sync problem. Could someone please help me resolve this issue.

Preethi Rao
  • 5,117
  • 1
  • 16
  • 29
  • 1
    Are you synchronizing access to the MediaMuxer? Are there any failure messages earlier in logcat? "Failed to stop the muxer" is usually caused by something else; it's a sort of generic failure that means an error was noticed when the muxer was closing. – fadden Dec 24 '14 at 16:40
  • thanks @fadden it was the issue with synchronous access of the media muxer . Now the problem is fixed – Preethi Rao Dec 26 '14 at 09:50
  • @fadden now i am not getting the crash but i am getting this random error `MPEG4Writer(23890): There are no sync frames for video track` which is causing corrupted video. Whenever i get this error i am unable to play video – Preethi Rao Dec 26 '14 at 12:02
  • 1
    Can you confirm that you are supplying frames that periodically have the BUFFER_FLAG_KEY_FRAME flag set? It might be necessary for the very first frame to have that set. See e.g. the Grafika CircularEncoderBuffer class, used by the "continuous capture" activity. When feeding data to the muxer it always starts with a key frame. (I don't know much about audio recording, so I don't know if there's a key frame involved there that it's complaining about.) – fadden Dec 26 '14 at 17:03

0 Answers0