Flutter : Fetch audio from recorded video

390

I assume you are trying to extract audio only from Video, you can achive this by using the ffmpeg package.

Import this package in your project add the following lines in your android\build.gradle

ext.flutterFFmpegPackage = 'full'

flutter_ffmpeg provides eight packages that include different sets of external libraries. These packages are named according to the external libraries included in them. From documentation you can see which libraries are enabled in each package. And you can use according to your need, so if you need to change full to specific one you can do this but here i am using full to make your work done.

With below code snippet you can extract audio from video

 final FlutterFFmpeg FFmpeg = FlutterFFmpeg();
    FFmpeg.execute(
        "-i /storage/emulated/0/download/Test_video.mp4 -map 0:a -acodec libmp3lame /storage/emulated/0/download/test3.mp3").then((rc) =>
    {
      print("FFmpeg process exited with rc $rc.")
    }

Print statement should return 0 on success, Also i am using testvideo from my own storage you need to change this according to your storage location.

Share:
390
Mj24
Author by

Mj24

Updated on January 04, 2023

Comments

  • Mj24
    Mj24 over 1 year

    I have a feature to implement in Flutter. I have to record user video and fetch audio from that for next level verification. Does anyone have any idea about this. Thanks in advance.

    • Community
      Community about 2 years
      Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    • Mj24
      Mj24 about 2 years
      My requirement is to record a video in which user will speak something. I have to fetch that speech and match it on back end (kind of authentication process). @Community
    • Mj24
      Mj24 about 2 years
      @Ahmad Raza yes I want extract the audio(speech) from the video.