<pre><code>ffmpeg -i music.mp3 -loop 1 -i image.jpg -filter_complex "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p[v];[1:v][v]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a copy -shortest -movflags +faststart output.mp4
</code></pre>

<ul>
<li><p>Remove the <a href="https://ffmpeg.org/ffmpeg-filters.html#format" rel="nofollow noreferrer">format</a> filter after showwaves.</p></li>
<li><p>Use <code>format=auto</code> in the <a href="https://ffmpeg.org/ffmpeg-filters.html#overlay" rel="nofollow noreferrer">overlay</a> filter.</p></li>
<li><p>Do all of the filtering within the filtergraph, so remove <code>-pix_fmt</code> and replace it with the format filter.</p></li>
</ul>

<p>If you want <code>image.jpg</code> to fit within a specific size such as 1280x720:</p>

<pre><code>ffmpeg -i music.mp3 -loop 1 -i image.jpg -filter_complex "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p[fg];[1:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1[bg];[bg][fg]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a copy -shortest -movflags +faststart output.mp4
</code></pre>

CC BY-SA 4.0
2019-02-12T16:31:07.083Z
thanks for script .There is a padding (default black) under the visualiser (in the original script ),how could one change the color of this padding ?I tried adding option  "overlay :colors= Blue" but received an error= "Option 'colors' not found"
srt111
CC BY-SA 4.0
2019-02-12T18:44:29.040Z
@starzar Show a screenshot so I can see what you are describing.
llogan
CC BY-SA 4.0
2019-02-05T07:03:36.583Z
tested your script but the issue still persists.On closer inspection ,the visualizer is there ,it is just getting pushed to the bottom of the page(Some spikes in the frequency could be seen at the page bottom ).How could the visualizer  be bought to the center?.
srt111
CC BY-SA 4.0
2019-02-05T17:52:38.070Z
@starzar Updated answer. It will now center the overlay. The second example will resize images to fit within 1280x720 without needing to pre-process with ImageMagick.
llogan
CC BY-SA 4.0
2019-02-04T20:44:39.493Z
2019-02-05T17:51:54.727Z
2019-02-05T17:51:54.727Z
llogan
<p>Scale does matter while creating ffmpeg videos with images.</p>

<p>In the above case, some background images were really small (eg 512 x 210 etc).
On doing a batch size conversion  of all the background images (using Imagemagick)to 1280x720 (same as render size) the above code works fine </p>

CC BY-SA 4.0
2019-02-05T16:44:39.577Z
2019-02-05T16:59:10.100Z
2019-02-05T16:59:10.100Z
srt111
<p>The code below runs a perfect red audiovisualizer when run on a “black” colored background. But when used with any other colored jpg image the visualizer just doesn't show up. What's missing? </p>

<pre><code>ffmpeg -y -i music.mp3 -loop 1 -i black.jpg -filter_complex \
   "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p,format=yuv420p[v];[1:v][v]overlay=0:200[outv]" \
   -map "[outv]" -pix_fmt yuv420p -map 0:a -c:v libx264 -c:a copy -shortest output_bg.mp4
</code></pre>

<p><a href="https://i.sstatic.net/lKCoz.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lKCoz.jpg" alt="enter image description here"></a>
<a href="https://i.sstatic.net/FmKVc.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FmKVc.jpg" alt="enter image description here"></a></p>

<ffmpeg>
Audiovisualiser not visible
srt111
# Audiovisualiser not visible

(Asked by: username_0 on 2019-02-04)

The code below runs a perfect red audiovisualizer when run on a “black” colored background. But when used with any other colored jpg image the visualizer just doesn't show up. What's missing? 
ffmpeg -y -i music.mp3 -loop 1 -i black.jpg -filter_complex \
   "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p,format=yuv420p[v];[1:v][v]overlay=0:200[outv]" \
   -map "[outv]" -pix_fmt yuv420p -map 0:a -c:v libx264 -c:a copy -shortest output_bg.mp4

**Tags:** ffmpeg


---

## 2 answers

### Answer by username_1 on 2019-02-04. Score: 1

ffmpeg -i music.mp3 -loop 1 -i image.jpg -filter_complex "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p[v];[1:v][v]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a copy -shortest -movflags +faststart output.mp4


Remove the format filter after showwaves.
Use format=auto in the overlay filter.
Do all of the filtering within the filtergraph, so remove -pix_fmt and replace it with the format filter.

If you want image.jpg to fit within a specific size such as 1280x720:
ffmpeg -i music.mp3 -loop 1 -i image.jpg -filter_complex "[0:a]showwaves=s=1280x175:colors=Red:mode=p2p[fg];[1:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1[bg];[bg][fg]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a copy -shortest -movflags +faststart output.mp4

> **Comments:**
> **username_0**: tested your script but the issue still persists.On closer inspection ,the visualizer is there ,it is just getting pushed to the bottom of the page(Some spikes in the frequency could be seen at the page bottom ).How could the visualizer  be bought to the center?.  
> **username_1**: @starzar Updated answer. It will now center the overlay. The second example will resize images to fit within 1280x720 without needing to pre-process with ImageMagick.  
> **username_0**: thanks for script .There is a padding (default black) under the visualiser (in the original script ),how could one change the color of this padding ?I tried adding option  "overlay :colors= Blue" but received an error= "Option 'colors' not found"  
> **username_1**: @starzar Show a screenshot so I can see what you are describing.  

---

### Answer by username_0 on 2019-02-05. Score: 0

Scale does matter while creating ffmpeg videos with images.

In the above case, some background images were really small (eg 512 x 210 etc).
On doing a batch size conversion of all the background images (using Imagemagick)to 1280x720 (same as render size) the above code works fine


---

