I try to get the waves of an audio file as image. I'd like to use FFmpeg but unfortunately I found very less code in this regard and the documentary has just one example. I use it for the first time. So I tried this kotlin code using showwavespic:
val audioFile = File(pathAudioFile)
val wavePic = File(context.filesDir.absolutePath + "/waveform.png")
val cmd = "-y -i ${audioFile.path} showwavespic=s=640x120 ${wavePic.path}"
try {
when(FFmpeg.execute(cmd)){
Config.RETURN_CODE_SUCCESS -> {
frameLayout.findViewById<ImageView>(R.id.waveView).setImageURI(Uri.fromFile(wavePic))
}
else -> {
}
}
With that command the else-block get's called so it seems to be wrong. This is the example from the documentary
ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
I don't need the available options (for now) so what is my fault? I'm also not sure if I need the path or the file itself so I tried this:
val cmd = "-i $audioFile waveform.png"
But that doesn't work neither. Can somebody help me with my first steps using FFmpeg?