1

Hello I'm using google's grafika library to create a custom camera app and so far I managed to do everything I want except adding audio to the videos. I searched all over the internet for a similar example but I couldn't find answer to my problem. I tried adding another mediaCodec for the audio, one more CircularEncoderBuffer for the audio too and also adding 2 more parameters to the EncoderThread for the audio mediaCodec and the audio buffer to no avail. When I attempt to start recording I receive a dozen frames and the buffers drain them but afterwards the app freezes with no error and I can't go back to the previous screen or exit the preview by any means.

Has anyone tried adding audio to the continuous capture before ? Do I need another thread for the audio mediaCodec and if so how do I mux the video and audio afterwards ? Do I need a second CircularEncoderBuffer or I should somehow use only 1 to store both audio and video ?

I'm not sure what part of my code will be useful for you guys so I won't add any for now, but if you tell me what you need I will immediately update my question with code sample.

  • I have searched for this for more than a week but now that I posted the question stackoverflow suggests me recommended question that is the same as mine. Sorry for the duplicate and here's a link to the other questions - https://stackoverflow.com/questions/27394665/android-video-circular-buffer-with-sound?rq=1v – Nikolai Nikolov Aug 17 '18 at 08:39
  • please follow this link may be help you: https://github.com/OnlyInAmerica/HWEncoderExperiments/blob/audioonly/HWEncoderExperiments/src/main/java/net/openwatch/hwencoderexperiments/AudioEncoder.java – Ali Nov 17 '18 at 07:25
  • Also refer this link : [AudioVideoRecordingSample](https://github.com/saki4510t/AudioVideoRecordingSample) – Ali Nov 20 '18 at 07:26

0 Answers0