简体   繁体   中英

What are those bars in audio visualizer exactly? Need to make visualizer with help of ffmpeg

I'm trying to understand what are those bars in audio visualizers exactly.

音频可视化器

I tried to decode a mp3 file using ffmpeg like this:

ffmpeg -i music.mp3 -t 1 -f s8 -acodec pcm_s8 -ar 1 out_1sec_sr1.raw

The output of this command is raw data of first second of the music.mp3 in 1hz samplerate. But the output file contains just 2 bytes... one for the left channel and one for the right channel? I'm pretty sure that it is not possible to visualize a second of a music using only two bytes? I guess each bar in below picture is at least one byte. Am I missing something in ffmpeg command? Is pcm_s8 codec appropriate for getting such data to visualize audio at all?

I'm using this library in my android project to use ffmpeg: https://github.com/brarcher/ffmpeg-android-java

I do not have any problem in drawing those bars and reading raw data file from storage using inputStream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM