Afficher la forme d’onde ou spectrogramme en ligne de code sous Linux

FORME D'ONDE

All channels

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

All channels will be represented by various shades in the waveform.

Downmixed

Pour une représentation en mono :

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

Separate channels

If you want to split them into separate channels:

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

Changing range

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

Video

ffmpeg -i input -filter_complex "[0:a]showwaves=s=1280x720:mode=line,format=yuv420p[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy output.mkv

s= dimsensions de la vidéo ((ffmpeg-utils)"Video size" section in the ffmpeg-utils manual. Default value is 600x240.

mode= Set display mode. Available values are:Default value is point.

point Draw a point for each sample.line Draw a vertical line for each sample.
p2p Draw a point for each sample and a line between them.cline Draw a centered vertical line for each sample.

n Set the number of samples which are printed on the same column. A larger value will decrease the frame rate. Must be a positive integer. This option can be set only if the value for rate is not explicitly specified.

rate, r Set the output frame rate. This is done by setting the option n. Default value is 25.

split_channels Set if channels should be drawn separately or overlap. Default value is 0.

colors Set colors separated by ’|’ which are going to be used for drawing of each channel.

scale= Set amplitude scale. Available values are:Default is linear.

lin Linear.

log Logarithmic.

sqrt Square root.

cbrt Cubic root.

draw= set the draw mode. This is mostly useful to set for high n.Default value is scale.

Available values are:

scale Scale pixel values for each drawn sample.

full Draw every sample directly.

Exemples :

Output the input file audio and the corresponding video representation at the same time:

amovie=a.mp3,asplit[out0],showwaves[out1]

Create a synthetic signal and show it with showwaves, forcing a frame rate of 30 frames per second:

aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]

showwavespic

s= dimensions de la vidéo. voir (ffmpeg-utils)"Video size" section in the ffmpeg-utils manual. Default value is 600x240.

split_channels Set if channels should be drawn separately or overlap. Default value is 0.
colors Set colors separated by ’|’ which are going to be used for drawing of each channel.

scale= Set amplitude scale. Available values are:Default is linear.

lin Linear.

log Logarithmic.
sqrt Square root.

cbrt Cubic root.

Exemples :

Extract a channel split representation of the wave form of a whole audio track in a 1024x800 picture using ffmpeg:

ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png

voir : https://ffmpeg.org/ffmpeg-filters.html#showwavespic

SPECTROGRAMME

sox my.wav -n spectrogram

créer le spectrogramme du fichier entier dans spectrogram.png.

sox my.wav -n remix 2 trim 20 30 spectrogram

Spectrogramme du canal droit (remix 2), et de 20s à 50s (20+30).

Pour analyser une petite portion du spectre :

sox my.wav -n rate 6k spectrogram

permet l'analyse jusqu'à 3kHz (moitié du taux d'échantillonnage) là où la voix humaine est la plus sensible.

sox my.wav -n trim 0 10 spectrogram -x 600 -y 200 -z 100

Taille des axes X, Y et Z. (ici, une image de 600x200 pixels et une profondeur de 100 dB). Attention, la légende est incluse dans les dimensions :

sox -n -n synth 6 tri 10k:14k spectrogram -z 100 -w kaiser
rate 2k spectrogram -X 200 -Z -10 -w kaiser

Options disponibles pour l'apparence et nom du fichier de sortie :

sox my.wav -n spectrogram -m -l -o print.png

pour une sortie en noir & blanc.

Options

-x num Change the (maximum) width (X-axis) of the spectrogram from its (800 par défaut) pixels to a given number entre 100 and 200000.

-X num X-axis pixels/second.

-y num axe des Y en pixels (per channel); N.B. it can be slow to produce the spectrogram if this number is not one more than a power of two (e.g. 129). By default the Y-axis size is chosen automatically.

-Y num Hauteur totale (550 px par défaut).

-z num axe des Z (couleur) range in dB, default 120. De 20 (très contrasté) à 180 (peu contrasté).

-Z num limit d'axe des Z en dBFS. A negative num effectively increases the `brightness' of the spectrogram display.

-q num Sets the Z-axis quantisation, i.e. the number of different colours (or intensities) in which to render Z-axis values. A small number (e.g. 4) will give a `poster'-like effect making it easier to discern magnitude bands of similar level. Small numbers also usually result in small PNG files. The number given specifies the number of colours to use inside the Z-axis range; two colours are reserved to represent out-of-range values.

-w name Window: Hann (default), Hamming, Bartlett, Rectangular or Kaiser. The spectrogram is produced using the Discrete Fourier Transform (DFT) algorithm. A significant parameter to this algorithm is the choice of `window function'. By default, SoX uses the Hann window which has good all-round frequency-resolution and dynamic-range properties. For better frequency resolution (but lower dynamic-range), select a Hamming window; for higher dynamic-range (but poorer frequency-resolution), select a Kaiser window. Bartlett and Rectangular windows are also available.

-W num Window adjustment parameter. This can be used to make small adjustments to the Kaiser window shape. A positive number (up to ten) increases its dynamic range, a negative number decreases it.

-s Allow slack overlapping of DFT windows. This can, in some cases, increase image sharpness and give greater adherence to the -x value, but at the expense of a little spectral loss.

-m monochrome.

-p num Permute the colours in a colour or hybrid palette. The num parameter, from 1 (défaut) to 6, selects the permutation.

-l Creates a printer friendly spectrogram with a light background (default dark background).

-a Suppress the display of the axis lines.

-r Raw spectrogram: suppress the display of axes and legends.

-A Selects an alternative, fixed colour-set.

-t text Set the image title - text to display above the spectrogram.

-c text Set (or clear) the image comment - text to display below and to the left of the spectrogram.

-o text Nom du fichier PNG en sortie (par défaut spectrogramm.png).

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *