[FFmpeg-user] FFMpeg encoding error: "height not divisible by 2" - Recommended dimesion 1680 x ??? with aspect 16:9

He Lei helei0908 at hotmail.com
Mon Oct 22 11:47:19 EEST 2018


The encoder needs multiples of 2. It better be a multiple of 16.
You can create a black background,   center over the background use the source image.
This will not distort the image.

black  = yuv(0, 128, 128);


//=========================
src_ratio = src_w / src_h;                //ratio of source
dst_ratio = 16.0 / 9;                         //ratio of destination

if(src_ratio > dst_ratio){
  bg_w = src_w;                               //width of background
  bg_h = (int)(bg_w / dst_ratio);      //height of background
  bg_h += bg_h % 2;                       //make it a multiple of 2
}else{
  bg_h = src_h;
  bg_w = (int)(bg_h * dst_ratio);
  bg_w += bg_w % 2;                       //make it a multiple of 2
}

overlay_x = (bg_w - src_w) / 2; //overlay_x  and overlay_y always have one equal to 0
overlay_y = (bg_h - src_h) / 2;


then:
1,create background with size(bg_w, bg_h);
2,overlay to (overlay_x, overlay_y) with the source;
3,encode


LeiHe
helei0908 at hotmail.com<mailto:helei0908 at hotmail.com>



在 2018年10月22日,下午3:32,Ben <bxstover-at-yahoo.co.uk at ffmpeg.org<mailto:bxstover-at-yahoo.co.uk at ffmpeg.org>> 写道:

I wanted to encode (and resize) an existing MP4 file into a new MP4 video and a width of 1680 * ... and an aspect ratio of 16:9
The used codec is H.264

Since the calculated height therefore is (1680/16)*9=945 I entered this for the ffmpeg command and got an error:

"height not divisible by 2"

Hmm, can this really be?

What is the recommended height otherwise?

Is there no auto-adjustment in ffmpeg?

Ben
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org<mailto:ffmpeg-user at ffmpeg.org>
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-user mailing list