0

I was looking to put an audio visualiser filter on my podcast file(mp3)and got the necessary code from here.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 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!

2
  • 1
    Set size in showwaves to 1280x176.
    – Gyan
    Commented Feb 4, 2019 at 15:00
  • @Gyan tried 1280x174,1280x175,1280x176 - not working
    – srt111
    Commented Feb 4, 2019 at 15:46

2 Answers 2

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.

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

enter image description here

3
  • It looks like ffmpeg scaling doesn't work well on "odd dimensions" --> what does this mean?
    – Gyan
    Commented Feb 4, 2019 at 16:51
  • odd is the opposite of even, They are numbers that are not multiples of 2.
    – SlimSCSI
    Commented Feb 5, 2019 at 0:26
  • 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.
    – Alexander
    Commented Oct 29, 2020 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.