运行ffmpeg多个命令 [英] Run ffmpeg multiple commands

查看:1308
本文介绍了运行ffmpeg多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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 to wav2png:

      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
      

      • 如果要制作波形视频,请尝试 showwaves .
      • 您可以在使用ffmpeg 生成波形.
        • If you want to make a video of the wave form, then try showwaves.
        • You can see a colored example at Generating a waveform using ffmpeg.
        • 这篇关于运行ffmpeg多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆