0

With ffmpeg, it's possible to generate an image-based waveform representation from an audio file with this command:

ffmpeg -i input -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png

It produces an output akin to the following:

waveform image

from https://trac.ffmpeg.org/wiki/Waveform


This creates a waveform image for the entire audio file. How can I make it so that it only creates the waveform for a specific part of it, without first separately clipping the source file into an entirely new audio file? Say from 50 seconds to 60.453 seconds.

2 Answers 2

4

I'm presuming you'll be able to use seeking with the waveform imaging... otherwise you'll need to cut the sound clip first.

Seeking in FFMpeg:

ffmpeg -ss 00:50:00 -i will start at 50 seconds into the file

and we then use the -to 60:45.300 after the input to allow the file to play this far.

Combined with the input file this gives us:

ffmpeg -ss 00:50:00 -to 00:60:43 -i input -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png

1
1

The selected answer may have been right in the past, but it no longer is in the versions I've tried (ffmpeg version 2021-12-09-git-b9f4c1231f-full_build-www.gyan.dev + ffmpeg version 2023-04-10-git-b18a9c2971-full_build-www.gyan.dev).

I'm presuming you'll be able to use seeking with the waveform imaging... otherwise you'll need to cut the sound clip first.

The above portion of the selected answer IS correct, however. Seeking does not work with showwavespic. This should probably be submitted as a bug to ffmpeg.

The command below does work and hackily pipes the output of one ffmpeg command (one for splitting) to another (one for the waveform creation).

It assumes an input video with aac audio (otherwise you will need to change the -f paramater in the first command) and is set to overwrite the created output.png if it exists (-y in the second command) rather than fail in that case.

ffmpeg -i inputfile.mp4 -ss 1:11 -t 3 -vn -acodec copy -f adts - | ffmpeg -i - -y -filter_complex "compand,showwavespic=s=800x400" output.png

Another option is found in the man pages https://trac.ffmpeg.org/wiki/Waveform#UsingGnuplot but I haven't gotten around to trying that yet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .