Is there a more lightweight solution to read/write MP3 with Linux+Python?











up vote
0
down vote

favorite












This works very well to export a WAV to MP3:



from pydub import AudioSegment
song = AudioSegment.from_wav("test.wav")
song.export("test.mp3", format="mp3", bitrate="256k")


but it requires to install ffmpeg which takes 338 MB with apt-get install ffmpeg:



enter image description here



I'm working on a small container, thus I'd like to avoid using 338 MB for this task.



Is there a more lightweight solution to read/write MP3 with Python+Linux?










share|improve this question


















  • 3




    Please avoid screenshots, that's just fugly.
    – tink
    Nov 29 at 17:19










  • Does pythonstudio.us/learning/the-lame-project.html help? :)
    – tink
    Nov 29 at 17:22










  • @tink It's as ugly as having to install 338 MB to decode a MP3 ;)
    – Basj
    Nov 29 at 17:27










  • @tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
    – Basj
    Nov 29 at 17:29








  • 1




    You don't need to include the build-environment in your container ... ?
    – tink
    Nov 29 at 17:48















up vote
0
down vote

favorite












This works very well to export a WAV to MP3:



from pydub import AudioSegment
song = AudioSegment.from_wav("test.wav")
song.export("test.mp3", format="mp3", bitrate="256k")


but it requires to install ffmpeg which takes 338 MB with apt-get install ffmpeg:



enter image description here



I'm working on a small container, thus I'd like to avoid using 338 MB for this task.



Is there a more lightweight solution to read/write MP3 with Python+Linux?










share|improve this question


















  • 3




    Please avoid screenshots, that's just fugly.
    – tink
    Nov 29 at 17:19










  • Does pythonstudio.us/learning/the-lame-project.html help? :)
    – tink
    Nov 29 at 17:22










  • @tink It's as ugly as having to install 338 MB to decode a MP3 ;)
    – Basj
    Nov 29 at 17:27










  • @tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
    – Basj
    Nov 29 at 17:29








  • 1




    You don't need to include the build-environment in your container ... ?
    – tink
    Nov 29 at 17:48













up vote
0
down vote

favorite









up vote
0
down vote

favorite











This works very well to export a WAV to MP3:



from pydub import AudioSegment
song = AudioSegment.from_wav("test.wav")
song.export("test.mp3", format="mp3", bitrate="256k")


but it requires to install ffmpeg which takes 338 MB with apt-get install ffmpeg:



enter image description here



I'm working on a small container, thus I'd like to avoid using 338 MB for this task.



Is there a more lightweight solution to read/write MP3 with Python+Linux?










share|improve this question













This works very well to export a WAV to MP3:



from pydub import AudioSegment
song = AudioSegment.from_wav("test.wav")
song.export("test.mp3", format="mp3", bitrate="256k")


but it requires to install ffmpeg which takes 338 MB with apt-get install ffmpeg:



enter image description here



I'm working on a small container, thus I'd like to avoid using 338 MB for this task.



Is there a more lightweight solution to read/write MP3 with Python+Linux?







apt python audio mp3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 29 at 17:17









Basj

90821135




90821135








  • 3




    Please avoid screenshots, that's just fugly.
    – tink
    Nov 29 at 17:19










  • Does pythonstudio.us/learning/the-lame-project.html help? :)
    – tink
    Nov 29 at 17:22










  • @tink It's as ugly as having to install 338 MB to decode a MP3 ;)
    – Basj
    Nov 29 at 17:27










  • @tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
    – Basj
    Nov 29 at 17:29








  • 1




    You don't need to include the build-environment in your container ... ?
    – tink
    Nov 29 at 17:48














  • 3




    Please avoid screenshots, that's just fugly.
    – tink
    Nov 29 at 17:19










  • Does pythonstudio.us/learning/the-lame-project.html help? :)
    – tink
    Nov 29 at 17:22










  • @tink It's as ugly as having to install 338 MB to decode a MP3 ;)
    – Basj
    Nov 29 at 17:27










  • @tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
    – Basj
    Nov 29 at 17:29








  • 1




    You don't need to include the build-environment in your container ... ?
    – tink
    Nov 29 at 17:48








3




3




Please avoid screenshots, that's just fugly.
– tink
Nov 29 at 17:19




Please avoid screenshots, that's just fugly.
– tink
Nov 29 at 17:19












Does pythonstudio.us/learning/the-lame-project.html help? :)
– tink
Nov 29 at 17:22




Does pythonstudio.us/learning/the-lame-project.html help? :)
– tink
Nov 29 at 17:22












@tink It's as ugly as having to install 338 MB to decode a MP3 ;)
– Basj
Nov 29 at 17:27




@tink It's as ugly as having to install 338 MB to decode a MP3 ;)
– Basj
Nov 29 at 17:27












@tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
– Basj
Nov 29 at 17:29






@tink Thank you for your answer. This solution seems to involve C compiling, etc. so it will require to install dev tools too (build-essential) and it will be big too. I'm looking for a binary that could decode/encode MP3 from Python in a few megabytes maximum.
– Basj
Nov 29 at 17:29






1




1




You don't need to include the build-environment in your container ... ?
– tink
Nov 29 at 17:48




You don't need to include the build-environment in your container ... ?
– tink
Nov 29 at 17:48










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Not 100% sure it will work, but I'll try it:



Go on https://www.ffmpeg.org/download.html, select "Linux Static Builds", this redirects to https://johnvansickle.com/ffmpeg/. Then select https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz, do



tar ffmpeg-release-amd64-static.tar.xz


Then:



./ffmpeg 


seems to work.



It might be possible to keep only one of the 3 (or am I wrong?)



-rwxr-xr-x 1 1000 1000  63M Nov 12 02:45 ffmpeg
-rwxr-xr-x 1 1000 1000 64M Nov 12 03:05 ffmpeg-10bit
-rwxr-xr-x 1 1000 1000 63M Nov 12 02:45 ffprobe


so I think we can reduce the required size to 63M.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484978%2fis-there-a-more-lightweight-solution-to-read-write-mp3-with-linuxpython%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Not 100% sure it will work, but I'll try it:



    Go on https://www.ffmpeg.org/download.html, select "Linux Static Builds", this redirects to https://johnvansickle.com/ffmpeg/. Then select https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz, do



    tar ffmpeg-release-amd64-static.tar.xz


    Then:



    ./ffmpeg 


    seems to work.



    It might be possible to keep only one of the 3 (or am I wrong?)



    -rwxr-xr-x 1 1000 1000  63M Nov 12 02:45 ffmpeg
    -rwxr-xr-x 1 1000 1000 64M Nov 12 03:05 ffmpeg-10bit
    -rwxr-xr-x 1 1000 1000 63M Nov 12 02:45 ffprobe


    so I think we can reduce the required size to 63M.






    share|improve this answer

























      up vote
      0
      down vote













      Not 100% sure it will work, but I'll try it:



      Go on https://www.ffmpeg.org/download.html, select "Linux Static Builds", this redirects to https://johnvansickle.com/ffmpeg/. Then select https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz, do



      tar ffmpeg-release-amd64-static.tar.xz


      Then:



      ./ffmpeg 


      seems to work.



      It might be possible to keep only one of the 3 (or am I wrong?)



      -rwxr-xr-x 1 1000 1000  63M Nov 12 02:45 ffmpeg
      -rwxr-xr-x 1 1000 1000 64M Nov 12 03:05 ffmpeg-10bit
      -rwxr-xr-x 1 1000 1000 63M Nov 12 02:45 ffprobe


      so I think we can reduce the required size to 63M.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Not 100% sure it will work, but I'll try it:



        Go on https://www.ffmpeg.org/download.html, select "Linux Static Builds", this redirects to https://johnvansickle.com/ffmpeg/. Then select https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz, do



        tar ffmpeg-release-amd64-static.tar.xz


        Then:



        ./ffmpeg 


        seems to work.



        It might be possible to keep only one of the 3 (or am I wrong?)



        -rwxr-xr-x 1 1000 1000  63M Nov 12 02:45 ffmpeg
        -rwxr-xr-x 1 1000 1000 64M Nov 12 03:05 ffmpeg-10bit
        -rwxr-xr-x 1 1000 1000 63M Nov 12 02:45 ffprobe


        so I think we can reduce the required size to 63M.






        share|improve this answer












        Not 100% sure it will work, but I'll try it:



        Go on https://www.ffmpeg.org/download.html, select "Linux Static Builds", this redirects to https://johnvansickle.com/ffmpeg/. Then select https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz, do



        tar ffmpeg-release-amd64-static.tar.xz


        Then:



        ./ffmpeg 


        seems to work.



        It might be possible to keep only one of the 3 (or am I wrong?)



        -rwxr-xr-x 1 1000 1000  63M Nov 12 02:45 ffmpeg
        -rwxr-xr-x 1 1000 1000 64M Nov 12 03:05 ffmpeg-10bit
        -rwxr-xr-x 1 1000 1000 63M Nov 12 02:45 ffprobe


        so I think we can reduce the required size to 63M.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 30 at 17:45









        Basj

        90821135




        90821135






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484978%2fis-there-a-more-lightweight-solution-to-read-write-mp3-with-linuxpython%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Entries order in /etc/network/interfaces

            新発田市

            Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)