Changes between Version 3 and Version 4 of Waveform


Ignore:
Timestamp:
Dec 28, 2015, 12:18:54 AM (2 years ago)
Author:
llogan
Comment:

add showwaves 'n friends

Legend:

Unmodified
Added
Removed
Modified
  • Waveform

    v3 v4  
    11[[PageOutline(1-100,Contents)]] 
    22 
    3 = Overview = 
    4  
    53Audio data is often represented by a waveform image. This guide explains how to 
    6 easily create such an image using FFmpeg and Gnuplot. 
    7  
    8 = Single Channel = 
     4easily create such an image or video. 
     5 
     6= Waveform image = 
     7 
     8The [https://ffmpeg.org/ffmpeg-filters.html#showwavespic showwavespic] filter is the easiest method to create a waveform image. 
     9 
     10== All channels == 
     11 
     12[[Image(showwavespic.png)]] 
     13 
     14{{{ 
     15ffmpeg -i input -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png 
     16}}} 
     17 
     18All channels will be represented by various shades in the waveform. 
     19 
     20== Downmixed == 
     21 
     22[[Image(showwavespic_mono.png)]] 
     23 
     24If you want a simpler representation where all channels are represented by one waveform you can downmix your audio to mono first with [https://ffmpeg.org/ffmpeg-filters.html#aformat aformat]: 
     25 
     26{{{ 
     27ffmpeg -i input -filter_complex "aformat=channel_layouts=mono,showwavespic=s=640x120" -frames:v 1 output.png 
     28}}} 
     29 
     30== Separate channels == 
     31 
     32[[Image(showwavespic_split.png)]] 
     33 
     34If you want to split them into separate channels: 
     35 
     36{{{ 
     37ffmpeg -i input -filter_complex "showwavespic=s=640x240:split_channels=1" -frames:v 1 output.png 
     38}}} 
     39 
     40== Changing range == 
     41 
     42[[Image(showwavespic_compand.png)]] 
     43 
     44If the waveform looks a little flat you can use the [https://ffmpeg.org/ffmpeg-filters.html#compand compand] filter to expand or compress the dynamic range: 
     45 
     46{{{ 
     47ffmpeg -i input -filter_complex "compand,showwavespic=s=640x120" -frames:v 1 output.png 
     48}}} 
     49 
     50Note that this won't be as accurate of a representation as it would without compand, but for aesthetics it may be preferred. 
     51 
     52== Adding color, alpha (transparency), and background == 
     53 
     54Using [https://ffmpeg.org/ffmpeg-filters.html#format format], [https://ffmpeg.org/ffmpeg-filters.html#colorkey colorkey], [https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer colorchannelmixer], and [https://ffmpeg.org/ffmpeg-filters.html#overlay overlay]: 
     55 
     56{{{ 
     57ffmpeg -i input -i background.png -filter_complex \ 
     58"[0:a]showwavespic=s=640x240,format=rgba,colorkey=black,colorchannelmixer=rr=0.953:gg=0.435:bb=0.133[top]; \ 
     59 [1:v][top]overlay=format=rgb" \ 
     60-frames:v 1 output.png 
     61}}} 
     62 
     63* This example assumes the background is the same width and height as the waveform. If it is not, you can [https://ffmpeg.org/ffmpeg-filters.html#scale scale], [https://ffmpeg.org/ffmpeg-filters.html#crop crop], or [https://ffmpeg.org/ffmpeg-filters.html#pad pad] the background first. 
     64 
     65* This example will make the waveform an orange color (`#f36f22` or `rgb(243,111,34)`). The RGB value for each color channel must be interpolated to fit the 0-1 range of the colorchannelmixer filter by dividing each value by 255. For example, the green channel is 111/255≈0.435. 
     66 
     67= Waveform video = 
     68 
     69[[Image(showwaves.png)]] 
     70 
     71The [https://ffmpeg.org/ffmpeg-filters.html#showwaves showwaves] filter makes a video waveform. 
     72 
     73{{{ 
     74ffmpeg -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  
     75}}} 
     76 
     77---- 
     78 
     79= Using Gnuplot = 
     80 
     81== Single Channel == 
    982 
    1083Plotting a single channel waveform is easier as the data can be passed to 
     
    96169 
    97170 
    98 = Multiple Channels = 
     171== Multiple Channels == 
    99172 
    100173While the basic idea and the command for plotting multiple channels remain the 
     
    140213 
    141214 
    142 = Additional Hints = 
     215== Additional Hints == 
    143216 
    144217Sometimes there are a few loud pitches while the rest of the data is relatively