Lame MP3 Converter的Python等效项是什么?

如何解决Lame MP3 Converter的Python等效项是什么?

| 我需要在服务器端将mp3音频文件转换为64kbps。 现在,我正在使用
subprocess
来调用
lame
,但是我想知道是否有其他好的选择?     

解决方法

这里的主题似乎有点陈旧:http://www.dreamincode.net/forums/topic/72083-lame-mp3-encoder-for-python/ 最后的结论是通过Python-> C绑定创建一个到lame_enc.dll的自定义绑定。 该结论的原因是尚未维护现有的绑定库(pymedia / py-lame)。 不幸的是,那个家伙没有让它起作用:) 也许您应该继续使用
subprocess
。您可以利用这一选择,在更高的层次上抽象您的编码,并重用代码/策略来有选择地执行其他命令行编码工具(例如ogg或shn工具)。 我已经看到几种音频翻录工具采用了这种策略。     ,我一直在使用Python音频工具,该工具能够在不同的音频格式之间进行转换。 我已经使用它将.wav文件转换为mp3,.flac和.m4a。     ,如果要使用LAME编码MP3(而不是PyMedia),则始终可以使用ctypes包装la脚的编码器DLL(如果是Linux,则为.so)。您将使用的确切包装器代码将与LAME DLL版本绑定(不幸的是,其中有很多这样的代码),因此我无法给出任何示例,但是ctypes文档应该是关于包装DLL足够清楚。     ,注意:这里是相对较新的程序员,我以前不需要转换音频文件。 但是,如果我正确理解了服务器端的含义,那么您可能正在寻找一种管理大量转换的好方法,而您对python解决方案的兴趣可能部分是为了能够更好地管理资源使用或集成进入您的加工链。我遇到了类似的问题/目标,并结合使用了Merlyn的推荐和Celery。我不使用django-celery,但是如果这是基于django的项目,那也可能会吸引您。您可以在此处找到有关芹菜的更多信息: http://celeryproject.org/community.html http://ask.github.com/celery/getting-started/introduction.html 根据您已经设置的内容,可能需要一些前期时间才能进行设置。要充分利用所有功能,您需要安装rabbitmq / erlang,但是如果您按照上述站点上的指南进行操作,现在它很快。 这是我如何将芹菜与子过程结合使用以解决类似问题的示例。与上面发布者的建议类似,我使用子过程调用ffmpeg,它与视频工具一样好,实际上也可能与音频工具一样好。我在这里包含的多余信息使您对自己的配置有所了解。
    #example of configuring an option,here I\'m selecting how much I want to adjust bitrate
    #based on my input\'s format
    def generate_command_line_method(self):
        if self.bitrate:
            compression_dict =  {\'.mp4\':1.5,\'.rm\':1.5,\'.avi\': 1.2,\'.mkv\': 1.2,\'.mpg\': 1,\'.mpeg\':1}
            if self.ext.lower() in compression_dict.keys():
                compression_factor = compression_dict[self.ext.lower()]

        #Making a list to send to the command line through subprocess
        ffscript = [\'ffmpeg\',\'-i\',self.fullpath,\'-b\',str(self.bitrate * compression_factor),\'-qscale\',\'3\',#quality factor,based on trial and error
                   \'-g\',\'90\',#iframe roughly per 3 seconds
                   \'-intra\',outpath
                   ]
        return ffscript

        #The celery side of things,I\'d have a celeryconfig.py file in the 
        #same directory as the script that points to the following function,so my task 
        #queue would know the specifics of the function I\'ll call through it.  You can
        #see example configs on the sites above,but it\'s basically just going to be
        #a tuple that says,here are the modules I want you to look in,celery,e.g.
        #CELERY_MODULES = (\"exciting_asynchronous_module.py\",).  This file then contains,from celery.decorators import task
        from mymodule import myobject
        from subprocess import Popen

        @task(time_limit=600) #say,for example,10 mins
        def run_ffscript(ffscript):
            some_result = Popen(ffscript).wait() 

            #Note: we\'ll wait because we don\'t want to compound
            #the asynchronous aspect (we don\'t want celery to launch the subprocess and think
            #it has finished.

        #Then I start up celery/rabbitmq,and got into my interactive shell (ipython shown):
        #I\'ll have some generator feeding these ffscripts command lines,then process them 
        #with something like:

        In[1]: for generated_ffscript in generator:
                  run_ffscript.delay(generated_ffscript)
让我知道这对您是否有用。我在这里回答问题相对较新,不确定我的尝试是否有帮助。祝好运!     ,好吧,Gstreamer具有\“ ugly plugin \” lamemp3enc,并且有针对Gstreamer的python绑定(gst-python 1.2,支持python 3.3)。我没有尝试过自己做这条路,所以我真的没有什么建议的地方……坦白说,对我来说,子流程解决方案似乎要简单得多,即使不是“更干净”。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-