4

Yes I know that this has been asked many many times, but the libraries on every single answer just ends up needing ffmepg.

The problem with that is that the file size increases dramatically when I include ffmpeg to my project, and I just don't want that.

I want to keep my project as lightweight as possible without needing to add 200 meabytes of data just for video to audio conversion which is just a very small part of the project.

So is there any way to

    1. not use ffmpeg
    1. use another lightweight converter with a python wrapper
    1. just use the parts in ffmpeg where the webm to mp3 conversion is actually taking place
Andy_ye
  • 560
  • 1
  • 7
  • 19

1 Answers1

1

Compile your own ffmpeg using this configuration to decode Vorbis/Opus audio in WebM and encode MP3 via libmp3lame:

./configure --disable-everything --disable-network --disable-autodetect --enable-small --enable-protocol=file,pipe --enable-demuxer=matroska --enable-muxer=mp3 --enable-decoder=vorbis,opus --enable-encoder=libmp3lame --enable-libmp3lame --enable-filter=aresample

Resulting size of ffmpeg is under 2 MB.

llogan
  • 121,796
  • 28
  • 232
  • 243
  • 1
    @Andy_ye Very basic instructions are to 1) download the FFmpeg source code 2) run ` configure` 3) Run `make`. What's your OS? You can see some [FFmpeg compiling guides on the wiki](https://trac.ffmpeg.org/#CompilingFFmpeg). – llogan Apr 30 '20 at 16:09
  • Is there any chance of a MWE - I have no idea where to start from ! – 3kstc Apr 28 '21 at 06:02
  • it's grotesque windows - windows 10 :( what I would do be on a linux platform – 3kstc Apr 28 '21 at 06:06
  • @3kstc Oh...I don't have any experience with that. Maybe see https://github.com/BtbN/FFmpeg-Builds or https://github.com/m-ab-s/media-autobuild_suite or https://github.com/rdp/ffmpeg-windows-build-helpers or just download a build from https://www.gyan.dev/ffmpeg/builds/ – llogan Apr 28 '21 at 06:10
  • cheers! on another thought If I were to do this on a Raspberry pi3B+ - how would I do it? – 3kstc Apr 28 '21 at 06:12
  • @3kstc Not sure what you mean. You want to crosscompile on the RPI for Windows? Crosscompile on something for the RPI? Compile normally on the RPI? What's the OS on that device? – llogan Apr 28 '21 at 06:16
  • Sorry - I'm thinking of carrying across the `*.webm` and `*.m4a` on to a raspberry Pi that runs Raspbian on it, and write a small script that can convert the `*.webm` and `*.m4a` files into a `*.mp3` format. – 3kstc Apr 28 '21 at 06:19
  • @3kstc I'd probably just be lazy, `apt install ffmpeg`, run `ffmpeg -i input.webm output.mp3` and call it good. – llogan Apr 28 '21 at 06:22