ffmpeg - Can I draw an audio channel as an image?

狂风中的少年 提交于 2019-12-23 07:40:06

问题


I'm wondering if it's possible to draw an audio channel of a video or audio file as an image using ffmpeg, or if there's another tool that would do it on Win2k8 x64. I'm doing this as part of an encoding process after a user uploads a video or audio file.

I'm using ColdFusion 10 to handle the upload and calling cfexecute to run ffmpeg.

I need the image to look something like this (without the horizontal lines):


回答1:


You can do this programmatically very easily.

Study the basics of FFmpeg. I suggest you to compile this sample. It explains how to open a video/audio, identify the streams and loop over the packets.

Once you have the data packet (in this case you are interested only in the audio packets). You will decode it (line 87 of this document) and obtain the raw data of an audio. It's the waveform itself (the analogue "bitmap" for an audio).

You could also study this sample. This second example is how to write a video/audio file. You don't want to write any video, but with this sample you can easily understand how the audio raw data packet works, if you see the functions get_audio_frame() and write_audio_frame().

You need to have some knowledge about creating a bitmap. Any platform has an easy way to do that.

So, the answer for you: YES, IT IS POSSIBLE TO DO THIS WITH FFMPEG! But you have to code a little bit in order to get what you want...

UPDATE:

Sorry, there are ALSO built-in features for this:

You could use those filters... or

showspectrum, showwaves, avectorscope

Here are some examples on how to use it: FFmpeg Filters - 12.22 showwaves.



来源:https://stackoverflow.com/questions/16509906/ffmpeg-can-i-draw-an-audio-channel-as-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!