dqrzot2791 2010-02-21 04:13
浏览 73
已采纳

你如何用PHP运行命令行程序(如lame或svn)?

Specifically, I need to automate the encoding of audio files into mp3 with LAME. You don't need to know LAME to answer this, I could be talking about svn or some other program..

I know how to use LAME on the command line to do this, for one file at a time.

I would like to do this via a php script however, so I can convert a bunch at once (for instance, all the files in a directory)

So what I am confused about, is how I should invoke the program, LAME. I could definitely use shell_exec() http://php.net/manual/en/function.shell-exec.php

But is that a "screwy" way to do it, since I am going through the shell?

Should I be using lame_enc.dll somehow instead, instead of lame.exe?

It seems like I could somehow do it with exec() also http://php.net/manual/en/function.exec.php

But in that case, how would I supply the arguments?

Or is there a better way to do it, maybe a .bat file? I am running windows

Should I be using lame_enc.dll instead of lame.exe somehow?

  • 写回答

2条回答 默认 最新

  • duankuixi1930 2010-02-21 04:21
    关注

    It's possible to do it with PHP. Not a typical use case scenario but it can be done. Since you are on Windows, a bat file would be better suited since then you don't need the PHP parser to run the script.

    Put the same commands you would run in the console to convert your audio files with LAME in a *.bat. Then run the bat as if it was a regular executable file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!