Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

enter image description here

like image 855
Redtopia Avatar asked May 12 '13 17:05

Redtopia


1 Answers

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.

like image 130
Wagner Patriota Avatar answered Sep 22 '22 14:09

Wagner Patriota