height not divisible by 2

h.264 - FFMPEG (libx264) "height not divisible by 2" - Stack Overflow  https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2

After playing around with this a bit, I think I've answered my own question. Here is the solution in case anyone else runs into a similar issue... I had to add the below argument to the command:

-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

Command:

ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

Basically, .h264 needs even dimensions so this filter will:

  1. Divide the original height and width by 2
  2. Round it down to the nearest pixel
  3. Multiply it by 2 again, thus making it an even number

尺寸调整为不大于的最小偶数

from PIL import Image

f = 'my.jpg'
mid_icon = Image.open(f)
h, w = mid_icon.height, mid_icon.width
h, w = int(h / 2) * 2, int(w / 2) * 2
mid_icon = mid_icon.resize((w, h), Image.ANTIALIAS)
mid_icon.save(f)
from PIL import Image

def img_to_floor_even(f):
try:
fo = Image.open(f)
w, h = fo.width, fo.height
w_, h_ = int(w / 2) * 2, int(h / 2) * 2
if (w, h) != (w_, h):
fo = fo.resize((w_, h_), Image.ANTIALIAS)
fo.save(f)
except Exception as e:
print(e)
# log

  

  

height not divisible by 2的更多相关文章

  1. ffmpeg按比例缩放--"width / height not divisible by 2" 解决方法

    最近在处理视频的时候,有这么一个需求 如果视频的分辨率宽度大于960的话,就把宽度设为960,而高度按其比例进行缩放 如果视频的分辨率高度大于540的话,就把高度设为540,而宽度按其比例进行缩放 之 ...

  2. # [libx264 @ 00000275eb57fec0] height not divisible by 2 (520x325)

    # [libx264 @ 00000275eb57fec0] height not divisible by 2 (520x325)

  3. ffmpeg基本功能使用

    任务描述:由给定图像序列合成 24fps 视频 方案一 直接对图像进行操作,适用于图像名比较规范且默认即为所需顺序 ffmpeg -f image2 -i ./images_crop_%d.png - ...

  4. ffmpeg入门篇-滤镜的基本使用

    转发自白狼栈:查看原文 滤镜 什么是滤镜?百度百科介绍说"滤镜主要是用来实现图像的各种特殊效果......". 我们最早在ffmpeg是如何转码的一文中了解过滤镜,来回顾下当时的转 ...

  5. ffmpeg细节整理记录

    ffmpeg细节整理记录 1.-vcodec.-code:v.-c:v ffmpeg的官方文档 -vcodec 是 -code:v 别名. -vcodec codec (output) Set the ...

  6. [PyData] 03 - Data Representation

    Ref: http://blog.csdn.net/u013534498/article/details/51399035 如何在Python中实现这五类强大的概率分布 考虑下在mgrid上画二维概率 ...

  7. H5 canvas的 width、height 与style中宽高的区别

    Canvas 的width height属性 1.当使用width height属性时,显示正常不会被拉伸:如下 <canvas id="mycanvas" width=&q ...

  8. height:100% 布局

    常常会碰到需要填满整个浏览器,并且自适应高度的需求.首先肯定会想到给容器设定height:100%,但是会没有效果.原因是body没有高度,所以百分比无法生效. 解决方案:给html,body,标签都 ...

  9. 页面width与height使用百分比来划分不起作用解决办法--记录六

    有时候你写 <div style="width:80%;height:100%;border:1px solid red"></div> <div s ...

随机推荐

  1. python3+beautifulSoup4.6抓取某网站小说(三)网页分析,BeautifulSoup解析

    本章学习内容:将网站上的小说都爬下来,存储到本地. 目标网站:www.cuiweijuxs.com 分析页面,发现一共4步:从主页进入分版打开分页列表.打开分页下所有链接.打开作品页面.打开单章内容. ...

  2. 笔试算法题(22):二分法求旋转数组最小值 & 骰子值概率

    出题:将一个数组最开始的k个(K小于数组大小N)元素照搬到数组末尾,我们称之为数组的旋转:现在有一个已经排序的数组的一个旋转,要求输出旋转数组中的最小元素,且时间复杂度小于O(N): 分析: 时间复杂 ...

  3. 笔试算法题(02):N阶阶乘 & 双向循环链表实现

    出题:N阶阶乘问题的递归算法和非递归算法: 分析: 第一种解法:普通暴力解法的实现较为容易: 第二种解法:stirling公式可快速给出近似解: 解题: int Recursive(int s) { ...

  4. python3.x Day6 多进程

    多进程:1.每个子进程申请到的资源都是独立的,不与其他进程共享.2.语法上和线程基本上差不多,使用multiprocessing.Process(target=xxxx,args=(xxx,xxx,x ...

  5. nginx虚拟主机配置实践

    1.配置基于域名的虚拟主机 [root@web01 html]# egrep -v "#|^$" /application/nginx/conf/nginx.conf.defaul ...

  6. ResNet,DenseNet

    目录 ResNet BOOM Why call Residual? 发展史 Basic Block Res Block ResNet-18 DenseNet ResNet 确保20层能训练好的前提下, ...

  7. ABC077翻车实况

    今天强行打一波ABC,想作为信心赛,然而= = T1  日常练习读入&输出 T2  $STL$大法好,$sqrt$保平安,我强行递推$WA$了一圈,然后罚时++ T3  woc好难啊,$n=1 ...

  8. 关于iphone 微信浏览器编码问题

    这个问题最终没有完美的解决,给出的一个解决方法是返回一个html文档.

  9. 网页js粘贴截图

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. MySQL集群方案收集

    MySQL集群是一个需要时间才能磨得出的话题,不可能一下子就全部能掌握.由于整个方案结合LVS+Keepalived这种,更加的复杂. 下面是一些主流方案的收集: MySQL双主 + Keepaliv ...