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条)

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败