0

It may seem a dumb question, I have been working on this all night and could not get a webm video recorded from my mobile.

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);

    //mMediaRecorder.setOutputFormat(outFormat);

    //CamcorderProfile camPro = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_480P);
    //camPro.fileFormat = MediaRecorder.OutputFormat.WEBM;
    //camPro.videoFrameRate = 30;
    mMediaRecorder.setCaptureRate(30f);
    //camPro.videoFrameWidth = 360;
    //camPro.videoFrameHeight = 640;
    //camPro.videoBitRate = 2000000;
    //camPro.audioCodec = MediaRecorder.AudioEncoder.VORBIS;

    mMediaRecorder.setVideoSize(640,360);
    mMediaRecorder.setVideoEncodingBitRate(2000000);

    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.VORBIS);
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8);
    //camPro.videoCodec = MediaRecorder.VideoEncoder.VP8;
    mMediaRecorder.setVideoFrameRate(30);
    //mMediaRecorder.setProfile(camPro);

I've commented the camcorder profile lines as i suppose only one has to be used. I also saw a note saying API level 21 is required for it, So I am on my moto G with lollipop 5.0.2.

The error I am getting is Camera died Error 100. Sometimes the media recorder.prepare() happens but then media recorder.start() throws an error. I am confused as to what should be done. Once I got no errors. But I only had a file of 6.19KB which couldn't be played.

Chetan
  • 56
  • 6
  • unfortunately VORBIS encoding isn't supported in Android (only decoding).. so you won't be able to record audio – user25 Jul 14 '18 at 08:41

1 Answers1

0

I can't tell whether you're wanting to write to a file or to a Socket or what. But if you're wanting to write to a Socket, then Lollipop seems to have an issue with it. You have to use this technique to write to the Socket.

However, WEBM seems to stop streaming data for me after the first two packets. I'm currently unsure why this is the case.

Anyone Have MediaRecorder Working with ParcelFileDescriptor and createPipe()?

Community
  • 1
  • 1
Jeff Fischer
  • 2,063
  • 1
  • 17
  • 12