| 6 | | easily create such an image using FFmpeg and Gnuplot. |
| 7 | | |
| 8 | | = Single Channel = |
| | 4 | easily create such an image or video. |
| | 5 | |
| | 6 | = Waveform image = |
| | 7 | |
| | 8 | The [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 | {{{ |
| | 15 | ffmpeg -i input -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png |
| | 16 | }}} |
| | 17 | |
| | 18 | All channels will be represented by various shades in the waveform. |
| | 19 | |
| | 20 | == Downmixed == |
| | 21 | |
| | 22 | [[Image(showwavespic_mono.png)]] |
| | 23 | |
| | 24 | If 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 | {{{ |
| | 27 | ffmpeg -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 | |
| | 34 | If you want to split them into separate channels: |
| | 35 | |
| | 36 | {{{ |
| | 37 | ffmpeg -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 | |
| | 44 | If 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 | {{{ |
| | 47 | ffmpeg -i input -filter_complex "compand,showwavespic=s=640x120" -frames:v 1 output.png |
| | 48 | }}} |
| | 49 | |
| | 50 | Note 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 | |
| | 54 | Using [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 | {{{ |
| | 57 | ffmpeg -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 | |
| | 71 | The [https://ffmpeg.org/ffmpeg-filters.html#showwaves showwaves] filter makes a video waveform. |
| | 72 | |
| | 73 | {{{ |
| | 74 | 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 |
| | 75 | }}} |
| | 76 | |
| | 77 | ---- |
| | 78 | |
| | 79 | = Using Gnuplot = |
| | 80 | |
| | 81 | == Single Channel == |