Tuesday, 15 September 2015

android - How do I use MediaRecorder to record video without causing a segmentation fault? -


I have Android I am trying to use the media. To record the media record video, and even if I'm ready for Android Runtime Segmentation Defects () here is an example:

  Create a bundle savedinstenstate {log on public}. ("Video test", "make recorder"); MediaRecorder Recorder = New MediaRecorder (); ContentResolver = getContentResolver (); Try {Super.onCreate (Saved Instantstate); Logs. I ("video test", "-------------- start ----------------"); Surface view target_view = new surface view (this); Logs. I ("video test", "creating surface"); Surface Target = target_view.getHolder (). GetSurface (); Log.i ("video test", target.toString ()); Logs. I ("video test", "new recorder"); Recorder = new media recorder (); Logs. I ("video test", "set display"); Recorder.setPreviewDisplay (target); Logs. I ("video test", "pushing surface"); SetContentView (target_view); Logs. I ("Video test", "Set audio source"); Recorder.setAudioSource (MediaRecorder.AudioSource.MIC); Logs. I ("video test", "set video source"); Recorder.setVideoSource (MediaRecorder.VideoSource.DEFAULT); Log.i ("video test", "set output format"); Recorder.setOutputFormat (MediaRecorder.OutputFormat.THREE_GPP); Logs. I ("video test", "set audio encoder"); Recorder.setAudioEncoder (MediaRecorder.AudioEncoder.AMR_NB); Logs. I ("video test", "set video encoder"); Recorder.setVideoEncoder (MediaRecorder.VideoEncoder.MPEG_4_SP); Logs. I ("Video test", "Set maximum duration"); Recorder.setMaxDuration (3600); Logs. I ("video test", "set to information listener"); Recorder.setOnInfoListener (new listener); Logs. I ("video test", "set video size"); Recorder.set videos (320, 240); Logs. I ("video test", "set video frame rate"); Recorder.setVideoFrameRate (15); Logs. I ("video test", "set output file"); Recorder.setOutputFile (get_path (this, "foo.3gp")); Logs. I ("video test", "ready"); Recorder.prepare (); Logs. I ("video test", "start"); Recorder.start (); Logs. I ("video test", "sleep"); Thread.Sleep (3600); Logs. I ("video test", "stop"); Recorder.stop (); Logs. I ("video test", "release"); Recorder.release (); Logs. I ("Video Testing", "----------------- SUCCESS ------------------"); End(); } Hold (exception e) {Log.i ("video test", e.ostustring ()); Recorder.reset (); Recorder.release (); Logs. I ("Video Tates", "------------------- Fail -------------------"); End(); }} Public static string get_path (reference references, string fname) {string path = context.getFileStreamPath ("foo"). GetParentFile () GetAbsolutePath (); String race = path + "/" + fname; Logs. I ("video test", "path:" + res); Return ridge; } Class listeners have media recorder .Oniflister {Infos at Public Zero (Media Records Recorder, It's What Extra) {Log. ("Video Test", "Video Info:" + + "," + Extra); }}  

This issue appears to be related to the timing of the state machine for the camera

< / P>

/ div>

No comments:

Post a Comment