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
[email protected]<mailto:[email protected]>
在 2018年10月22日,下午3:32,Ben
<[email protected]<mailto:[email protected]>>
写道:
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
[email protected]<mailto:[email protected]>
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".