Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques ffmpeg incorrectly assumes width to be odd, when it is even – [libx264 @ 0xe302cd0]width or height not divisible by 2

  • ffmpeg incorrectly assumes width to be odd, when it is even – [libx264 @ 0xe302cd0]width or height not divisible by 2

    Posted by Siddhant Bhansali on December 3, 2011 at 7:48 am

    ffmpeg gives the following error:
    [libx264 @ 0xe302cd0]width or height not divisible by 2 (710×425)

    when trying to convert a 710×426 video (as per VLC) via the following command line:
    ffmpeg -i profilevid.mov -vcodec libx264 -r 29.97 -ar 48000 -ab 64k -b 1324k -vpre default profilevid.mp4

    Output:

    built on Jun 2 2009 04:35:52, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)

    Seems stream 1 codec frame rate differs from container frame rate: 59.94 (5994/100) -> 29.97 (30000/1001)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘profilevid.mov’:
    Duration: 00:00:55.48, start: 0.000000, bitrate: 3367 kb/s
    Stream #0.0(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    Stream #0.1(eng): Video: h264, yuv420p, 710×425, 29.97 tbr, 29.97 tbn, 59.94 tbc
    Output #0, mp4, to ‘profilevid.mp4’:
    Stream #0.0(eng): Video: libx264, yuv420p, 710×425, q=10-51, 1324 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, s16, 64 kb/s
    Stream mapping:
    Stream #0.1 -> #0.0
    Stream #0.0 -> #0.1
    [libx264 @ 0xe302cd0]width or height not divisible by 2 (710×425)
    Error while opening codec for output stream #0.0 – maybe incorrect parameters such as bit_rate, rate, width or height

    Rahul Seth replied 11 years, 10 months ago 3 Members · 5 Replies
  • 5 Replies
  • Reuben Martin

    December 4, 2011 at 12:44 am

    First, ffmpeg from 2009 is very very old.

    Either ffmpeg is wrong, or the video is encoded wrong. Either way you can add “-s 710×426” to force ffmpeg to scale it to the correct size.

    However you shouldn’t really need to re-encode the video. It’s already in h264 format. Just re-encode the audio to aac and copy the video stream.

    ffmpeg -i profilevid.mov -vcodec copy -acodec libfaac -ar 48000 -ab 64k -f mp4 profilevid.mp4

  • Siddhant Bhansali

    December 5, 2011 at 12:06 am

    Hi Reuben,

    Thanks for replying. To clarify further, this ffmpeg command is part of an automated script that handles a variety of user uploaded video formats. It worked fine for all videos except for this particular instance where it was breaking and I was investigating why.

    Also, regarding your comment about the version, there’s been a bit of back and forth between my hosting company and I and they have said that they have installed the latest version of ffmpeg. Running ffmpeg from the command line shows the following, is there any strong reason to believe otherwise?

    I dont understand the ‘FFmpeg version %{evr}’ – can I check the version number elsewhere?

    root@vps [~]# ffmpeg
    FFmpeg version %{evr}, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: –prefix=/usr –libdir=/usr/lib64 –shlibdir=/usr/lib64 –mandir=/usr/share/man –enable-shared –enable-gpl –enable-postproc –enable-swscale –enable-avfilter –enable-avfilter-lavf –enable-pthreads –enable-vdpau –disable-avisynth –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-nonfree –disable-demuxer=v4l –disable-demuxer=v412 –disable-indevs –disable-outdevs –enable-shared –extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC –disable-stripping
    libavutil 49.15. 0 / 49.15. 0
    libavcodec 52.20. 0 / 52.20. 0
    libavformat 52.31. 0 / 52.31. 0
    libavdevice 52. 1. 0 / 52. 1. 0
    libavfilter 0. 4. 0 / 0. 4. 0
    libswscale 0. 7. 1 / 0. 7. 1
    libpostproc 51. 2. 0 / 51. 2. 0
    built on Jun 2 2009 04:35:52, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)
    At least one output file must be specified

  • Reuben Martin

    December 5, 2011 at 3:13 am

    Well if it’s user submitted content, that’s a whole new ballgame… For all you know, user uploaded content may have been encoded with some sort of crappy freeware encoder that jacked things up. Anything can go wrong in those cases, and it’s hard to write a script to effectively deal with any sort of oddball problem. In this case, given that it’s a h264+pcm in a mov format, and that it uses a 5994/100 frame-rate/frame-base it was probably encoded with something quicktime based. (5994/100 is incorrect. It should be 60000/1001. Apple has NEVER set NTSC timings correctly…)

    All video in h264 is actually encoded with the width and height as multiples of 16. It’s just how the DCT encoding functions work. They have to break an image down into 16×16 pixel blocks. If the video width or height is not a multiple of 16, extra pixels are added, and then a flag is set to tell the decoder to chop off those extra pixels at playback time. Most likely something is broken with how that cropping information was encoded. OR the ffmpeg version used has a bug.

    The version may be the latest version of ffmpeg available for RedHat 4.1.2 (or whatever RedHat clone is being used), but certainly not the version most recently available. I’m simply basing that from the copyright and build date from June of 2009. But, if this is provided by a hosting company rather than in-house you don’t have much control over that anyway.

    It looks like the variable used to give the version number was not set, so you might not be able to nail down the exact version. From the date, it’s probably from the 0.5.x series. Ffmpeg and libx264 have both come a long way since then.

    Try “ffmpeg -version”. My output:

    ffmpeg version 0.8.7, Copyright (c) 2000-2011 the FFmpeg developers
    built on Nov 30 2011 19:06:24 with gcc 4.5.3
    configuration: –prefix=/usr –libdir=/usr/lib64 –shlibdir=/usr/lib64 –mandir=/usr/share/man –enable-shared –cc=x86_64-pc-linux-gnu-gcc –disable-optimizations –disable-static –enable-gpl –enable-version3 –enable-postproc –enable-avfilter –disable-stripping –disable-debug –disable-doc –enable-libmp3lame –enable-libvo-aacenc –enable-libvo-amrwbenc –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-libaacplus –enable-nonfree –enable-libfaac –enable-nonfree –enable-libdc1394 –disable-indev=v4l –disable-indev=v4l2 –disable-indev=oss –enable-x11grab –disable-outdev=oss –enable-frei0r –enable-libfreetype –enable-pthreads –enable-libopencore-amrwb –enable-libopencore-amrnb –enable-libgsm –enable-libdirac –enable-librtmp –enable-libschroedinger –enable-libspeex –enable-libvpx –enable-libopenjpeg –disable-altivec –disable-avx –cpu=host –enable-hardcoded-tables
    libavutil 51. 9. 1 / 51. 9. 1
    libavcodec 53. 8. 0 / 53. 8. 0
    libavformat 53. 5. 0 / 53. 5. 0
    libavdevice 53. 1. 1 / 53. 1. 1
    libavfilter 2. 23. 0 / 2. 23. 0
    libswscale 2. 0. 0 / 2. 0. 0
    libpostproc 51. 2. 0 / 51. 2. 0
    ffmpeg 0.8.7
    libavutil 51. 9. 1 / 51. 9. 1
    libavcodec 53. 8. 0 / 53. 8. 0
    libavformat 53. 5. 0 / 53. 5. 0
    libavdevice 53. 1. 1 / 53. 1. 1
    libavfilter 2. 23. 0 / 2. 23. 0
    libswscale 2. 0. 0 / 2. 0. 0
    libpostproc 51. 2. 0 / 51. 2. 0

  • Siddhant Bhansali

    December 5, 2011 at 4:27 am

    Hmm – good points, but nevertheless we do need a ‘blanket’ conversion process in our application to handle user videos. I’m planning to use the following and I do have a mechanism to detect when the conversion breaks altogether:

    ffmpeg -i input.ext -vcodec libx264 -s 640×360 -qmax 30 output.mp4

    # ffmpeg -version

    FFmpeg version %{evr}, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: –prefix=/usr –libdir=/usr/lib64 –shlibdir=/usr/lib64 –mandir=/usr/share/man –enable-shared –enable-gpl –enable-postproc –enable-swscale –enable-avfilter –enable-avfilter-lavf –enable-pthreads –enable-vdpau –disable-avisynth –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-nonfree –disable-demuxer=v4l –disable-demuxer=v412 –disable-indevs –disable-outdevs –enable-shared –extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC –disable-stripping
    libavutil 49.15. 0 / 49.15. 0
    libavcodec 52.20. 0 / 52.20. 0
    libavformat 52.31. 0 / 52.31. 0
    libavdevice 52. 1. 0 / 52. 1. 0
    libavfilter 0. 4. 0 / 0. 4. 0
    libswscale 0. 7. 1 / 0. 7. 1
    libpostproc 51. 2. 0 / 51. 2. 0
    built on Jun 2 2009 04:35:52, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)
    FFmpeg %{evr}
    libavutil 49.15. 0 / 49.15. 0
    libavcodec 52.20. 0 / 52.20. 0
    libavformat 52.31. 0 / 52.31. 0
    libavdevice 52. 1. 0 / 52. 1. 0
    libavfilter 0. 4. 0 / 0. 4. 0
    libswscale 0. 7. 1 / 0. 7. 1
    libpostproc 51. 2. 0 / 51. 2. 0

  • Rahul Seth

    August 4, 2014 at 10:04 am

    Hey I want to create video from different png images (same size 1366*768) and 1 audio file. here is my command

    ffmpeg -i ‘ . $audio . ‘ -f image2 -loop 1 -r ‘ . $rate . ‘ -i uploads/%03d.png -shortest -c:a copy -c:v libx264 -qscale:v ‘. $qscale .’ -pix_fmt yuv420p -crf ‘. $crf .’ -preset slow uploads/’ . $title . ‘1.mp4

    but I face an error message

    Stream mapping:
    Stream #0:1 -> #0:0 (mjpeg (native) -> h264 (libx264))
    Stream #0:0 -> #0:1 (copy)
    Error while opening encoder for output stream #0:0 – maybe incorrect parameters such as bit_rate, rate, width or height

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy