ffmpeg命令行太多了,运行ffmpeg多个命令

Im using this ffmpeg command to convert mp3 to wav:

ffmpeg -i audio.mp3 -acodec libmp3lame -ab 64k -ar 16000 audio.wav

and this command to create waveform from audio.wav:

wav2png --foreground-color=ffb400aa --background-color=2e4562ff -o example4.png papa2.wav

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.

Thank You!

解决方案

You have several options here:

Option 1: Use &&

In Bash you can use an 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

Using -acodec libmp3lame when outputting to WAV makes no sense, so I removed that.

WAV ignores bitrate options, so I removed -ab.

Do you really need to change the audio rate (-ar)? Removed.

Option 2: Pipe from ffmpeg to wav2png

Instead of making a temporary WAV file you can pipe the output from ffmpeg directly to wav2png:

ffmpeg -i audio.mp3 -f wav - | wav2png -o output.png /dev/stdin

Option 3: Just use ffmpeg

Saving the best for last, you can try the showwavespic filter.

c61ed3ec4485e1c8a596820139a5f7d5.png

ffmpeg -i music.wav -filter_complex showwavespic=s=640x320 showwaves.png

If you want to make a video of the wave form, then try showwaves.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值