运行ffmpeg多个命令 [英] Run ffmpeg multiple commands
问题描述
我使用ffmpeg命令将mp3转换为wav:
Im using this ffmpeg command to convert mp3 to wav:
ffmpeg -i audio.mp3 -acodec libmp3lame -ab 64k -ar 16000 audio.wav
和此命令从audio.wav创建波形:
and this command to create waveform from audio.wav:
wav2png --foreground-color=ffb400aa --background-color=2e4562ff -o example4.png papa2.wav
我想知道,如何多次运行此命令?例如,完成从.mp3到.wav的转换后,请运行wav2png命令.
I would love to know, how to run this commands multiple? For example, when conversion from .mp3 to .wav is done, then run the wav2png command.
谢谢!
推荐答案
您在这里有几个选择:
在Bash中,您可以使用 并列出 连接命令.每个命令将一个接一个地执行.当命令失败或所有命令成功执行后,和列表将终止.
In Bash you can use an and list to concatenate commands. Each command will be executed one after the other. The and list will terminate when a command fails, or when all commands have been successfully executed.
ffmpeg -i audio.mp3 audio.wav && wav2png -o output.png audio.wav
-
在输出到WAV时使用
-acodec libmp3lame
没有任何意义,因此我将其删除.Using
-acodec libmp3lame
when outputting to WAV makes no sense, so I removed that.WAV忽略比特率选项,因此我删除了
-ab
.WAV ignores bitrate options, so I removed
-ab
.您是否真的需要更改音频速率(
-ar
)?已删除.Do you really need to change the audio rate (
-ar
)? Removed.代替制作临时的WAV文件,您可以将
ffmpeg
的输出直接通过管道传输到wav2png
:Instead of making a temporary WAV file you can pipe the output from
ffmpeg
directly towav2png
:ffmpeg -i audio.mp3 -f wav - | wav2png -o output.png /dev/stdin
选项3:只需使用
ffmpeg
保存最好的结果,您可以尝试 showwavespic过滤器.
Option 3: Just use
ffmpeg
Saving the best for last, you can try the showwavespic filter.
ffmpeg -i music.wav -filter_complex showwavespic=s=640x320 showwaves.png