Answers.Body: <p>It looks like FFmpeg scaling doesn't work well on <strong>&quot;odd dimensions&quot;</strong>. I manually changed the image dimensions to 244×207 to 244×208 [<strong>even</strong>] (using MS Paint resize option) now everything works fine!</p>
  <p><a href="https://i.sstatic.net/GWeEQ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GWeEQ.jpg" alt="enter image description here" /></a></p>
  <p><a href="https://i.sstatic.net/uyxDE.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uyxDE.jpg" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-29T19:11:53.930Z
Answers.Text: you didn't use scale in your original command. It's not only ffmpeg's issue - the x264 codec requires the output to be divisible by 2 (both height and width). Therefor if you feed an image with not divisible by 2 dimensions, you must scale it: filter_complex "1 scale=244:208 [img]" or you can pad it with color pixel "1 pad=h=208 [img]" see more in docs.
Answers.UserDisplayName: Alexander
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-04T16:51:23.900Z
Answers.Text: *It looks like ffmpeg scaling doesn't work well on "odd dimensions"* --> what does this mean?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-05T00:26:35.837Z
Answers.Text: odd is the opposite of even, They are numbers that are not multiples of 2.
Answers.UserDisplayName: SlimSCSI
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-04T16:09:17.363Z
Answers.LastActivityDate: 2021-01-13T00:24:20.907Z
Answers.LastEditDate: 2021-01-13T00:24:20.907Z
Answers.UserDisplayName: srt111
Answers.Body: <p>Use</p>
  
  <p><code>ffmpeg -y -i audio.mp3 -loop 1 -i image.jpg -filter_complex "[1:v]scale=2*trunc(iw*sar/2):2*trunc(ih/2)[bg];[0:a]showwaves=s=1280x175:colors=White:mode=p2p,format=yuv420p[v];[bg][v]overlay=0:200[outv]" -map "[outv]" -pix_fmt yuv420p -map 0:a -c:v libx264 -c:a copy -shortest output12.mp4</code></p>
  
  <p>Since the image is the base layer, its dimensions should be made even.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-04T15:52:47.077Z
Answers.LastActivityDate: 2019-02-04T15:52:47.077Z
Answers.UserDisplayName: Gyan
Body: <p>I was looking to put an audio visualiser filter on my podcast file(mp3)and got the necessary code from <a href="https://www.youtube.com/watch?v=H5dCKuN9Ius" rel="nofollow noreferrer">here</a>.But on running the code,the terminal gave an error"height not divisible by 2".I tried my best to apply the solution from <a href="https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2">here</a> but it didn't work.Any suggestions would be helpful.</p>
  
  <p>Code:</p>
  
  <blockquote>
    <p>ffmpeg -y -i audio.mp3 -loop 1 -i image.jpg -filter_complex "[0:a]showwaves=s=1280x175:colors=White: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 output12.mp4</p>
  </blockquote>
  
  <p>Error Log:</p>
  
  <blockquote>
    <p>ffmpeg version N-90762-g223f3dff8c Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 7.3.0 (GCC)
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 15.100 / 56. 15.100
      libavcodec     58. 19.100 / 58. 19.100
      libavformat    58. 13.100 / 58. 13.100
      libavdevice    58.  4.100 / 58.  4.100
      libavfilter     7. 18.100 /  7. 18.100
      libswscale      5.  2.100 /  5.  2.100
      libswresample   3.  2.100 /  3.  2.100
      libpostproc    55.  2.100 / 55.  2.100
    [mp3 @ 000001fa2ffdabc0] Estimating duration from bitrate, this may be inaccurate
    Input #0, mp3, from 'fast.mp3':
      Duration: 00:00:13.98, start: 0.000000, bitrate: 128 kb/s
        Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
    Input #1, png_pipe, from 'scott.png':
      Duration: N/A, bitrate: N/A
        Stream #1:0: Video: png, rgb24(pc), 244x207 [SAR 1:1 DAR 244:207], 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream mapping:
      Stream #0:0 (mp3float) -> showwaves
      Stream #1:0 (png) -> overlay:main
      overlay -> Stream #0:0 (libx264)
      Stream #0:0 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    [libx264 @ 000001fa2ffdd080] height not divisible by 2 (244x207)
    Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    Conversion failed!</p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-04T15:00:39.737Z
Comments.Text: Set size in showwaves to 1280x176.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-04T15:46:12.710Z
Comments.Text: @Gyan tried 1280x174,1280x175,1280x176  - not working
Comments.UserDisplayName: srt111
Tags: <ffmpeg>
Title: Error:-[libx264 @ 000001fa2ffdd080] height not divisible by 2 (244x207)
UserDisplayName: srt111
ThreadText: # Error:-[libx264 @ 000001fa2ffdd080] height not divisible by 2 (244x207)
  
  (Asked by: username_0 on 2019-02-04)
  
  I was looking to put an audio visualiser filter on my podcast file(mp3)and got the necessary code from [here](https://www.youtube.com/watch?v=H5dCKuN9Ius).But on running the code,the terminal gave an error"height not divisible by 2".I tried my best to apply the solution from [here](https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2) but it didn't work.Any suggestions would be helpful.
  
  Code:
  
  > ffmpeg -y -i audio.mp3 -loop 1 -i image.jpg -filter\_complex "[0:a]showwaves=s=1280x175:colors=White: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 output12.mp4
  
  Error Log:
  
  > ffmpeg version N-90762-g223f3dff8c Copyright (c) 2000-2018 the FFmpeg developers
  > built with gcc 7.3.0 (GCC)
  > configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  > libavutil 56. 15.100 / 56. 15.100
  > libavcodec 58. 19.100 / 58. 19.100
  > libavformat 58. 13.100 / 58. 13.100
  > libavdevice 58. 4.100 / 58. 4.100
  > libavfilter 7. 18.100 / 7. 18.100
  > libswscale 5. 2.100 / 5. 2.100
  > libswresample 3. 2.100 / 3. 2.100
  > libpostproc 55. 2.100 / 55. 2.100
  > [mp3 @ 000001fa2ffdabc0] Estimating duration from bitrate, this may be inaccurate
  > Input #0, mp3, from 'fast.mp3':
  > Duration: 00:00:13.98, start: 0.000000, bitrate: 128 kb/s
  > Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
  > Input #1, png\_pipe, from 'scott.png':
  > Duration: N/A, bitrate: N/A
  > Stream #1:0: Video: png, rgb24(pc), 244x207 [SAR 1:1 DAR 244:207], 25 fps, 25 tbr, 25 tbn, 25 tbc
  > Stream mapping:
  > Stream #0:0 (mp3float) -> showwaves
  > Stream #1:0 (png) -> overlay:main
  > overlay -> Stream #0:0 (libx264)
  > Stream #0:0 -> #0:1 (copy)
  > Press [q] to stop, [?] for help
  > [libx264 @ 000001fa2ffdd080] height not divisible by 2 (244x207)
  > Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit\_rate, rate, width or height
  > Conversion failed!
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Set size in showwaves to 1280x176.  
  > **username_0**: @username_1 tried 1280x174,1280x175,1280x176  - not working  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-02-04. Score: 0
  
  It looks like FFmpeg scaling doesn't work well on **"odd dimensions"**. I manually changed the image dimensions to 244×207 to 244×208 [**even**] (using MS Paint resize option) now everything works fine!
  
  [![enter image description here](https://i.sstatic.net/GWeEQ.jpg)](https://i.sstatic.net/GWeEQ.jpg)
  
  [![enter image description here](https://i.sstatic.net/uyxDE.jpg)](https://i.sstatic.net/uyxDE.jpg)
  
  > **Comments:**
  > **username_1**: *It looks like ffmpeg scaling doesn't work well on "odd dimensions"* --> what does this mean?  
  > **username_3**: odd is the opposite of even, They are numbers that are not multiples of 2.  
  > **username_2**: you didn't use scale in your original command. It's not only ffmpeg's issue - the x264 codec requires the output to be divisible by 2 (both height and width). Therefor if you feed an image with not divisible by 2 dimensions, you must scale it: filter_complex "1 scale=244:208 [img]" or you can pad it with color pixel "1 pad=h=208 [img]" see more in docs.  
  
  ---
  
  ### Answer by username_1 on 2019-02-04. Score: 0
  
  Use
  
  `ffmpeg -y -i audio.mp3 -loop 1 -i image.jpg -filter_complex "[1:v]scale=2*trunc(iw*sar/2):2*trunc(ih/2)[bg];[0:a]showwaves=s=1280x175:colors=White:mode=p2p,format=yuv420p[v];[bg][v]overlay=0:200[outv]" -map "[outv]" -pix_fmt yuv420p -map 0:a -c:v libx264 -c:a copy -shortest output12.mp4`
  
  Since the image is the base layer, its dimensions should be made even.
  
  
  ---
  
  