[FFmpeg-user] Request for Assistance: Recording Android Mobile Device Input and Output Audio with FFmpeg

H. Vidal, Jr. hvidal at tesseract-tech.com
Thu Apr 4 22:09:54 EEST 2024



On 4/4/24 10:53, Nagulan Bsc cs wrote:
> Dear FFmpeg Team,
>
> I hope this email finds you well. I am writing to seek your assistance with
> a project involving audio recording using FFmpeg.
>
> I am currently working on a project that requires capturing both the input
> and output audio from mobile devices. After some research, I came across
> FFmpeg as a potential solution for recording audio. However, I am facing
> difficulties in achieving this functionality.
>
> Specifically, I need to record the audio input (microphone) and output
> (speaker) simultaneously on mobile devices. I have tried various
> approaches, including using "alsa" input for microphone and "pulse" output
> for the speaker, but haven't been successful in obtaining the desired
> results.
>
> Below is a simplified version of the script I've been using:
>
> *import subprocess*
>
> *def record_audio(output_audio):    try:        ffmpeg_command = [
>    'ffmpeg', '-f', 'alsa', '-i', 'pulse', '-ac', '2', '-vn', output_audio
>      ]        subprocess.run(ffmpeg_command, check=True)        print("Audio
> recording completed successfully.")    except subprocess.CalledProcessError
> as e:        print("Error:", e)if __name__ == "__main__":    output_audio =
> "output_audio.mp3"    record_audio(output_audio)*
>
>
> Could you please provide guidance on how I can achieve simultaneous
> recording of mobile device input and output audio using FFmpeg? Any
> insights, suggestions, or examples would be greatly appreciated.
>
> Thank you very much for your time and assistance. I look forward to hearing
> from you soon.
>
>
>
> *Best regards,Nagulan M*
It doesn't feel like mobile devices and ffmpeg would
be the way to go.

Mobile devices (Android, iOS presumably) have dedicated
APIs for media capture, recording, muxing, etc.

A very quick google search suggests MediaRecorder and MediaMuxer
are places to start in Android API.

I am sure you can find an iOS equivalent.

hv


More information about the ffmpeg-user mailing list